26 #include <QtWidgets/QPushButton> 27 #include <QtWidgets/QMessageBox> 28 #include <QtWidgets/QTextBrowser> 51 DemoTutorialDialog::DemoTutorialDialog(
QWidget* parent,
const char* name)
53 Ui_DemoTutorialDialogData(),
62 demo_action_(nullptr),
63 tutorial_action_(nullptr),
64 raytracing_tutorial_action_(nullptr)
66 #ifdef BALL_VIEW_DEBUG 67 Log.
error() <<
"new DemoTutorialDialog " <<
this << std::endl;
77 connect(cancel_button, SIGNAL(clicked()),
this, SLOT(hide()));
82 #ifdef BALL_VIEW_DEBUG 83 Log.
error() <<
"deleting DemoTutorialDialog " <<
this << std::endl;
91 setWindowTitle(tr(
"BALLView Demo"));
95 next_button->setEnabled(
true);
101 if (LogView::getInstance(0) != 0) LogView::getInstance(0)->hide();
102 if (DatasetControl::getInstance(0) != 0) DatasetControl::getInstance(0)->hide();
104 #ifdef BALL_HAS_RTFACT 107 Stage* stage = Scene::getInstance(0)->getStage();
110 StageSettings* stage_settings = Scene::getInstance(0)->getStageSettings();
126 LightSettings::getInstance(0)->updateFromStage();
128 Scene::getInstance(0)->applyPreferences();
140 if (tutorial_type_ == TUTORIAL)
142 setWindowTitle(tr(
"BALLView Tutorial"));
145 else if (tutorial_type_ == RAYTRACING_TUTORIAL)
147 setWindowTitle(tr(
"Ray tracing Tutorial"));
151 next_button->setEnabled(
false);
153 #ifdef BALL_HAS_RTFACT 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);
167 Stage* stage = Scene::getInstance(0)->getStage();
171 StageSettings* stage_settings = Scene::getInstance(0)->getStageSettings();
186 LightSettings::getInstance(0)->updateFromStage();
188 if (tutorial_type_ == TUTORIAL)
190 DatasetControl::getInstance(0)->show();
191 DatasetControl::getInstance(0)->applyPreferences();
192 DatasetControl::getInstance(0)->setFloating(
false);
194 else if (tutorial_type_ == RAYTRACING_TUTORIAL)
196 #ifdef BALL_HAS_RTFACT 211 Scene::getInstance(0)->getMaterialSettings()->updateDefaultMaterialsFromStage();
217 Scene::getInstance(0)->applyPreferences();
219 next_button->setEnabled(
true);
221 Log.
info() <<
"DemoTutorialDialog: no RTFact available! Close the dialog!" << __FILE__ <<
" " << __LINE__ << endl;
225 LogView::getInstance(0)->hide();
232 if (tutorial_type_ == DEMO)
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;
246 QUrl qurl = QUrl::fromLocalFile((prefix_ +
"01.html").c_str());
247 text_browser->setSource(qurl);
256 if (!isVisible())
return;
258 switch (tutorial_type_)
266 case RAYTRACING_TUTORIAL:
276 if (current_step_ == 13 || current_step_ == 14)
278 if (!RTTI::isKindOf<FinishedSimulationMessage>(message))
return;
280 else if (current_step_ == 15)
291 RegularData3DDataset*
set =
dynamic_cast<RegularData3DDataset*
>(msg->
getDataset());
296 else if (current_step_ == 16)
298 SceneMessage* msg = RTTI::castTo<SceneMessage>(*message);
315 next_button->setEnabled(
true);
322 if (
id.size() == 1)
id =
"0" + id;
324 id = prefix_ +
id +
".html";
326 QUrl qurl = QUrl::fromLocalFile(
id.c_str());
327 text_browser->setSource(qurl);
328 next_button->setEnabled(
false);
330 if (tutorial_type_ == DEMO)
332 if (current_step_ == 17)
340 #ifdef BALL_HAS_RTFACT 342 if (current_step_ == 11)
345 next_button->setEnabled(
true);
350 else if (tutorial_type_ == TUTORIAL)
352 if (current_step_ == 8)
354 next_button->setEnabled(
true);
357 else if (tutorial_type_ == RAYTRACING_TUTORIAL)
359 switch (current_step_)
365 Scene::getInstance(0)->getStage()->setBackgroundColor(color);
366 StageSettings* stage_settings = Scene::getInstance(0)->getStageSettings();
368 Scene::getInstance(0)->applyPreferences();
376 LightSource& ls = Scene::getInstance(0)->getStage()->getLightSource(0);
382 LightSettings::getInstance(0)->updateFromStage();
385 Camera& camera = Scene::getInstance(0)->getStage()->getCamera();
389 Scene::getInstance(0)->applyPreferences();
395 if (
getMainControl()->getCompositeManager().getComposites().size() == 0)
397 Log.
info() <<
"DemoTutorialDialog: no system available! " << __FILE__ <<
" " << __LINE__ << endl;
415 HashSet<Composite*> composites = MainControl::getInstance(0)->getCompositeManager().getComposites();
431 Log.
info() <<
"DemoTutorialDialog.addPlane(): No system given! "<< __FILE__ <<
" " << __LINE__ << endl;
438 system =
dynamic_cast<System*
>(*sit);
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;
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;
462 height = height*(-1);
463 boundary = boundary*(-1);
474 if (plane_specifier ==
'x')
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);
484 else if (plane_specifier ==
'y')
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);
494 else if (plane_specifier ==
'z')
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);
506 Log.
info() <<
"DemoTutorialDialog.addPlane(): unknown plane_specifier! "<< __FILE__ <<
" " << __LINE__ << endl;
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);
536 for (
int i=0; i<4; i++)
537 plane->
normal.push_back(normal);
561 if (current_step_ == 1)
572 String file_name = path.
find(
"structures/bpti.pdb");
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;
586 QMessageBox::critical(0, tr(
"Error while starting BALLView Demo"), msg.
c_str(),
587 QMessageBox::Ok, Qt::NoButton, Qt::NoButton);
602 composites_.push_back(system_);
605 if (current_step_ == 17)
612 next_button->setEnabled(current_step_ >= 14);
619 if (!surface_ && nr == 1 && current_step_ == 6)
622 Mesh* mesh =
dynamic_cast<Mesh*
>(go);
625 surface_ =
new Mesh(*mesh);
631 surface_ =
new Mesh();
641 if (current_step_ < 6)
650 else if (current_step_ < 8)
659 else if (current_step_ == 8)
665 #ifndef BALL_HAS_RTFACT 669 else if (current_step_ == 9)
673 else if (current_step_ == 10)
677 else if (current_step_ == 11)
681 else if (current_step_ == 12 || current_step_ == 13)
687 list<Composite*> composites;
688 composites.push_back(*
getMainControl()->getCompositeManager().getComposites().begin());
689 MolecularControl::getInstance(0)->highlight(composites);
691 if (current_step_ == 12)
697 #ifdef BALL_HAS_RTFACT 711 else if (current_step_ == 14)
720 else if (current_step_ == 15)
738 else if (current_step_ == 16)
749 if (grids.empty())
return;
759 tutorial_type_ = RAYTRACING_TUTORIAL;
766 tutorial_type_ = TUTORIAL;
772 tutorial_type_ = DEMO;
783 switch (current_step_)
793 if (!RTTI::isKindOf<SceneMessage>(message))
return;
804 if (!RTTI::isKindOf<DatasetMessage>(message))
return;
831 if (!RTTI::isKindOf<DatasetMessage>(message))
return;
881 Log.
error() << (
String)tr(
"Current step") <<
": " << current_step_ << std::endl;
895 switch (current_step_)
909 if (Scene::getInstance(0)->getStage()->getBackgroundColor() !=
ColorRGBA(0, 0, 0, 255))
return;
914 if (!RTTI::isKindOf<SceneMessage>(message))
return;
920 if (Scene::getInstance(0)->getStage()->getLightSources().size() != 2)
return;
938 cout <<
"*7*" << cmsg->
getType() << endl;
943 Log.
error() <<
"Current step: " << current_step_ << std::endl;
954 String description =
"Shortcut|Help|Demo";
956 description, QKeySequence(),
957 tr(
"Show a demonstration of BALLView's features"),
960 description =
"Shortcut|Help|Tutorial";
962 description, QKeySequence(), tr(
"Perform a step-by-step tutorial"),
965 #ifdef BALL_HAS_RTFACT 966 description =
"Shortcut|Help|RaytracingTutorial";
978 bool busy = main_control.
isBusy();
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);
void setIntensity(float intensity)
String find(const String &name)
const char * c_str() const BALL_NOEXCEPT
void setMaxIterations(Size n)
Set the maximum number of iterations for the minimizer.
virtual void setBackgroundColor(const ColorRGBA &color)
Set the background color.
LogStream & info(int n=0)
virtual void addLightSource(const LightSource &light_source)
Add a light source.
vector< Normal > normal
the normals for each vertex
void setRepresentation(Representation *rep)
float reflective_intensity
Base class for all messages concerning a Representation.
void setName(const String &name)
void setNumberOfSteps(Size steps)
void show()
Show and raise the dialog.
void setPosition(const Vector3 &position)
Set position.
Size getNumberOfRepresentations() const
Get the number of the Representations.
void setColor(const ColorRGBA &color)
void calculateHBonds()
Calculate the H-Bonds for a Protein.
BALL_EXPORT LogStream Log
virtual void resetOptions()
void setMode(Position pos)
bool insert(Representation &rep)
defines the property for the model: Ball and Stick
defines the property for the model: H-Bonds
void nextStepClicked()
Next Step.
virtual void onNotifyRaytracingTutorial_(Message *message)
AmberConfigurationDialog & getAmberConfigurationDialog()
Get an instance of an dialog to setup the AMBER forcefield.
Rebuild the GLDisplayList objects in the GLRenderer.
Add a Representation to GeometricControl, but don't update in Scene.
void addPlane_(char plane_specifier, int height, int boundary, bool bottom=true)
void setTimeStep(float time)
LogStream & error(int n=0)
void chooseAmberFF()
Slot for a menu entry to select the AMBER force field.
Dataset * getDataset() const
MainControl * getMainControl() const
CompositeMessageType getType() const
bool update(Representation &rep)
#define BALLVIEW_DEBUG
BALLView Debug macro.
const Vector3 & getLower() const
void setMaxValue(float value)
String getFilename() const
RepresentationMessageType getType() const
std::list< Composite * > & getMolecularControlSelection()
Get the selection (highlighted items) of the MolecularControl (not the selection with checkboxes) ...
bool apply(UnaryProcessor< T > &processor)
Update the Representation.
Representation * getRepresentation()
defines the property for the model: solvent-accessible surface
defines the property for the model: Cartoon
void MDSimulation(bool show_dialog_=true)
Perfomr a molecular dynamics simulation with the currently selected force field.
MinimizationDialog & getMinimizationDialog()
vector< Triangle > triangle
the triangles
void setGrid(RegularData3D *grid)
virtual void onNotify(Message *message)
Message handling method.
MolecularDynamicsDialog & getMDSimulationDialog()
defines the property for the model: contour surface
void notify_(Message *message)
static void registerWidget(ModularWidget *mwidget)
void setRefresh(Size n)
Set the number of steps between the Scene refreshs.
void setViewPoint(const Vector3 &view_point)
Set the position of the camera.
virtual void onNotifyTutorial_(Message *message)
Update all datas for a Composite (but not in the MolecularControl)
Representation * createRepresentation()
Create a Representation and insert it.
const vector< ValueType > & getData() const
Get the full data.
virtual void checkMenu(MainControl &main_control)
void setMinValue(float value)
void enableCreationForNewMolecules(bool state)
Set if Representations are automaticaly created for new Molecules.
const RepresentationList & getRepresentations() const
Get the list with the Representations.
void setColor(const ColorRGBA &color)
virtual void initializeWidget(MainControl &main_control)
const Vector3 & getViewPoint() const
Get the position of the camera.
virtual void onNotifyDemo_(Message *message)
void setDrawingPrecision(int value)
bool computeIsoContourSurface(Dataset &data, const ColorRGBA &color, float value)
static const char PATH_SEPARATOR
void setMultithreading(bool state)
See above.
TVector3< float > Vector3
void setModelType(ModelType type)
const Vector3 & getUpper() const
RepresentationManager & getRepresentationManager()
bool calculateFDPB(bool show=true)
void setAttenuation(const Vector3 &attenuation)
Set the attenuation parameters of the light.
void insertPopupMenuSeparator(int ID, UIOperationMode::OperationMode mode=UIOperationMode::MODE_ALL)
virtual System * openMolecularFile(const String &file)
defines the property for the model: solvent-excluded surface
FragmentDB & getFragmentDB() const
vector< Dataset * > getDatasets()
Get all Datasets of this type in the DatasetControl.
ColorRGBA reflective_color
defines the property for the model: Stick
void setMaxGradient(double max_gradient)
void updateFromStage()
Get the values for Stageing from the stage.
void insert(GeometricObject &object)
Material & getMaterial()
Gives access to the default material parameters.
SceneMessageType getType() const
Get the type of the message.
vector< Vertex > vertex
the vertices
ModelType getModelType() const
defines the property for the model: Van der Waals
virtual ~DemoTutorialDialog()
Destructor.
void runMinimization(bool show_dialog_=true)
Run a energy minization with the currently selected force field.
bool remove(Representation &rep)
void showRaytracingTutorial()
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)