26#include <QtWidgets/QPushButton>
27#include <QtWidgets/QMessageBox>
28#include <QtWidgets/QTextBrowser>
53 Ui_DemoTutorialDialogData(),
62 demo_action_(nullptr),
63 tutorial_action_(nullptr),
64 raytracing_tutorial_action_(nullptr)
67 Log.
error() <<
"new DemoTutorialDialog " <<
this << std::endl;
77 connect(cancel_button, SIGNAL(clicked()),
this, SLOT(hide()));
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)
280 else if (current_step_ == 15)
291 RegularData3DDataset* set =
dynamic_cast<RegularData3DDataset*
>(msg->
getDataset());
296 else if (current_step_ == 16)
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_)
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;
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);
BALL_EXPORT LogStream Log
TVector3< float > Vector3
bool isKindOf(const U *u)
@ COLORING_SECONDARY_STRUCTURE
@ COLORING_TEMPERATURE_FACTOR
@ 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
String getFilename() const
LogStream & error(int n=0)
LogStream & info(int n=0)
bool apply(UnaryProcessor< T > &processor)
const vector< ValueType > & getData() const
Get the full data.
const char * c_str() const BALL_NOEXCEPT
vector< Normal > normal
the normals for each vertex
vector< Triangle > triangle
the triangles
vector< Vertex > vertex
the vertices
const Vector3 & getLower() const
const Vector3 & getUpper() const
static const char PATH_SEPARATOR
String find(const String &name)
vector< Dataset * > getDatasets()
Get all Datasets of this type in the DatasetControl.
bool computeIsoContourSurface(Dataset &data, const ColorRGBA &color, float value)
virtual void resetOptions()
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 setMaxValue(float value)
void setMinValue(float value)
void setRepresentation(Representation *rep)
void setGrid(RegularData3D *grid)
void setMode(Position pos)
void setNumberOfSteps(Size steps)
void setTimeStep(float time)
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()
void setMultithreading(bool state)
See above.
Dataset * getDataset() const
CompositeMessageType getType() const
@ CHANGED_COMPOSITE
Update all datas for a Composite (but not in the MolecularControl)
@ REBUILD_DISPLAY_LISTS
Rebuild the GLDisplayList objects in the GLRenderer.
SceneMessageType getType() const
Get the type of the message.
Base class for all messages concerning a Representation.
@ ADD_TO_GEOMETRIC_CONTROL
Add a Representation to GeometricControl, but don't update in Scene.
@ UPDATE
Update the Representation.
Representation * getRepresentation()
RepresentationMessageType getType() const
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)
void setIntensity(float intensity)
void setPosition(const Vector3 &position)
Set position.
void setAttenuation(const Vector3 &attenuation)
Set the attenuation parameters of the light.
Material & getMaterial()
Gives access to the default material parameters.
virtual void setBackgroundColor(const ColorRGBA &color)
Set the background color.
virtual void addLightSource(const LightSource &light_source)
Add a light source.
ColorRGBA reflective_color
float reflective_intensity
const Vector3 & getViewPoint() const
Get the position of the camera.
void setViewPoint(const Vector3 &view_point)
Set the position of the camera.
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)
void nextStepClicked()
Next Step.
virtual void initializeWidget(MainControl &main_control)
void show()
Show and raise the dialog.
virtual void onNotifyDemo_(Message *message)
void showRaytracingTutorial()
virtual void onNotifyRaytracingTutorial_(Message *message)
virtual ~DemoTutorialDialog()
Destructor.
#define BALLVIEW_DEBUG
BALLView Debug macro.