BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
demoTutorialDialog.C
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #include "demoTutorialDialog.h"
6 #include "mainframe.h"
7 
11 
18 
21 
31 #include <BALL/SYSTEM/path.h>
32 
33 #include <QtGui/QPushButton>
34 #include <QtGui/QMessageBox>
35 #include <QtGui/QTextBrowser>
36 
37 using namespace std;
38 
39 namespace BALL
40 {
41  namespace VIEW
42  {
43 
45 {
55 };
56 
57 
58 DemoTutorialDialog::DemoTutorialDialog(QWidget* parent, const char* name)
59  : QDialog(parent),
60  Ui_DemoTutorialDialogData(),
61  ModularWidget(name),
62  surface_(0),
63  demo_action_(0),
64  tutorial_action_(0),
65  raytracing_tutorial_action_(0)
66 {
67 #ifdef BALL_VIEW_DEBUG
68  Log.error() << "new DemoTutorialDialog " << this << std::endl;
69 #endif
70 
71  setupUi(this);
72  setObjectName(name);
73 
74  // register the widget with the MainControl
76  hide();
77  connect(next_button, SIGNAL(clicked()), this, SLOT(nextStepClicked()));
78  connect(cancel_button, SIGNAL(clicked()), this, SLOT(hide()));
79 }
80 
82 {
83 #ifdef BALL_VIEW_DEBUG
84  Log.error() << "deleting DemoTutorialDialog " << this << std::endl;
85 #endif
86 
87  delete surface_;
88 }
89 
91 {
92  setWindowTitle(tr("BALLView Demo"));
93 
94  prefix_ = getBaseDir_() + "demo";
95 
96  next_button->setEnabled(true);
97  QDialog::show();
98  raise();
99  move(20,20);
100 
101  // hide some dockwidgets
102  if (LogView::getInstance(0) != 0) LogView::getInstance(0)->hide();
103  if (DatasetControl::getInstance(0) != 0) DatasetControl::getInstance(0)->hide();
104 #ifdef BALL_PYTHON_SUPPORT
105  if (PyWidget::getInstance(0) != 0) PyWidget::getInstance(0)->hide();
106 #endif
107 
108 #ifdef BALL_HAS_RTFACT
109  // Set the background to black
110  ColorRGBA color(0, 0, 0, 255);
111  Stage* stage = Scene::getInstance(0)->getStage();
112 
113  stage->setBackgroundColor(color);
114  StageSettings* stage_settings = Scene::getInstance(0)->getStageSettings();
115  stage_settings->updateFromStage();
116 
117  //TODO: get rid of this hack.
118  //TODO: BALLView should come up with good light settings by itself!
119  // set a good light source
120  stage->clearLightSources();
121 
122  LightSource ls;
123 
124  ls.setPosition(Vector3(1, -2, -15));
125  ls.setAttenuation(Vector3(0., 0., 0.3));
127  ls.setColor(ColorRGBA(255, 255, 255, 255));
128  ls.setIntensity(500./100);
129  stage->addLightSource(ls);
130  LightSettings::getInstance(0)->updateFromStage();
131  // apply everything to the scene...
132  Scene::getInstance(0)->applyPreferences();
133 #endif
134 }
135 
137 {
138  Path p;
139  String dir = p.find( String("..")
141  + "doc"
143  + "internal"
145 
146  return dir;
147 }
148 
150 {
151  if (tutorial_type_ == TUTORIAL)
152  {
153  setWindowTitle(tr("BALLView Tutorial"));
154  prefix_ = getBaseDir_() + "tutorial";
155  }
156  else if (tutorial_type_ == RAYTRACING_TUTORIAL)
157  {
158  setWindowTitle(tr("Ray tracing Tutorial"));
159  prefix_ = getBaseDir_() + "raytracing_tutorial";
160  }
161 
162  next_button->setEnabled(false);
163 
164 #ifdef BALL_HAS_RTFACT
165  // Set the defaults
166  ((Mainframe*)getMainControl())->reset();
167 
168  Scene::getInstance(0)->show();
169  MolecularControl::getInstance(0)->show();
170  MolecularControl::getInstance(0)->setFloating(false);
171  MolecularControl::getInstance(0)->applyPreferences();
172  GeometricControl::getInstance(0)->show();
173  GeometricControl::getInstance(0)->applyPreferences();
174  GeometricControl::getInstance(0)->setFloating(false);
175 
176  // Set the background to black
177  ColorRGBA color(0, 0, 0, 255);
178  Stage* stage = Scene::getInstance(0)->getStage();
179 
180  stage->setBackgroundColor(color);
181 
182  StageSettings* stage_settings = Scene::getInstance(0)->getStageSettings();
183  stage_settings->updateFromStage();
184 
185  // get one useable light source
186  stage->clearLightSources();
187 
188  LightSource ls;
189 
190  ls.setPosition(Vector3(1, -2, -15));
191  ls.setAttenuation(Vector3(0., 0., 0.7));
193  ls.setColor(ColorRGBA(255, 255, 255, 255));
194  ls.setIntensity(500./100);
195 
196  stage->addLightSource(ls);
197  LightSettings::getInstance(0)->updateFromStage();
198 #endif
199  if (tutorial_type_ == TUTORIAL)
200  {
201  DatasetControl::getInstance(0)->show();
202  DatasetControl::getInstance(0)->applyPreferences();
203  DatasetControl::getInstance(0)->setFloating(false);
204  }
205  else if (tutorial_type_ == RAYTRACING_TUTORIAL)
206  {
207 #ifdef BALL_HAS_RTFACT
208  Stage::Material& rt_material = stage->getMaterial();
209 
210  rt_material.ambient_color = ColorRGBA(255, 255, 255, 255);
211  rt_material.ambient_intensity = 0.;
212 
213  rt_material.specular_color = ColorRGBA(255, 255, 255, 255);
214  rt_material.specular_intensity = 1.;
215 
216  rt_material.reflective_color = ColorRGBA(255, 255, 255, 255);
217  rt_material.reflective_intensity = 0.;
218 
219  rt_material.shininess = 75.031;
220  rt_material.transparency = 0;
221 
222  Scene::getInstance(0)->getMaterialSettings()->updateDefaultMaterialsFromStage();
223 
224  // set ball and stick as next model
225  DisplayProperties::getInstance(0)->selectModel(MODEL_BALL_AND_STICK);
226 
227  // apply everything to the scene...
228  Scene::getInstance(0)->applyPreferences();
229 
230  next_button->setEnabled(true);
231 #else
232  Log.info() << "DemoTutorialDialog: no RTFact available! Close the dialog!" << __FILE__ << " " << __LINE__ << endl;
233  return;
234 #endif
235  }
236  LogView::getInstance(0)->hide();
237 }
238 
240 {
241  current_step_ = 1;
242 
243  if (tutorial_type_ == DEMO)
244  {
245  initDemo_();
246  }
247  else
248  {
249  int result = QMessageBox::question(this, tr("Warning"),
250  tr("To start the tutorial, all loaded structures and molecules will be deleted."),
251  QMessageBox::Ok| QMessageBox::Cancel, QMessageBox::Ok);
252  if (result != QMessageBox::Ok) return;
253 
254  initTutorials_();
255  }
256 
257  QUrl qurl = QUrl::fromLocalFile((prefix_ + "01.html").c_str());
258  text_browser->setSource(qurl);
259 
260  QDialog::show();
261  resize(350, 650);
262  raise();
263 }
264 
266 {
267  if (!isVisible()) return;
268 
269  switch (tutorial_type_)
270  {
271  case DEMO:
272  onNotifyDemo_(message);
273  break;
274  case TUTORIAL:
275  onNotifyTutorial_(message);
276  break;
277  case RAYTRACING_TUTORIAL:
279  break;
280  }
281 }
282 
284 {
285  RepresentationMessage* rmsg = RTTI::castTo<RepresentationMessage>(*message);
286 
287  if (current_step_ == 13 ||
288  current_step_ == 14)
289  {
290  if (!RTTI::isKindOf<FinishedSimulationMessage>(*message)) return;
291  }
292  else if (current_step_ == 15)
293  {
294  DatasetMessage* msg = RTTI::castTo<DatasetMessage>(*message);
295  if (msg == 0) return;
296 
297  if (msg->getDataset() == 0)
298  {
300  return;
301  }
302 
303  RegularData3DDataset* set = dynamic_cast<RegularData3DDataset*>(msg->getDataset());
304  if (set->getType() != RegularData3DController::type) return;
305 
306  grid_ = (RegularData3D*) set->getData();
307  }
308  else if (current_step_ == 16)
309  {
310  SceneMessage* msg = RTTI::castTo<SceneMessage>(*message);
311  if (msg == 0 || msg->getType() != SceneMessage::REBUILD_DISPLAY_LISTS)
312  {
313  return;
314  }
315  }
316  else if (rmsg == 0 ||
318  {
319  return;
320  }
321 
322  enableNextStep_();
323 }
324 
325 
327 {
328  next_button->setEnabled(true);
329 }
330 
331 // TODO: split into several functions...
333 {
334  String id = String(current_step_ + 1); //TODO WHY??
335  if (id.size() == 1) id = "0" + id;
336 
337  id = prefix_ + id + ".html";
338 
339  QUrl qurl = QUrl::fromLocalFile(id.c_str());
340  text_browser->setSource(qurl);
341  next_button->setEnabled(false);
342 
343  if (tutorial_type_ == DEMO)
344  {
345  if (current_step_ == 17)
346  {
347  showTutorial();
348  return;
349  }
350 
351  nextStepDemo_();
352 
353  #ifdef BALL_HAS_RTFACT
354  // we do not want to show energy minimization and MD simulation
355  if (current_step_ == 11)
356  {
357  current_step_ +=2;
358  next_button->setEnabled(true);
359  }
360  #endif
361 
362  }
363  else if (tutorial_type_ == TUTORIAL)
364  {
365  if (current_step_ == 8)
366  {
367  next_button->setEnabled(true);
368  }
369  if (current_step_ == 10)
370  {
371  hide();
372  HelpViewer* hv = HelpViewer::getInstance(1);
373  if (hv == 0) return;
374  hv->showHelp();
375  hv->setFloating(true);
376  hv->showMaximized();
377  }
378  }
379  else if (tutorial_type_ == RAYTRACING_TUTORIAL)
380  {
381  switch (current_step_)
382  {
383  case 2:
384  {
385  // prepare the background for the next step
386  ColorRGBA color(255, 255, 255, 255); // white
387  Scene::getInstance(0)->getStage()->setBackgroundColor(color);
388  StageSettings* stage_settings = Scene::getInstance(0)->getStageSettings();
389  stage_settings->updateFromStage();
390  Scene::getInstance(0)->applyPreferences();
391  break;
392  }
393 
394  case 4: // preparing downgraded light settings
395  {
396  // There should be just a single light source!
397  // first manipulate the light
398  LightSource& ls = Scene::getInstance(0)->getStage()->getLightSource(0);
399  ls.setPosition(Vector3(1, -8, -45)); //(Vector3(1, -2, -15));
400  ls.setAttenuation(Vector3(0., 0., 0.2)); //0.7
402  ls.setColor(ColorRGBA(255, 255, 255, 255)); //ColorRGBA(255, 245, 208, 255));
403  ls.setIntensity(250./100);
404  LightSettings::getInstance(0)->updateFromStage();
405 
406  // then change the camera position
407  Camera& camera = Scene::getInstance(0)->getStage()->getCamera();
408  camera.setViewPoint(camera.getViewPoint()+Vector3(20,20,20));
409 
410  // update everything
411  Scene::getInstance(0)->applyPreferences();
412  break;
413  }
414  case 5: //preparing bad materials
415  {
416  // Add a plane to be used as a mirror
417  if (getMainControl()->getCompositeManager().getComposites().size() == 0)
418  {
419  Log.info() << "DemoTutorialDialog: no system available! " << __FILE__ << " " << __LINE__ << endl;
420  return;
421  }
422 
423  addPlane_('x', 5, 5);
424  break;
425  }
426  case 7:
427  {
428  // offer the Documentation
429  hide();
430  HelpViewer* hv = HelpViewer::getInstance(1);
431  if (hv == 0) return;
432  hv->showHelp();
433  hv->setFloating(true);
434  hv->showMaximized();
435  break;
436  }
437 
438  default: // nothing to see here...
439  break;
440  }
441  }
442 
443  current_step_++;
444 }
445 
446 void DemoTutorialDialog::addPlane_(char plane_specifier, int height, int boundary, bool bottom)
447 {
448  HashSet<Composite*> composites = MainControl::getInstance(0)->getCompositeManager().getComposites();
449  HashSet<Composite*>::Iterator sit = composites.begin();
450 
452  Vector3 v_low(0., 0., 0.);
453  Vector3 v_upp(0., 0., 0.);
454 
455  System* system = NULL;
456  system = dynamic_cast<System*>(*sit);
457  if (system != 0)
458  {
459  system->apply(bbp);
460  v_low = Vector3(bbp.getLower().x, bbp.getLower().y, bbp.getLower().z);
461  v_upp = Vector3(bbp.getUpper().x, bbp.getUpper().y, bbp.getUpper().z);
462  }
463  else
464  {
465  Log.info() << "DemoTutorialDialog.addPlane(): No system given! "<< __FILE__ << " " << __LINE__ << endl;
466  return;
467  }
468 
469  ++sit;
470  for (; +sit; ++sit)
471  {
472  system = dynamic_cast<System*>(*sit);
473  if (system != 0)
474  {
475  system->apply(bbp);
476  Vector3 low = Vector3(bbp.getLower().x, bbp.getLower().y, bbp.getLower().z);
477  Vector3 upp = Vector3(bbp.getUpper().x, bbp.getUpper().y, bbp.getUpper().z);
478 
479  // find the boundaries over all systems
480  if (v_low.x > low.x) v_low.x = low.x;
481  if (v_low.y > low.y) v_low.y = low.y;
482  if (v_low.z > low.z) v_low.z = low.z;
483 
484  if (v_upp.x < upp.x) v_upp.x = upp.x;
485  if (v_upp.y < upp.y) v_upp.y = upp.y;
486  if (v_upp.z < upp.z) v_upp.z = upp.z;
487 
488  }
489  }
490 
491  if (! bottom)
492  {
493  Vector3 v_tmp = v_low;
494  v_low = v_upp;
495  v_upp = v_tmp;
496  height = height*(-1);
497  boundary = boundary*(-1);
498  }
499 
500  Vector3 v_low_left (0., 0., 0.);
501  Vector3 v_low_right(0., 0., 0.);
502  Vector3 v_upp_right(0., 0., 0.);
503  Vector3 v_upp_left (0., 0., 0.);
504 
505  Vector3 normal(0., 0., 0.);
506 
507 
508  if (plane_specifier == 'x')
509  {
510  v_low = v_low - Vector3(height, boundary, boundary);
511  v_upp = v_upp + Vector3(height, boundary, boundary);
512  v_low_left = Vector3(v_low.x, v_low.y, v_low.z);
513  v_low_right = Vector3(v_low.x, v_upp.y, v_low.z);
514  v_upp_right = Vector3(v_low.x, v_upp.y, v_upp.z);
515  v_upp_left = Vector3(v_low.x, v_low.y, v_upp.z);
516  normal = Vector3(1., 0., 0.);
517  }
518  else if (plane_specifier == 'y')
519  {
520  v_low = v_low - Vector3(boundary, height, boundary);
521  v_upp = v_upp + Vector3(boundary, height, boundary);
522  v_low_left = Vector3(v_low.x, v_low.y, v_low.z);
523  v_low_right = Vector3(v_low.x, v_low.y, v_upp.z);
524  v_upp_right = Vector3(v_upp.x, v_low.y, v_upp.z);
525  v_upp_left = Vector3(v_upp.x, v_low.y, v_low.z);
526  normal = Vector3(0., 1., 0.);
527  }
528  else if (plane_specifier == 'z')
529  {
530  v_low = v_low - Vector3(boundary, boundary, height);
531  v_upp = v_upp + Vector3(boundary, boundary, height);
532  v_low_left = Vector3(v_low.x, v_low.y, v_low.z);
533  v_low_right = Vector3(v_low.x, v_upp.y, v_low.z);
534  v_upp_right = Vector3(v_upp.x, v_upp.y, v_low.z);
535  v_upp_left = Vector3(v_upp.x, v_low.y, v_low.z);
536  normal = Vector3(0., 0., 1.);
537  }
538  else
539  {
540  Log.info() << "DemoTutorialDialog.addPlane(): unknown plane_specifier! "<< __FILE__ << " " << __LINE__ << endl;
541  return;
542  }
543 
544  // create the plane
545  Mesh* plane = new Mesh();
546 
547  // the vertices
548  plane->vertex.push_back(v_low_left);
549  plane->vertex.push_back(v_low_right);
550  plane->vertex.push_back(v_upp_right);
551  plane->vertex.push_back(v_upp_left);
552 
553  // the first triangle of the plane
554  Mesh::Triangle t1;
555  t1.v1 = 0; // v_low_left
556  t1.v2 = 1; // v_low_right
557  t1.v3 = 2; // v_upp_right
558 
559  plane->triangle.push_back(t1);
560 
561  // the second triangle of the plane
562  Mesh::Triangle t2;
563  t2.v1 = 2; // v_upp_right
564  t2.v2 = 3; // v_upp_left
565  t2.v3 = 0; // v_low_left
566 
567  plane->triangle.push_back(t2);
568 
569  // the normals
570  for (int i=0; i<4; i++)
571  plane->normal.push_back(normal);
572 
573  // color
574  ColorRGBA color(0,0,0,1);
575  plane->setColor(color);
576 
577  // a representation
579  rep->setName("Mirror Plane");
580 
581  // insert
582  rep->insert(*plane);
583 
584  // and commit
585  getMainControl()->insert(*rep);
586  getMainControl()->update(*rep);
588 }
589 
590 
591 
593 {
594  // initialisation for first real step
595  if (current_step_ == 1)
596  {
597  DisplayProperties* dp = DisplayProperties::getInstance(0);
599 
600  ((Mainframe*)getMainControl())->reset();
601 
602  // open bpti
603  try
604  {
605  Path path;
606  String file_name = path.find("structures/bpti.pdb");
607 
608  MolecularFileDialog* dialog = MolecularFileDialog::getInstance(0);
609  if (dialog == 0) return;
610 
612  system_ = dialog->openMolecularFile(file_name);
614 
615  if (system_ == 0)
616  {
617  String msg((String)tr("Could not open bpti.pdb. Maybe the file was deleted?")+"\n");
618  msg += (String)tr("It should be found in") + " " + file_name;
619 
620  QMessageBox::critical(0, tr("Error while starting BALLView Demo"), msg.c_str(),
621  QMessageBox::Ok, Qt::NoButton, Qt::NoButton);
622  return;
623  }
624 
625  system_->apply(getFragmentDB().add_hydrogens);
626  system_->apply(getFragmentDB().build_bonds);
627  getMainControl()->update(*system_, true);
628  }
629  catch(Exception::FileNotFound e)
630  {
631  Log.error() << (String)tr("Could not open") << " " << e.getFilename() << std::endl;
632  return;
633  }
634 
635  composites_.clear();
636  composites_.push_back(system_);
637  }
638 
639  if (current_step_ == 17) // last page
640  {
641  hide();
642  return;
643  }
644  MolecularStructure* ms = MolecularStructure::getInstance(0);
645 
646  next_button->setEnabled(current_step_ >= 14);
647 
648  // remove representations
651  std::list<Representation*> reps = pm.getRepresentations();
652 
653  if (surface_ == 0 && nr == 1 && current_step_ == 6)
654  {
655  GeometricObject* go = *(**reps.begin()).getGeometricObjects().begin();
656  Mesh* mesh = dynamic_cast<Mesh*>(go);
657  if (mesh != 0)
658  {
659  surface_ = new Mesh(*mesh);
660  }
661  else
662  {
663  // should not happen
665  surface_ = new Mesh();
666  }
667  }
668 
669  for (Position p = 0; p < nr; p++)
670  {
671  getMainControl()->remove(**reps.begin());
672  reps.pop_front();
673  }
674 
675  if (current_step_ < 6)
676  {
677  ModelType type = (ModelType) (current_step_ - 1);
678  if (type >= MODEL_SA_SURFACE)
679  {
680  type = (ModelType)((Index)type + 1);
681  }
682  notify_(new CreateRepresentationMessage(composites_, type, COLORING_ELEMENT));
683  }
684  else if (current_step_ < 8)
685  {
686  ModelType type = (ModelType) (current_step_ - 1);
687  if (type >= MODEL_SA_SURFACE)
688  {
689  type = (ModelType)((Index)type + 1);
690  }
691  notify_(new CreateRepresentationMessage(composites_, type, COLORING_MOLECULE));
692  }
693  else if (current_step_ == 8)
694  {
696  getMainControl()->getMolecularControlSelection().push_back(system_);
697  ms->calculateHBonds();
699 #ifndef BALL_HAS_RTFACT
701 #endif
702  }
703  else if (current_step_ == 9)
704  {
706  }
707  else if (current_step_ == 10)
708  {
710  }
711  else if (current_step_ == 11)
712  {
714  }
715  else if (current_step_ == 12 ||
716  current_step_ == 13)
717  {
721 
722  list<Composite*> composites;
723  composites.push_back(*getMainControl()->getCompositeManager().getComposites().begin());
724  MolecularControl::getInstance(0)->highlight(composites);
725 
726  if (current_step_ == 12)
727  {
729  ms->chooseAmberFF();
732 #ifdef BALL_HAS_RTFACT
734 #else
736 #endif
737  ms->runMinimization(false);
738  }
739  else
740  {
741  ms->getMDSimulationDialog().setTimeStep(0.002);
743  ms->MDSimulation(false);
744  }
745  }
746  else if (current_step_ == 14) //FDPB
747  {
749  if (!ms->calculateFDPB(false))
750  {
752  }
754  }
755  else if (current_step_ == 15) // SES colored
756  {
757  // Create a new representation containing the contour surface.
760  rep->insert(*new Mesh(*surface_));
761  getMainControl()->insert(*rep);
762 
763  ModifyRepresentationDialog* cdialog = ModifyRepresentationDialog::getInstance(0);
764  cdialog->setMode(0);
765  cdialog->setRepresentation(rep);
766  cdialog->setGrid(grid_);
767  cdialog->setMinValue(-0.7);
768  cdialog->setMaxValue(0.7);
769  cdialog->accept();
770 
771  getMainControl()->update(*rep);
772  }
773  else if (current_step_ == 16)
774  {
778 
780 
781  DatasetController* dc = DatasetControl::getInstance(0)->getController(RegularData3DController::type);
783  vector<Dataset*> grids = rcon.getDatasets();
784  if (grids.empty()) return;
785  rcon.computeIsoContourSurface(*grids[0], ColorRGBA(255,0,0), -0.1);
786  rcon.computeIsoContourSurface(*grids[0], ColorRGBA(0,0,255), 0.1);
787 
788  // last entry: we are done
789  }
790 }
791 
793 {
794  tutorial_type_ = RAYTRACING_TUTORIAL;
795  show();
796 }
797 
798 
800 {
801  tutorial_type_ = TUTORIAL;
802  show();
803 }
804 
806 {
807  tutorial_type_ = DEMO;
808  show();
809 }
810 
812 {
813  CompositeMessage* cmsg = RTTI::castTo<CompositeMessage>(*message);
814  RepresentationMessage* rmsg = RTTI::castTo<RepresentationMessage>(*message);
815 
816  if (rmsg != 0 && rmsg->getRepresentation() == 0) return;
817 
818  switch (current_step_)
819  {
820  case TUTORIAL_PEPTIDE: // "Building a peptide from a given sequence"
821  {
822  if (cmsg == 0 || cmsg->getType() != CompositeMessage::NEW_MOLECULE) return;
823  break;
824  }
825 
826  case TUTORIAL_ROTATE: // "Rotating"
827  {
828  if (!RTTI::isKindOf<SceneMessage>(*message)) return;
829  break;
830  }
831 
832  case TUTORIAL_HIERARCHY: // "Hierarchy of molecules"
833  {
834  break;
835  }
836 
837  case TUTORIAL_MDS: // "Molecular Dynamics Simulation")
838  {
839  if (!RTTI::isKindOf<DatasetMessage>(*message)) return;
840  DatasetMessage* msg = dynamic_cast<DatasetMessage*>(message);
841  if (msg->getDataset() == 0)
842  {
844  return;
845  }
846 
847  if (msg->getDataset()->getType() != TrajectoryController::type ||
848  msg->getType() != DatasetMessage::ADD)
849  {
850  return;
851  }
852 
853  break;
854  }
855 
856  case TUTORIAL_TRAJECTORY: // "Visualisation of trajectories")
857  {
858  if (cmsg != 0 && cmsg->getType() == CompositeMessage::CHANGED_COMPOSITE)
859  {
860  enableNextStep_();
861  }
862  break;
863  }
864 
865  case TUTORIAL_ES: // "Calculation of electrostatics"
866  {
867  if (!RTTI::isKindOf<DatasetMessage>(*message)) return;
868  DatasetMessage* msg = dynamic_cast<DatasetMessage*>(message);
869  if (msg->getDataset() == 0)
870  {
872  return;
873  }
874 
876  msg->getType() != DatasetMessage::ADD)
877  {
878  return;
879  }
880 
881  break;
882  }
883 
884  case TUTORIAL_SES: // "Creating a Solvent Excluded Surface"
885  {
886  if (rmsg == 0 ||
889  {
890  return;
891  }
892  break;
893  }
894 
895  case TUTORIAL_SES_COLORING: // "Coloring a SES by electrostatics"
896  {
897  if (rmsg == 0 ||
900  {
901  return;
902  }
903  break;
904  }
905 
906  case TUTORIAL_CS: // "Creating a isocontour surface"
907  {
908  if (rmsg == 0 ||
910  {
911  return;
912  }
913  break;
914  }
915 
916  default:
918  Log.error() << (String)tr("Current step") << ": " << current_step_ << std::endl;
919  return;
920  }
921 
922  enableNextStep_();
923 }
924 
926 {
927  CompositeMessage* cmsg = RTTI::castTo<CompositeMessage>(*message);
928  RepresentationMessage* rmsg = RTTI::castTo<RepresentationMessage>(*message);
929 
930  if (rmsg != 0 && rmsg->getRepresentation() == 0) return;
931 
932  switch (current_step_)
933  {
934  case 1:
935  {
936  // nothing to be checked
937  break;
938  }
939  case 2: // "Building a peptide from a given sequence"
940  {
941  if (cmsg == 0 || cmsg->getType() != CompositeMessage::NEW_MOLECULE) return;
942  break;
943  }
944  case 3: // "Set the background color"
945  {
946  if (Scene::getInstance(0)->getStage()->getBackgroundColor() != ColorRGBA(0, 0, 0, 255)) return;
947  break;
948  }
949  case 4: // "Rotating"
950  {
951  if (!RTTI::isKindOf<SceneMessage>(*message)) return;
952  break;
953  }
954  case 5: // "Setting light sources"
955  {
956  //if (Scene::getInstance(0)->getStage()->getLightSource(0).getColor() != ColorRGBA(255, 245, 208, 255)) return;
957  if (Scene::getInstance(0)->getStage()->getLightSources().size() != 2) return;
958  break;
959  }
960  case 6: // "Setting the materials"
961  {
962  // check, if we got an SES
963  if (rmsg == 0 ||
966  {
967  return;
968  }
969  break;
970  }
971  case 7: // "downsampling/PNGs"
972  {
973  //TODO find a checker!!
974  if (cmsg != 0)
975  cout << "*7*" << cmsg->getType() << endl;
976  break;
977  }
978 
979  /* Put into a later step
980  if (tutorial_type_ == RAYTRACING_TUTORIAL)
981  {
982  // set the camera non-optimal
983  Camera& camera = Scene::getInstance(0)->getStage()->getCamera();
984  Vector3 absolute_offset = camera.getRightVector() * 100
985  + camera.getLookUpVector() * 100
986  + camera.getViewVector() * 100;
987 
988  camera.setViewPoint(camera.getViewPoint()+absolute_offset);
989  camera.setLookAtPosition(camera.getLookAtPosition()+absolute_offset);
990  Scene::getInstance(0)->rotateClockwise(90);
991  Scene::getInstance(0)->update();
992  Scene::getInstance(0)->updateGL();
993  }
994  */
995 
996  default:
998  Log.error() << "Current step: " << current_step_ << std::endl;
999  return;
1000  }
1001 
1002  enableNextStep_();
1003 }
1004 
1006 {
1008 
1009  String description = "Shortcut|Help|Demo";
1010  demo_action_ = insertMenuEntry(MainControl::HELP, tr("Demo"), this, SLOT(showDemo()),
1011  description, QKeySequence(),
1012  tr("Show a demonstration of BALLView's features"), UIOperationMode::MODE_ADVANCED);
1013 
1014  description = "Shortcut|Help|Tutorial";
1015  tutorial_action_ = insertMenuEntry(MainControl::HELP, tr("Tutorial"), this, SLOT(showTutorial()),
1016  description, QKeySequence(), tr("Perform a step-by-step tutorial"),
1018 
1019 #ifdef BALL_HAS_RTFACT
1020  description = "Shortcut|Help|RaytracingTutorial";
1021  raytracing_tutorial_action_ = insertMenuEntry(MainControl::HELP, tr("Ray tracing Tutorial"), this,
1022  SLOT(showRaytracingTutorial()), description, QKeySequence(),
1023  tr("Learn how to use RTFact"), UIOperationMode::MODE_ADVANCED);
1024 #endif
1025 
1027 
1028 }
1029 
1031 {
1032  bool busy = main_control.isBusy();
1033  if (demo_action_)
1034  demo_action_->setEnabled(!busy);
1035  if (tutorial_action_)
1036  tutorial_action_->setEnabled(!busy);
1037  if (raytracing_tutorial_action_)
1038  raytracing_tutorial_action_->setEnabled(!busy);
1039 }
1040 
1041 } } // namespaces
Update all datas for a Composite (but not in the MolecularControl)
Definition: message.h:220
void setModelType(ModelType type)
RepresentationManager & getRepresentationManager()
Definition: mainControl.h:255
void setColor(const ColorRGBA &color)
defines the property for the model: Ball and Stick
const Vector3 & getViewPoint() const
Get the position of the camera.
Definition: camera.h:74
void enableCreationForNewMolecules(bool state)
Set if Representations are automaticaly created for new Molecules.
virtual void addLightSource(const LightSource &light_source)
Add a light source.
void addPlane_(char plane_specifier, int height, int boundary, bool bottom=true)
void setPosition(const Vector3 &position)
Set position.
Definition: stage.h:103
Base class for all messages concerning a Representation.
Definition: message.h:569
void insertPopupMenuSeparator(int ID, UIOperationMode::OperationMode mode=UIOperationMode::MODE_ALL)
#define BALLVIEW_DEBUG
BALLView Debug macro.
void setColor(const ColorRGBA &color)
Definition: stage.h:152
virtual void setBackgroundColor(const ColorRGBA &color)
Set the background color.
Definition: stage.h:364
const Vector3 & getUpper() const
String getType() const
Definition: dataset.h:108
virtual System * openMolecularFile(const String &file)
bool computeIsoContourSurface(Dataset &data, const ColorRGBA &color, float value)
void setMaxIterations(Size n)
Set the maximum number of iterations for the minimizer.
std::list< Composite * > & getMolecularControlSelection()
Get the selection (highlighted items) of the MolecularControl (not the selection with checkboxes) ...
void setAttenuation(const Vector3 &attenuation)
Set the attenuation parameters of the light.
Definition: stage.h:119
defines the property for the model: solvent-accessible surface
void setDrawingPrecision(int value)
RepresentationMessageType getType() const
Definition: message.h:625
void setMaxGradient(double max_gradient)
void chooseAmberFF()
Slot for a menu entry to select the AMBER force field.
Material & getMaterial()
Gives access to the default material parameters.
Definition: stage.h:481
Add a Representation to GeometricControl, but don't update in Scene.
Definition: message.h:598
QAction * insertMenuEntry(Position parent_id, const QString &name, const QObject *receiver=0, const char *slot=0, const String &description="", QKeySequence accel=QKeySequence(), const QString &menu_hint=QString(""), UIOperationMode::OperationMode minimal_mode=UIOperationMode::MODE_ALL)
static void registerWidget(ModularWidget *mwidget)
BALL_EXPORT LogStream Log
ColorRGBA reflective_color
Definition: stage.h:277
const Vector3 & getLower() const
vector< Normal > normal
the normals for each vertex
Definition: surface.h:188
LogStream & info(int n=0)
SceneMessageType getType() const
Get the type of the message.
Definition: message.h:403
Iterator begin()
Definition: hashSet.h:536
defines the property for the model: Cartoon
void setGrid(RegularData3D *grid)
static const char PATH_SEPARATOR
Definition: fileSystem.h:52
defines the property for the model: solvent-excluded surface
const RepresentationList & getRepresentations() const
Get the list with the Representations.
const char * c_str() const BALL_NOEXCEPT
Rebuild the GLDisplayList objects in the GLRenderer.
Definition: message.h:343
defines the property for the model: Stick
virtual ~DemoTutorialDialog()
Destructor.
virtual void onNotifyRaytracingTutorial_(Message *message)
String find(const String &name)
void insert(GeometricObject &object)
TVector3< float > Vector3
Definition: vector3.h:1084
void runMinimization(bool show_dialog_=true)
Run a energy minization with the currently selected force field.
virtual void initializeWidget(MainControl &main_control)
void clearLightSources()
defines the property for the model: H-Bonds
Representation * getRepresentation()
Definition: message.h:618
void setMultithreading(bool state)
See above.
Definition: mainControl.h:623
void setName(const String &name)
MolecularDynamicsDialog & getMDSimulationDialog()
vector< Dataset * > getDatasets()
Get all Datasets of this type in the DatasetControl.
LogStream & error(int n=0)
void setIntensity(float intensity)
Definition: stage.h:140
MainControl * getMainControl() const
vector< Vertex > vertex
the vertices
Definition: surface.h:185
bool apply(UnaryProcessor< T > &processor)
void updateFromStage()
Get the values for Stageing from the stage.
bool calculateFDPB(bool show=true)
void calculateHBonds()
Calculate the H-Bonds for a Protein.
virtual void onNotifyTutorial_(Message *message)
FragmentDB & getFragmentDB() const
Dataset * getDataset() const
Definition: message.h:180
virtual void checkMenu(MainControl &main_control)
vector< Triangle > triangle
the triangles
Definition: surface.h:191
void setViewPoint(const Vector3 &view_point)
Set the position of the camera.
Definition: camera.h:78
MinimizationDialog & getMinimizationDialog()
bool insert(Representation &rep)
defines the property for the model: contour surface
bool remove(Representation &rep)
const vector< ValueType > & getData() const
Get the full data.
ColorRGBA specular_color
Definition: stage.h:274
void MDSimulation(bool show_dialog_=true)
Perfomr a molecular dynamics simulation with the currently selected force field.
void setRefresh(Size n)
Set the number of steps between the Scene refreshs.
Representation * createRepresentation()
Create a Representation and insert it.
AmberConfigurationDialog & getAmberConfigurationDialog()
Get an instance of an dialog to setup the AMBER forcefield.
void setRepresentation(Representation *rep)
defines the property for the model: Van der Waals
virtual void onNotify(Message *message)
Message handling method.
Size getNumberOfRepresentations() const
Get the number of the Representations.
Update the Representation.
Definition: message.h:586
ModelType getModelType() const
Type getType() const
Definition: message.h:174
void show()
Show and raise the dialog.
void setType(Types type)
Definition: stage.h:164
virtual void showHelp(const String &URL)
virtual void onNotifyDemo_(Message *message)
bool update(Representation &rep)
void notify_(Message *message)
CompositeMessageType getType() const
Definition: message.h:287