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
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
30using namespace std;
31
32namespace BALL
33{
34 namespace VIEW
35 {
36
38{
48};
49
50
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
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
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
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
413void 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 }
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 }
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 }
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 {
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 {
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
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
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
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
STL namespace.
Definition: constants.h:13
BALL_EXPORT LogStream Log
TVector3< float > Vector3
Definition: vector3.h:1084
@ MODEL_STICK
defines the property for the model: Stick
@ MODEL_BALL_AND_STICK
defines the property for the model: Ball and Stick
@ MODEL_SA_SURFACE
defines the property for the model: solvent-accessible surface
@ MODEL_CONTOUR_SURFACE
defines the property for the model: contour surface
@ MODEL_VDW
defines the property for the model: Van der Waals
@ MODEL_CARTOON
defines the property for the model: Cartoon
@ MODEL_SE_SURFACE
defines the property for the model: solvent-excluded surface
@ MODEL_HBONDS
defines the property for the model: H-Bonds
LogStream & error(int n=0)
LogStream & info(int n=0)
bool apply(UnaryProcessor< T > &processor)
Iterator begin()
Definition: hashSet.h:536
const vector< ValueType > & getData() const
Get the full data.
const char * c_str() const BALL_NOEXCEPT
vector< Normal > normal
the normals for each vertex
Definition: surface.h:188
vector< Triangle > triangle
the triangles
Definition: surface.h:191
vector< Vertex > vertex
the vertices
Definition: surface.h:185
const Vector3 & getLower() const
const Vector3 & getUpper() const
static const char PATH_SEPARATOR
Definition: fileSystem.h:52
String find(const String &name)
String getType() const
Definition: dataset.h:108
vector< Dataset * > getDatasets()
Get all Datasets of this type in the DatasetControl.
bool computeIsoContourSurface(Dataset &data, const ColorRGBA &color, float value)
void enableCreationForNewMolecules(bool state)
Set if Representations are automaticaly created for new Molecules.
void setDrawingPrecision(int value)
void setRefresh(Size n)
Set the number of steps between the Scene refreshs.
void setMaxGradient(double max_gradient)
void setMaxIterations(Size n)
Set the maximum number of iterations for the minimizer.
void setRepresentation(Representation *rep)
void setGrid(RegularData3D *grid)
virtual System * openMolecularFile(const String &file)
void updateFromStage()
Get the values for Stageing from the stage.
void notify_(Message *message)
void setColor(const ColorRGBA &color)
bool insert(Representation &rep)
bool update(Representation &rep)
std::list< Composite * > & getMolecularControlSelection()
Get the selection (highlighted items) of the MolecularControl (not the selection with checkboxes)
bool remove(Representation &rep)
void insertPopupMenuSeparator(int ID, UIOperationMode::OperationMode mode=UIOperationMode::MODE_ALL)
RepresentationManager & getRepresentationManager()
Definition: mainControl.h:256
void setMultithreading(bool state)
See above.
Definition: mainControl.h:624
Type getType() const
Definition: message.h:174
Dataset * getDataset() const
Definition: message.h:180
CompositeMessageType getType() const
Definition: message.h:287
@ CHANGED_COMPOSITE
Update all datas for a Composite (but not in the MolecularControl)
Definition: message.h:220
@ REBUILD_DISPLAY_LISTS
Rebuild the GLDisplayList objects in the GLRenderer.
Definition: message.h:343
SceneMessageType getType() const
Get the type of the message.
Definition: message.h:403
Base class for all messages concerning a Representation.
Definition: message.h:570
@ ADD_TO_GEOMETRIC_CONTROL
Add a Representation to GeometricControl, but don't update in Scene.
Definition: message.h:598
@ UPDATE
Update the Representation.
Definition: message.h:586
Representation * getRepresentation()
Definition: message.h:618
RepresentationMessageType getType() const
Definition: message.h:625
FragmentDB & getFragmentDB() const
static void registerWidget(ModularWidget *mwidget)
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)
MainControl * getMainControl() const
void setModelType(ModelType type)
ModelType getModelType() const
void setName(const String &name)
void insert(GeometricObject &object)
const RepresentationList & getRepresentations() const
Get the list with the Representations.
Representation * createRepresentation()
Create a Representation and insert it.
Size getNumberOfRepresentations() const
Get the number of the Representations.
void setColor(const ColorRGBA &color)
Definition: stage.h:152
void setType(Types type)
Definition: stage.h:164
void setIntensity(float intensity)
Definition: stage.h:140
void setPosition(const Vector3 &position)
Set position.
Definition: stage.h:103
void setAttenuation(const Vector3 &attenuation)
Set the attenuation parameters of the light.
Definition: stage.h:119
Material & getMaterial()
Gives access to the default material parameters.
Definition: stage.h:448
virtual void setBackgroundColor(const ColorRGBA &color)
Set the background color.
Definition: stage.h:364
virtual void addLightSource(const LightSource &light_source)
Add a light source.
void clearLightSources()
ColorRGBA reflective_color
Definition: stage.h:277
ColorRGBA specular_color
Definition: stage.h:274
const Vector3 & getViewPoint() const
Get the position of the camera.
Definition: camera.h:74
void setViewPoint(const Vector3 &view_point)
Set the position of the camera.
Definition: camera.h:78
void chooseAmberFF()
Slot for a menu entry to select the AMBER force field.
MolecularDynamicsDialog & getMDSimulationDialog()
void MDSimulation(bool show_dialog_=true)
Perfomr a molecular dynamics simulation with the currently selected force field.
MinimizationDialog & getMinimizationDialog()
void runMinimization(bool show_dialog_=true)
Run a energy minization with the currently selected force field.
AmberConfigurationDialog & getAmberConfigurationDialog()
Get an instance of an dialog to setup the AMBER forcefield.
bool calculateFDPB(bool show=true)
void calculateHBonds()
Calculate the H-Bonds for a Protein.
DemoTutorialDialog(QWidget *parent=NULL, const char *name=NULL)
Default Constructor.
virtual void checkMenu(MainControl &main_control)
virtual void onNotify(Message *message)
Message handling method.
virtual void onNotifyTutorial_(Message *message)
void addPlane_(char plane_specifier, int height, int boundary, bool bottom=true)
virtual void initializeWidget(MainControl &main_control)
void show()
Show and raise the dialog.
virtual void onNotifyDemo_(Message *message)
virtual void onNotifyRaytracingTutorial_(Message *message)
virtual ~DemoTutorialDialog()
Destructor.
#define BALLVIEW_DEBUG
BALLView Debug macro.