33 #include <QtGui/QPushButton>
34 #include <QtGui/QMessageBox>
35 #include <QtGui/QTextBrowser>
58 DemoTutorialDialog::DemoTutorialDialog(
QWidget* parent,
const char* name)
60 Ui_DemoTutorialDialogData(),
65 raytracing_tutorial_action_(0)
67 #ifdef BALL_VIEW_DEBUG
68 Log.
error() <<
"new DemoTutorialDialog " <<
this << std::endl;
78 connect(cancel_button, SIGNAL(clicked()),
this, SLOT(hide()));
83 #ifdef BALL_VIEW_DEBUG
84 Log.
error() <<
"deleting DemoTutorialDialog " <<
this << std::endl;
92 setWindowTitle(tr(
"BALLView Demo"));
96 next_button->setEnabled(
true);
102 if (LogView::getInstance(0) != 0) LogView::getInstance(0)->hide();
103 if (DatasetControl::getInstance(0) != 0) DatasetControl::getInstance(0)->hide();
104 #ifdef BALL_PYTHON_SUPPORT
105 if (PyWidget::getInstance(0) != 0) PyWidget::getInstance(0)->hide();
108 #ifdef BALL_HAS_RTFACT
111 Stage* stage = Scene::getInstance(0)->getStage();
114 StageSettings* stage_settings = Scene::getInstance(0)->getStageSettings();
130 LightSettings::getInstance(0)->updateFromStage();
132 Scene::getInstance(0)->applyPreferences();
151 if (tutorial_type_ == TUTORIAL)
153 setWindowTitle(tr(
"BALLView Tutorial"));
156 else if (tutorial_type_ == RAYTRACING_TUTORIAL)
158 setWindowTitle(tr(
"Ray tracing Tutorial"));
162 next_button->setEnabled(
false);
164 #ifdef BALL_HAS_RTFACT
168 Scene::getInstance(0)->show();
169 MolecularControl::getInstance(0)->show();
170 MolecularControl::getInstance(0)->setFloating(
false);
171 MolecularControl::getInstance(0)->applyPreferences();
172 GeometricControl::getInstance(0)->show();
173 GeometricControl::getInstance(0)->applyPreferences();
174 GeometricControl::getInstance(0)->setFloating(
false);
178 Stage* stage = Scene::getInstance(0)->getStage();
182 StageSettings* stage_settings = Scene::getInstance(0)->getStageSettings();
197 LightSettings::getInstance(0)->updateFromStage();
199 if (tutorial_type_ == TUTORIAL)
201 DatasetControl::getInstance(0)->show();
202 DatasetControl::getInstance(0)->applyPreferences();
203 DatasetControl::getInstance(0)->setFloating(
false);
205 else if (tutorial_type_ == RAYTRACING_TUTORIAL)
207 #ifdef BALL_HAS_RTFACT
222 Scene::getInstance(0)->getMaterialSettings()->updateDefaultMaterialsFromStage();
228 Scene::getInstance(0)->applyPreferences();
230 next_button->setEnabled(
true);
232 Log.
info() <<
"DemoTutorialDialog: no RTFact available! Close the dialog!" << __FILE__ <<
" " << __LINE__ << endl;
236 LogView::getInstance(0)->hide();
243 if (tutorial_type_ == DEMO)
249 int result = QMessageBox::question(
this, tr(
"Warning"),
250 tr(
"To start the tutorial, all loaded structures and molecules will be deleted."),
251 QMessageBox::Ok| QMessageBox::Cancel, QMessageBox::Ok);
252 if (result != QMessageBox::Ok)
return;
257 QUrl qurl = QUrl::fromLocalFile((prefix_ +
"01.html").c_str());
258 text_browser->setSource(qurl);
267 if (!isVisible())
return;
269 switch (tutorial_type_)
277 case RAYTRACING_TUTORIAL:
287 if (current_step_ == 13 ||
290 if (!RTTI::isKindOf<FinishedSimulationMessage>(*message))
return;
292 else if (current_step_ == 15)
295 if (msg == 0)
return;
303 RegularData3DDataset* set =
dynamic_cast<RegularData3DDataset*
>(msg->
getDataset());
308 else if (current_step_ == 16)
310 SceneMessage* msg = RTTI::castTo<SceneMessage>(*message);
316 else if (rmsg == 0 ||
328 next_button->setEnabled(
true);
335 if (
id.size() == 1)
id =
"0" + id;
337 id = prefix_ +
id +
".html";
339 QUrl qurl = QUrl::fromLocalFile(
id.c_str());
340 text_browser->setSource(qurl);
341 next_button->setEnabled(
false);
343 if (tutorial_type_ == DEMO)
345 if (current_step_ == 17)
353 #ifdef BALL_HAS_RTFACT
355 if (current_step_ == 11)
358 next_button->setEnabled(
true);
363 else if (tutorial_type_ == TUTORIAL)
365 if (current_step_ == 8)
367 next_button->setEnabled(
true);
369 if (current_step_ == 10)
375 hv->setFloating(
true);
379 else if (tutorial_type_ == RAYTRACING_TUTORIAL)
381 switch (current_step_)
387 Scene::getInstance(0)->getStage()->setBackgroundColor(color);
388 StageSettings* stage_settings = Scene::getInstance(0)->getStageSettings();
390 Scene::getInstance(0)->applyPreferences();
398 LightSource& ls = Scene::getInstance(0)->getStage()->getLightSource(0);
404 LightSettings::getInstance(0)->updateFromStage();
407 Camera& camera = Scene::getInstance(0)->getStage()->getCamera();
411 Scene::getInstance(0)->applyPreferences();
417 if (
getMainControl()->getCompositeManager().getComposites().size() == 0)
419 Log.
info() <<
"DemoTutorialDialog: no system available! " << __FILE__ <<
" " << __LINE__ << endl;
433 hv->setFloating(
true);
448 HashSet<Composite*> composites = MainControl::getInstance(0)->getCompositeManager().getComposites();
456 system =
dynamic_cast<System*
>(*sit);
465 Log.
info() <<
"DemoTutorialDialog.addPlane(): No system given! "<< __FILE__ <<
" " << __LINE__ << endl;
472 system =
dynamic_cast<System*
>(*sit);
480 if (v_low.
x > low.
x) v_low.
x = low.
x;
481 if (v_low.
y > low.
y) v_low.
y = low.
y;
482 if (v_low.
z > low.
z) v_low.
z = low.
z;
484 if (v_upp.
x < upp.x) v_upp.
x = upp.x;
485 if (v_upp.
y < upp.y) v_upp.
y = upp.y;
486 if (v_upp.
z < upp.z) v_upp.
z = upp.z;
496 height = height*(-1);
497 boundary = boundary*(-1);
500 Vector3 v_low_left (0., 0., 0.);
501 Vector3 v_low_right(0., 0., 0.);
502 Vector3 v_upp_right(0., 0., 0.);
503 Vector3 v_upp_left (0., 0., 0.);
508 if (plane_specifier ==
'x')
510 v_low = v_low -
Vector3(height, boundary, boundary);
511 v_upp = v_upp +
Vector3(height, boundary, boundary);
512 v_low_left =
Vector3(v_low.
x, v_low.
y, v_low.
z);
513 v_low_right =
Vector3(v_low.
x, v_upp.
y, v_low.
z);
514 v_upp_right =
Vector3(v_low.
x, v_upp.
y, v_upp.
z);
515 v_upp_left =
Vector3(v_low.
x, v_low.
y, v_upp.
z);
518 else if (plane_specifier ==
'y')
520 v_low = v_low -
Vector3(boundary, height, boundary);
521 v_upp = v_upp +
Vector3(boundary, height, boundary);
522 v_low_left =
Vector3(v_low.
x, v_low.
y, v_low.
z);
523 v_low_right =
Vector3(v_low.
x, v_low.
y, v_upp.
z);
524 v_upp_right =
Vector3(v_upp.
x, v_low.
y, v_upp.
z);
525 v_upp_left =
Vector3(v_upp.
x, v_low.
y, v_low.
z);
528 else if (plane_specifier ==
'z')
530 v_low = v_low -
Vector3(boundary, boundary, height);
531 v_upp = v_upp +
Vector3(boundary, boundary, height);
532 v_low_left =
Vector3(v_low.
x, v_low.
y, v_low.
z);
533 v_low_right =
Vector3(v_low.
x, v_upp.
y, v_low.
z);
534 v_upp_right =
Vector3(v_upp.
x, v_upp.
y, v_low.
z);
535 v_upp_left =
Vector3(v_upp.
x, v_low.
y, v_low.
z);
540 Log.
info() <<
"DemoTutorialDialog.addPlane(): unknown plane_specifier! "<< __FILE__ <<
" " << __LINE__ << endl;
548 plane->
vertex.push_back(v_low_left);
549 plane->
vertex.push_back(v_low_right);
550 plane->
vertex.push_back(v_upp_right);
551 plane->
vertex.push_back(v_upp_left);
570 for (
int i=0; i<4; i++)
571 plane->
normal.push_back(normal);
595 if (current_step_ == 1)
606 String file_name = path.
find(
"structures/bpti.pdb");
609 if (dialog == 0)
return;
617 String msg((
String)tr(
"Could not open bpti.pdb. Maybe the file was deleted?")+
"\n");
618 msg += (
String)tr(
"It should be found in") +
" " + file_name;
620 QMessageBox::critical(0, tr(
"Error while starting BALLView Demo"), msg.
c_str(),
621 QMessageBox::Ok, Qt::NoButton, Qt::NoButton);
636 composites_.push_back(system_);
639 if (current_step_ == 17)
646 next_button->setEnabled(current_step_ >= 14);
653 if (surface_ == 0 && nr == 1 && current_step_ == 6)
656 Mesh* mesh =
dynamic_cast<Mesh*
>(go);
659 surface_ =
new Mesh(*mesh);
665 surface_ =
new Mesh();
675 if (current_step_ < 6)
684 else if (current_step_ < 8)
693 else if (current_step_ == 8)
699 #ifndef BALL_HAS_RTFACT
703 else if (current_step_ == 9)
707 else if (current_step_ == 10)
711 else if (current_step_ == 11)
715 else if (current_step_ == 12 ||
722 list<Composite*> composites;
723 composites.push_back(*
getMainControl()->getCompositeManager().getComposites().begin());
724 MolecularControl::getInstance(0)->highlight(composites);
726 if (current_step_ == 12)
732 #ifdef BALL_HAS_RTFACT
746 else if (current_step_ == 14)
755 else if (current_step_ == 15)
773 else if (current_step_ == 16)
784 if (grids.empty())
return;
794 tutorial_type_ = RAYTRACING_TUTORIAL;
801 tutorial_type_ = TUTORIAL;
807 tutorial_type_ = DEMO;
818 switch (current_step_)
828 if (!RTTI::isKindOf<SceneMessage>(*message))
return;
839 if (!RTTI::isKindOf<DatasetMessage>(*message))
return;
867 if (!RTTI::isKindOf<DatasetMessage>(*message))
return;
918 Log.
error() << (
String)tr(
"Current step") <<
": " << current_step_ << std::endl;
932 switch (current_step_)
946 if (Scene::getInstance(0)->getStage()->getBackgroundColor() !=
ColorRGBA(0, 0, 0, 255))
return;
951 if (!RTTI::isKindOf<SceneMessage>(*message))
return;
957 if (Scene::getInstance(0)->getStage()->getLightSources().size() != 2)
return;
975 cout <<
"*7*" << cmsg->
getType() << endl;
998 Log.
error() <<
"Current step: " << current_step_ << std::endl;
1009 String description =
"Shortcut|Help|Demo";
1011 description, QKeySequence(),
1014 description =
"Shortcut|Help|Tutorial";
1016 description, QKeySequence(), tr(
"Perform a step-by-step tutorial"),
1019 #ifdef BALL_HAS_RTFACT
1020 description =
"Shortcut|Help|RaytracingTutorial";
1032 bool busy = main_control.
isBusy();
1034 demo_action_->setEnabled(!busy);
1035 if (tutorial_action_)
1036 tutorial_action_->setEnabled(!busy);
1037 if (raytracing_tutorial_action_)
1038 raytracing_tutorial_action_->setEnabled(!busy);
Update all datas for a Composite (but not in the MolecularControl)
void setModelType(ModelType type)
RepresentationManager & getRepresentationManager()
void setColor(const ColorRGBA &color)
void nextStepClicked()
Next Step.
void setMinValue(float value)
defines the property for the model: Ball and Stick
const Vector3 & getViewPoint() const
Get the position of the camera.
void enableCreationForNewMolecules(bool state)
Set if Representations are automaticaly created for new Molecules.
virtual void addLightSource(const LightSource &light_source)
Add a light source.
void addPlane_(char plane_specifier, int height, int boundary, bool bottom=true)
void setPosition(const Vector3 &position)
Set position.
Base class for all messages concerning a Representation.
void setNumberOfSteps(Size steps)
void insertPopupMenuSeparator(int ID, UIOperationMode::OperationMode mode=UIOperationMode::MODE_ALL)
#define BALLVIEW_DEBUG
BALLView Debug macro.
void setColor(const ColorRGBA &color)
virtual void setBackgroundColor(const ColorRGBA &color)
Set the background color.
const Vector3 & getUpper() const
virtual System * openMolecularFile(const String &file)
bool computeIsoContourSurface(Dataset &data, const ColorRGBA &color, float value)
void setMaxIterations(Size n)
Set the maximum number of iterations for the minimizer.
std::list< Composite * > & getMolecularControlSelection()
Get the selection (highlighted items) of the MolecularControl (not the selection with checkboxes) ...
void setAttenuation(const Vector3 &attenuation)
Set the attenuation parameters of the light.
defines the property for the model: solvent-accessible surface
void setDrawingPrecision(int value)
RepresentationMessageType getType() const
void setMaxGradient(double max_gradient)
void chooseAmberFF()
Slot for a menu entry to select the AMBER force field.
Material & getMaterial()
Gives access to the default material parameters.
Add a Representation to GeometricControl, but don't update in Scene.
BALL_EXPORT LogStream Log
ColorRGBA reflective_color
const Vector3 & getLower() const
vector< Normal > normal
the normals for each vertex
LogStream & info(int n=0)
float reflective_intensity
SceneMessageType getType() const
Get the type of the message.
defines the property for the model: Cartoon
void setGrid(RegularData3D *grid)
static const char PATH_SEPARATOR
defines the property for the model: solvent-excluded surface
const RepresentationList & getRepresentations() const
Get the list with the Representations.
const char * c_str() const BALL_NOEXCEPT
Rebuild the GLDisplayList objects in the GLRenderer.
defines the property for the model: Stick
virtual ~DemoTutorialDialog()
Destructor.
virtual void onNotifyRaytracingTutorial_(Message *message)
String find(const String &name)
void insert(GeometricObject &object)
TVector3< float > Vector3
void runMinimization(bool show_dialog_=true)
Run a energy minization with the currently selected force field.
virtual void initializeWidget(MainControl &main_control)
defines the property for the model: H-Bonds
Representation * getRepresentation()
void setTimeStep(float time)
void setMultithreading(bool state)
See above.
void setName(const String &name)
MolecularDynamicsDialog & getMDSimulationDialog()
vector< Dataset * > getDatasets()
Get all Datasets of this type in the DatasetControl.
LogStream & error(int n=0)
void setIntensity(float intensity)
vector< Vertex > vertex
the vertices
bool apply(UnaryProcessor< T > &processor)
void updateFromStage()
Get the values for Stageing from the stage.
bool calculateFDPB(bool show=true)
void calculateHBonds()
Calculate the H-Bonds for a Protein.
virtual void onNotifyTutorial_(Message *message)
Dataset * getDataset() const
virtual void checkMenu(MainControl &main_control)
vector< Triangle > triangle
the triangles
void setViewPoint(const Vector3 &view_point)
Set the position of the camera.
MinimizationDialog & getMinimizationDialog()
bool insert(Representation &rep)
defines the property for the model: contour surface
virtual void resetOptions()
bool remove(Representation &rep)
const vector< ValueType > & getData() const
Get the full data.
void MDSimulation(bool show_dialog_=true)
Perfomr a molecular dynamics simulation with the currently selected force field.
void setRefresh(Size n)
Set the number of steps between the Scene refreshs.
Representation * createRepresentation()
Create a Representation and insert it.
AmberConfigurationDialog & getAmberConfigurationDialog()
Get an instance of an dialog to setup the AMBER forcefield.
void setRepresentation(Representation *rep)
defines the property for the model: Van der Waals
virtual void onNotify(Message *message)
Message handling method.
Size getNumberOfRepresentations() const
Get the number of the Representations.
void setMaxValue(float value)
void setMode(Position pos)
Update the Representation.
ModelType getModelType() const
void show()
Show and raise the dialog.
virtual void showHelp(const String &URL)
virtual void onNotifyDemo_(Message *message)
bool update(Representation &rep)
void notify_(Message *message)
CompositeMessageType getType() const
String getFilename() const
void showRaytracingTutorial()