Skip to content

Commit 2665e73

Browse files
committed
- somehow integrated the viewer in the animationwidget
1 parent f1fb176 commit 2665e73

File tree

3 files changed

+35
-32
lines changed

3 files changed

+35
-32
lines changed

OMEdit/OMEditGUI/Animation/AnimationWindowContainer.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include "AnimationWindowContainer.h"
3636

3737

38+
const double HEIGHT_CONTROLWIDGETS = 40;
39+
3840
/*!
3941
\class AnimationWindowContainer
4042
\brief A MDI area for animation windows.
@@ -65,6 +67,9 @@ AnimationWindowContainer::AnimationWindowContainer(MainWindow *pParent)
6567
//the viewer widget
6668
osg::ref_ptr<osg::Node> rootNode = osgDB::readRefNodeFile("D:/Programming/OPENMODELICA_GIT/OpenModelica/build/bin/dumptruck.osg");
6769
_viewerWidget = setupViewWidget(rootNode);
70+
_viewerWidget->setParent(this);
71+
_viewerWidget->setWindowFlags(Qt::SubWindow);
72+
//_viewerWidget->setWindowState(Qt::WindowMaximized);
6873
//the control widgets
6974
_topWidget = AnimationWindowContainer::setupAnimationWidgets();
7075
}
@@ -82,27 +87,27 @@ QWidget* AnimationWindowContainer::setupViewWidget(osg::ref_ptr<osg::Node> rootN
8287
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits();
8388
traits->windowName = "";
8489
traits->windowDecoration = false;
85-
traits->x = 100;
86-
traits->y = 100;
87-
traits->width = 300;
88-
traits->height = 300;
90+
traits->x = 0;
91+
traits->y = 0;
92+
93+
traits->width = this->parentWidget()->width();
94+
traits->height = this->parentWidget()->height();
8995
traits->doubleBuffer = true;
9096
traits->alpha = ds->getMinimumNumAlphaBits();
9197
traits->stencil = ds->getMinimumNumStencilBits();
9298
traits->sampleBuffers = ds->getMultiSamples();
9399
traits->samples = ds->getNumMultiSamples();
94-
osg::ref_ptr<osgQt::GraphicsWindowQt> gw = new osgQt::GraphicsWindowQt(traits.get(),this);
100+
osg::ref_ptr<osgQt::GraphicsWindowQt> gw = new osgQt::GraphicsWindowQt(traits.get());
95101

96102
//add a scene to viewer
97103
addView(_sceneView);
98104

99105
//get the viewer widget
100106
osg::ref_ptr<osg::Camera> camera = _sceneView->getCamera();
101107
camera->setGraphicsContext(gw);
102-
const osg::GraphicsContext::Traits* traits2 = gw->getTraits();
103108
camera->setClearColor(osg::Vec4(0.2, 0.2, 0.6, 1.0));
104-
camera->setViewport(new osg::Viewport(0, 0, traits2->width, traits2->height));
105-
camera->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits2->width) / static_cast<double>(traits2->height), 1.0f, 10000.0f);
109+
camera->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));
110+
camera->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits->width) / static_cast<double>(traits->height), 1.0f, 10000.0f);
106111
_sceneView->setSceneData(rootNode);
107112
_sceneView->addEventHandler(new osgViewer::StatsHandler());
108113
_sceneView->setCameraManipulator(new osgGA::MultiTouchTrackballManipulator());
@@ -141,13 +146,13 @@ QWidget* AnimationWindowContainer::setupAnimationWidgets()
141146
rowLayOut->addWidget(_timeSlider);
142147
rowLayOut->addWidget(_RTFactorDisplay);
143148
rowLayOut->addWidget(_timeDisplay);
144-
QGroupBox* widgetRowBox = new QGroupBox(this);
149+
QGroupBox* widgetRowBox = new QGroupBox();
145150
widgetRowBox->setLayout(rowLayOut);
146-
widgetRowBox->setFixedHeight(40);
151+
widgetRowBox->setFixedHeight(HEIGHT_CONTROLWIDGETS);
147152

148153
_topWidget = new QWidget(this);
149-
QVBoxLayout* mainVLayout = new QVBoxLayout(this);
150-
//mainVLayout->addWidget(viewerWidget);
154+
QVBoxLayout* mainVLayout = new QVBoxLayout();
155+
//mainVLayout->addWidget(_viewerWidget);
151156
mainVLayout->addWidget(widgetRowBox);
152157
_topWidget->setLayout(mainVLayout);
153158

@@ -209,12 +214,16 @@ void AnimationWindowContainer::loadVisualization(){
209214
void AnimationWindowContainer::chooseAnimationFileSlotFunction(){
210215
std::cout<<"animationFileSlotFunction "<<std::endl;
211216
QFileDialog dialog(this);
212-
std::string file = dialog.getOpenFileName(this,tr("Open Visualiation File"), "./", tr("Visualization FMU(*.fmu);; Visualization MAT(*.mat)")).toStdString();;
217+
std::string file = dialog.getOpenFileName(this,tr("Open Visualiation File"), "./", tr("Visualization MAT(*.mat)")).toStdString();
218+
if (file.compare("")){
213219
std::size_t pos = file.find_last_of("/\\");
214220
_pathName = file.substr(0, pos + 1);
215221
_fileName = file.substr(pos + 1, file.length());
216222
std::cout<<"file "<<_fileName<<" path "<<_pathName<<std::endl;
217223
loadVisualization();
224+
}
225+
else
226+
std::cout<<"No Visualization selected!"<<std::endl;
218227

219228
}
220229

@@ -251,6 +260,8 @@ void AnimationWindowContainer::pauseSlotFunction(){
251260
*/
252261
void AnimationWindowContainer::initSlotFunction(){
253262
std::cout<<"initSlotFunction "<<std::endl;
263+
_visualizer->initVisualization();
264+
254265
}
255266

256267
/*!

OMEdit/OMEditGUI/Animation/Visualizer.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void OMVisualBase::initVisObjects()
9999
}
100100
else
101101
{
102-
std::cout<<"shape._id "<<shape._id;
102+
//std::cout<<"shape._id "<<shape._id;
103103

104104
shape._type = std::string(expNode->value());
105105

@@ -391,12 +391,10 @@ void VisualizerMAT::updateVisAttributes(const double time)
391391

392392
for (auto& shape : _baseData->_shapes)
393393
{
394-
std::cout<<"shape "<<shape._id <<std::endl;
394+
//std::cout<<"shape "<<shape._id <<std::endl;
395395

396396
// Get the values for the scene graph objects
397397
updateObjectAttributeMAT(&shape._length, time, tmpReaderPtr);
398-
std::cout<<"shape "<<shape._id <<" done"<<std::endl;
399-
400398
updateObjectAttributeMAT(&shape._width, time, tmpReaderPtr);
401399
updateObjectAttributeMAT(&shape._height, time, tmpReaderPtr);
402400

@@ -431,7 +429,6 @@ void VisualizerMAT::updateVisAttributes(const double time)
431429
updateObjectAttributeMAT(&shape._color[2], time, tmpReaderPtr);
432430

433431
updateObjectAttributeMAT(&shape._specCoeff, time, tmpReaderPtr);
434-
std::cout<<"shape "<<shape._id <<" done2"<<std::endl;
435432

436433
rT = rotateModelica2OSG(osg::Vec3f(shape._r[0].exp, shape._r[1].exp, shape._r[2].exp),
437434
osg::Vec3f(shape._rShape[0].exp, shape._rShape[1].exp, shape._rShape[2].exp),
@@ -441,26 +438,15 @@ void VisualizerMAT::updateVisAttributes(const double time)
441438
osg::Vec3f(shape._lDir[0].exp, shape._lDir[1].exp, shape._lDir[2].exp),
442439
osg::Vec3f(shape._wDir[0].exp, shape._wDir[1].exp, shape._wDir[2].exp),
443440
shape._length.exp, shape._width.exp, shape._height.exp, shape._type);
444-
std::cout<<"shape "<<shape._id <<" done3"<<std::endl;
445441

446442
assemblePokeMatrix(shape._mat, rT._T, rT._r);
447-
std::cout<<"shape "<<shape._id <<" done4"<<std::endl;
448-
449443
// Update the shapes.
450444
_nodeUpdater->_shape = shape;
451445
//shape.dumpVisAttributes();
452-
std::cout<<"shape "<<shape._id <<" done5"<<std::endl;
453-
454446
// Get the scene graph nodes and stuff.
455447
child = _viewerStuff->getScene().getRootNode()->getChild(shapeIdx); // the transformation
456-
std::cout<<"shape "<<shape._id <<" done6"<<std::endl;
457-
458448
child->accept(*_nodeUpdater);
459-
std::cout<<"shape "<<shape._id <<" done7"<<std::endl;
460-
461449
++shapeIdx;
462-
std::cout<<"shape "<<shape._id <<" done8"<<std::endl;
463-
464450
}
465451
}
466452
catch (std::exception& ex)
@@ -497,7 +483,7 @@ double VisualizerMAT::omcGetVarValue(ModelicaMatReader* reader, const char* varN
497483
ModelicaMatVariable_t* var = nullptr;
498484
var = omc_matlab4_find_var(reader, varName);
499485
if (var == nullptr)
500-
std::cout<<"Did not get variable from result file. Variable name is "<<std::endl;
486+
std::cout<<"Did not get variable from result file. Variable name is "<<std::string(varName)<<std::endl;
501487
else
502488
omc_matlab4_val(&val, reader, var, time);
503489

OMEdit/OMEditGUI/MainWindow.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ MainWindow::MainWindow(QSplashScreen *pSplashScreen, bool debug, QWidget *parent
157157
connect(pAlgorithmicDebuggingShortcut, SIGNAL(activated()), SLOT(switchToAlgorithmicDebuggingPerspectiveSlot()));
158158
mpPerspectiveTabbar->setTabToolTip(3, tr("Changes to debugging perspective (%1)").arg(pAlgorithmicDebuggingShortcut->key().toString()));
159159
// 3d animation perspective
160-
mpPerspectiveTabbar->addTab(QIcon(":/Resources/icons/debugger.svg"), tr("Animation"));
160+
mpPerspectiveTabbar->addTab(QIcon(":/Resources/icons/animation.png"), tr("Animation"));
161161
QShortcut *pAnimationShortcut = new QShortcut(QKeySequence("Ctrl+f6"), this);
162162
connect(pAnimationShortcut, SIGNAL(activated()), SLOT(switchToAnimationPerspectiveSlot()));
163163
mpPerspectiveTabbar->setTabToolTip(4, tr("Changes to animation perspective (%1)").arg(pAnimationShortcut->key().toString()));
@@ -3095,7 +3095,13 @@ void MainWindow::switchToAnimationPerspective()
30953095
storePlotWindowsStateAndGeometry();
30963096
mpCentralStackedWidget->setCurrentWidget(mpAnimationWindowContainer);
30973097
mpAnimationWindowContainer->showWidgets();
3098-
//mpAnimationWindowContainer->viewerWidget->show();
3098+
mpVariablesDockWidget->hide();
3099+
mpStackFramesDockWidget->hide();
3100+
mpBreakpointsDockWidget->hide();
3101+
mpLocalsDockWidget->hide();
3102+
mpTargetOutputDockWidget->hide();
3103+
mpGDBLoggerDockWidget->hide();
3104+
mpWelcomePageWidget->hide();
30993105
}
31003106

31013107
/*!

0 commit comments

Comments
 (0)