35
35
#include " AnimationWindowContainer.h"
36
36
37
37
38
+ const double HEIGHT_CONTROLWIDGETS = 40 ;
39
+
38
40
/* !
39
41
\class AnimationWindowContainer
40
42
\brief A MDI area for animation windows.
@@ -65,6 +67,9 @@ AnimationWindowContainer::AnimationWindowContainer(MainWindow *pParent)
65
67
// the viewer widget
66
68
osg::ref_ptr<osg::Node> rootNode = osgDB::readRefNodeFile (" D:/Programming/OPENMODELICA_GIT/OpenModelica/build/bin/dumptruck.osg" );
67
69
_viewerWidget = setupViewWidget (rootNode);
70
+ _viewerWidget->setParent (this );
71
+ _viewerWidget->setWindowFlags (Qt::SubWindow);
72
+ // _viewerWidget->setWindowState(Qt::WindowMaximized);
68
73
// the control widgets
69
74
_topWidget = AnimationWindowContainer::setupAnimationWidgets ();
70
75
}
@@ -82,27 +87,27 @@ QWidget* AnimationWindowContainer::setupViewWidget(osg::ref_ptr<osg::Node> rootN
82
87
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits ();
83
88
traits->windowName = " " ;
84
89
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 ();
89
95
traits->doubleBuffer = true ;
90
96
traits->alpha = ds->getMinimumNumAlphaBits ();
91
97
traits->stencil = ds->getMinimumNumStencilBits ();
92
98
traits->sampleBuffers = ds->getMultiSamples ();
93
99
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 ());
95
101
96
102
// add a scene to viewer
97
103
addView (_sceneView);
98
104
99
105
// get the viewer widget
100
106
osg::ref_ptr<osg::Camera> camera = _sceneView->getCamera ();
101
107
camera->setGraphicsContext (gw);
102
- const osg::GraphicsContext::Traits* traits2 = gw->getTraits ();
103
108
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 );
106
111
_sceneView->setSceneData (rootNode);
107
112
_sceneView->addEventHandler (new osgViewer::StatsHandler ());
108
113
_sceneView->setCameraManipulator (new osgGA::MultiTouchTrackballManipulator ());
@@ -141,13 +146,13 @@ QWidget* AnimationWindowContainer::setupAnimationWidgets()
141
146
rowLayOut->addWidget (_timeSlider);
142
147
rowLayOut->addWidget (_RTFactorDisplay);
143
148
rowLayOut->addWidget (_timeDisplay);
144
- QGroupBox* widgetRowBox = new QGroupBox (this );
149
+ QGroupBox* widgetRowBox = new QGroupBox ();
145
150
widgetRowBox->setLayout (rowLayOut);
146
- widgetRowBox->setFixedHeight (40 );
151
+ widgetRowBox->setFixedHeight (HEIGHT_CONTROLWIDGETS );
147
152
148
153
_topWidget = new QWidget (this );
149
- QVBoxLayout* mainVLayout = new QVBoxLayout (this );
150
- // mainVLayout->addWidget(viewerWidget );
154
+ QVBoxLayout* mainVLayout = new QVBoxLayout ();
155
+ // mainVLayout->addWidget(_viewerWidget );
151
156
mainVLayout->addWidget (widgetRowBox);
152
157
_topWidget->setLayout (mainVLayout);
153
158
@@ -209,12 +214,16 @@ void AnimationWindowContainer::loadVisualization(){
209
214
void AnimationWindowContainer::chooseAnimationFileSlotFunction (){
210
215
std::cout<<" animationFileSlotFunction " <<std::endl;
211
216
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 (" " )){
213
219
std::size_t pos = file.find_last_of (" /\\ " );
214
220
_pathName = file.substr (0 , pos + 1 );
215
221
_fileName = file.substr (pos + 1 , file.length ());
216
222
std::cout<<" file " <<_fileName<<" path " <<_pathName<<std::endl;
217
223
loadVisualization ();
224
+ }
225
+ else
226
+ std::cout<<" No Visualization selected!" <<std::endl;
218
227
219
228
}
220
229
@@ -251,6 +260,8 @@ void AnimationWindowContainer::pauseSlotFunction(){
251
260
*/
252
261
void AnimationWindowContainer::initSlotFunction (){
253
262
std::cout<<" initSlotFunction " <<std::endl;
263
+ _visualizer->initVisualization ();
264
+
254
265
}
255
266
256
267
/* !
0 commit comments