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