2 // File: VISU_ViewManager_i.cxx
3 // Created: Wed Jan 22 17:53:23 2003
4 // Author: Alexey PETROV
5 // <apo@ivanox.nnov.matra-dtv.fr>
7 #include "VISU_ViewManager_i.hh"
8 #include "VISU_PrsObject_i.hh"
9 #include "VISU_Table_i.hh"
10 #include "VISU_ScalarBarActor.hxx"
11 #include "VISU_Actor.h"
13 #include "QAD_Application.h"
14 #include "QAD_Desktop.h"
15 #include "QAD_Tools.h"
16 #include "QAD_Study.h"
17 #include "QAD_RightFrame.h"
18 #include "QAD_StudyFrame.h"
20 #include "VTKViewer_ViewFrame.h"
21 #include "SALOMEGUI_TableDlg.h"
22 #include "Plot2d_CurveContainer.h"
23 #include "Plot2d_ViewFrame.h"
24 //#include "SALOMEGUI_SetupCurveDlg.h"
25 //#include "SALOMEGUI_SetupPlot2dDlg.h"
27 #include <vtkTransformPolyDataFilter.h>
28 #include <vtkDataSetMapper.h>
29 #include <vtkRenderer.h>
30 #include <vtkCamera.h>
36 static int MYDEBUG = 1;
38 static int MYDEBUG = 0;
42 //===========================================================================
43 VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame){
44 return dynamic_cast<VTKViewer_ViewFrame*>(theStudyFrame->getRightFrame()->getViewFrame());
46 vtkRenderer* GetRenderer(QAD_StudyFrame* theStudyFrame){
47 return GetViewFrame(theStudyFrame)->getRenderer();
49 vtkCamera* GetCamera(QAD_StudyFrame* theStudyFrame){
50 return GetRenderer(theStudyFrame)->GetActiveCamera();
52 void RepaintView(QAD_StudyFrame* theStudyFrame){
53 GetRenderer(theStudyFrame)->ResetCameraClippingRange();
54 GetViewFrame(theStudyFrame)->Repaint();
56 VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs){
57 VTKViewer_ViewFrame* vf = GetViewFrame(theStudyFrame);
59 if(MYDEBUG) MESSAGE("UpdateViewer - theDisplaing = "<<theDisplaing<<"; thePrs = "<<thePrs);
60 vtkRenderer *aRen = vf->getRenderer();
61 vtkActorCollection *anActColl = aRen->GetActors();
63 VISU_Actor *anVISUActor = NULL, *aResActor = NULL;
64 void *aSrcAddr = thePrs != NULL? (void*)thePrs->GetMapper(): NULL;
65 if(MYDEBUG) MESSAGE("UpdateViewer - aSrcAddr = "<<aSrcAddr);
66 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
67 if(anActor->IsA("VISU_Actor")){
68 anVISUActor = VISU_Actor::SafeDownCast(anActor);
69 void* aCurrAddr = (void*)anVISUActor->GetMapper();
70 if(MYDEBUG) MESSAGE("UpdateViewer - aCurrAddr = "<<aCurrAddr);
71 if (aSrcAddr == aCurrAddr) {
72 if(MYDEBUG) MESSAGE("UpdateViewer - aSrcAddr == aCurrAddr");
73 aResActor = anVISUActor;
74 if(theDisplaing < eErase){
75 aResActor->VisibilityOn();
76 if (aResActor->HasScalarBar()) aResActor->getScalarBar()->VisibilityOn();
78 aResActor->VisibilityOff();
79 if (aResActor->HasScalarBar()) aResActor->getScalarBar()->VisibilityOff();
82 if(theDisplaing > eDisplay){
83 anVISUActor->VisibilityOff();
84 if (anVISUActor->HasScalarBar()) anVISUActor->getScalarBar()->VisibilityOff();
86 anVISUActor->VisibilityOn();
87 if (anVISUActor->HasScalarBar()) anVISUActor->getScalarBar()->VisibilityOn();
93 RepaintView(theStudyFrame);
96 if(thePrs != NULL && theDisplaing < eErase){
97 anVISUActor = thePrs->CreateActor();
99 if(MYDEBUG) MESSAGE("UpdateViewer - thePrs->CreateActor() = "<<anVISUActor->GetMapper());
100 vf->AddActor(anVISUActor);
101 if(anVISUActor->HasScalarBar()){
102 if(MYDEBUG) MESSAGE("UpdateViewer - anVISUActor->getScalarBar()");
103 aRen->AddActor2D(anVISUActor->getScalarBar());
106 MESSAGE ("Null actor is created");
110 RepaintView(theStudyFrame);
113 void UpdatePlot2d(Plot2d_ViewFrame *theView,int theDisplaying, Curve_i* theCurve) {
114 if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = "<<theDisplaying);
117 QList<Plot2d_Curve> clist;
118 theView->getCurves( clist );
119 if ( theDisplaying == eEraseAll ) {
120 for ( int i = 0; i < clist.count(); i++ ) {
121 if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing all : curve - "<<clist.at( i ));
122 theView->eraseCurve( clist.at( i ) );
125 else if ( theDisplaying == eErase ) {
126 for ( int i = 0; i < clist.count(); i++ ) {
127 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
128 if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - "<<clist.at( i ) );
129 theView->eraseCurve( clist.at( i ) );
133 else if ( theDisplaying == eDisplay ) {
135 for ( int i = 0; i < clist.count(); i++ ) {
136 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
137 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - "<<clist.at( i ) );
138 clist.at( i )->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
139 clist.at( i )->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
140 clist.at( i )->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
141 clist.at( i )->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
142 /* - DATA NOT UPDATED */
143 if ( !clist.at( i )->isAutoAssign() ) {
144 clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
145 clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
146 SALOMEDS::Color color = theCurve->GetColor();
147 clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
148 clist.at( i )->setAutoAssign( theCurve->IsAuto() );
150 theView->displayCurve( clist.at( i ) );
155 Plot2d_Curve* crv = theCurve->CreatePresentation();
156 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
158 theView->displayCurve( crv );
161 else if ( theDisplaying == eDisplayOnly ) {
163 for ( int i = 0; i < clist.count(); i++ ) {
164 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
165 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - "<<clist.at( i ) );
166 clist.at( i )->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
167 clist.at( i )->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
168 clist.at( i )->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
169 clist.at( i )->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
170 /* - DATA NOT UPDATED */
171 if ( !clist.at( i )->isAutoAssign() ) {
172 clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
173 clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
174 SALOMEDS::Color color = theCurve->GetColor();
175 clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
176 clist.at( i )->setAutoAssign( theCurve->IsAuto() );
178 theView->displayCurve( clist.at( i ) );
182 theView->eraseCurve( clist.at( i ) );
186 Plot2d_Curve* crv = theCurve->CreatePresentation();
187 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - "<<crv );
189 theView->displayCurve( crv );
193 //===========================================================================
194 ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy) {
195 if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i");
196 Mutex mt(myMutex,qApp);
197 myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
199 CORBA::String_var aName = myStudyDocument->Name();
200 if(QAD_Application::getDesktop()->getActiveApp()->isStudyOpened(aName.in()))
201 QAD_Application::getDesktop()->getActiveApp()->loadStudy(aName.in());
204 VISU::View3D_ptr ViewManager_i::Create3DView(){
205 if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
206 VISU::View3D_i* pView = new View3D_i(myStudyDocument);
207 if(pView->Create(1) != NULL)
208 return VISU::View3D::_duplicate(pView->_this());
209 return VISU::View3D::_nil();
211 VISU::View_ptr ViewManager_i::GetCurrentView(){
212 if(MYDEBUG) MESSAGE("ViewManager_i::GetCurrent3DView");
213 QAD_Study* Study = QAD_Application::getDesktop()->findStudy( myStudyDocument );
214 QAD_StudyFrame* StudyFrame;
215 if ( Study && ( StudyFrame = Study->getActiveStudyFrame() ) ) {
216 if ( StudyFrame->getTypeView() == VIEW_VTK ) {
217 VISU::View3D_i* pView = new View3D_i(myStudyDocument);
218 if(pView->Create(0) != NULL)
219 return VISU::View3D::_duplicate(pView->_this());
221 else if ( StudyFrame->getTypeView() == VIEW_PLOT2D ) {
222 VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
223 if(pView->Create(0) != NULL)
224 return VISU::XYPlot::_duplicate(pView->_this());
227 return VISU::View::_nil();
229 VISU::XYPlot_ptr ViewManager_i::CreateXYPlot(){
230 if(MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot");
231 VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
232 if(pView->Create(1) != NULL)
233 return VISU::XYPlot::_duplicate(pView->_this());
234 return VISU::XYPlot::_nil();
236 VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){
237 if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
238 VISU::TableView_i* pView = new TableView_i(myStudyDocument);
239 if(pView->Create(VISU::Table::_duplicate(theTable)) != NULL)
240 return VISU::TableView::_duplicate(pView->_this());
241 return VISU::TableView::_nil();
243 void ViewManager_i::Destroy(View_ptr theView){
244 if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<<theView->_is_nil());
245 if(theView->_is_nil()) return;
246 CORBA::Object_var aView = VISU::View::_narrow(theView);
247 if(!CORBA::is_nil(aView)){
248 if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - VISU::View"<<(!CORBA::is_nil(aView)));
249 VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(aView));
250 if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - dynamic_cast"<<pView);
253 pView->_remove_ref();
255 //if(pView) delete pView;
259 //===========================================================================
260 View_i::View_i(SALOMEDS::Study_ptr theStudy) {
261 if(MYDEBUG) MESSAGE("View_i::View_i");
262 Mutex mt(myMutex,qApp);
263 CORBA::String_var aName = theStudy->Name();
264 myStudy = QAD_Application::getDesktop()->findStudy( theStudy );
265 if(MYDEBUG) MESSAGE("View_i::View_i - isStudyOpened = "<<myStudy);
267 myStudy = myStudy = QAD_Application::getDesktop()->getActiveApp()->loadStudy(aName.in());
270 if(MYDEBUG) MESSAGE("View_i::~View_i");
273 void View_i::SetBackground(const SALOMEDS::Color& theColor) {}
274 SALOMEDS::Color View_i::GetBackground() { return SALOMEDS::Color();}
275 void View_i::Minimize() {}
276 void View_i::Restore() {}
277 void View_i::Maximize() {}
278 void View_i::EraseAll() {}
279 void View_i::DisplayAll() {}
280 void View_i::Erase(PrsObject_ptr thePrsObj) {}
281 void View_i::Display(PrsObject_ptr thePrsObj) {}
282 void View_i::DisplayOnly(PrsObject_ptr thePrsObj) {}
283 void View_i::Update() {}
285 CORBA::Boolean View_i::SavePicture(const char* theFileName) { return false; }
287 const char* View_i::GetComment() const { return "";}
288 void View_i::ToStream(ostrstream& theStr) {}
290 const char* View_i::GetEntry(){
291 SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectIOR(GetID());
292 CORBA::String_var anEntry = aSObject->GetID();
293 string aString(anEntry);
294 if(MYDEBUG) MESSAGE("Result_i::GetEntry - "<<aString);
295 return aString.c_str();
297 //===========================================================================
298 XYPlot_i::XYPlot_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
299 if(MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
301 Storable* XYPlot_i::Create(int theNew){
302 if(MYDEBUG) MESSAGE("XYPlot_i::Create");
303 Mutex mt(myMutex,qApp);
305 myStudyFrame = myStudy->newWindow3d("",VIEW_PLOT2D);
307 myStudyFrame = myStudy->getActiveStudyFrame();
308 myView = dynamic_cast<Plot2d_ViewFrame*>(myStudyFrame->getRightFrame()->getViewFrame());
312 void XYPlot_i::Update() {
313 if(MYDEBUG) MESSAGE("XYPlot_i::Update");
314 Mutex mt(myMutex,qApp);
315 myName = myStudyFrame->title();
318 void XYPlot_i::Close(){
319 if(MYDEBUG) MESSAGE("XYPlot_i::Close");
320 Mutex mt(myMutex,qApp);
321 myStudyFrame->close();
323 XYPlot_i::~XYPlot_i() {
324 if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
325 Mutex mt(myMutex,qApp);
326 myStudyFrame->close();
328 void XYPlot_i::SetTitle(const char* theTitle){
329 if(MYDEBUG) MESSAGE("XYPlot_i::SetTitle");
330 Mutex mt(myMutex,qApp);
332 myStudyFrame->setCaption(myName.c_str());
334 char* XYPlot_i::GetTitle() {
335 if(MYDEBUG) MESSAGE("XYPlot_i::GetTitle");
336 Mutex mt(myMutex,qApp);
337 myName = myStudyFrame->title();
338 return CORBA::string_dup(myName.c_str());
341 void XYPlot_i::SetSubTitle(const char* theTitle){
342 if(MYDEBUG) MESSAGE("XYPlot_i::SetSubTitle");
343 Mutex mt(myMutex,qApp);
344 myView->setTitle(theTitle);
346 char* XYPlot_i::GetSubTitle() {
347 if(MYDEBUG) MESSAGE("XYPlot_i::GetSubTitle");
348 Mutex mt(myMutex,qApp);
349 return CORBA::string_dup(myView->getTitle());
352 void XYPlot_i::SetCurveType(VISU::XYPlot::CurveType theType){
353 if(MYDEBUG) MESSAGE("XYPlot_i::SetCurveType");
354 Mutex mt(myMutex,qApp);
355 myView->setCurveType(theType);
357 VISU::XYPlot::CurveType XYPlot_i::GetCurveType(){
358 if(MYDEBUG) MESSAGE("XYPlot_i::GetCurveType");
359 Mutex mt(myMutex,qApp);
360 return (VISU::XYPlot::CurveType)myView->getCurveType();
363 void XYPlot_i::SetMarkerSize(CORBA::Long theSize){
364 if(MYDEBUG) MESSAGE("XYPlot_i::SetMarkerSize");
365 Mutex mt(myMutex,qApp);
366 myView->setMarkerSize(theSize);
368 CORBA::Long XYPlot_i::GetMarkerSize(){
369 if(MYDEBUG) MESSAGE("XYPlot_i::GetMarkerSize");
370 Mutex mt(myMutex,qApp);
371 return myView->getMarkerSize();
374 void XYPlot_i::EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
375 CORBA::Boolean theMinor, CORBA::Long theNumMinor){
376 if(MYDEBUG) MESSAGE("XYPlot_i::EnableXGrid");
377 Mutex mt(myMutex,qApp);
378 myView->setXGrid(theMajor,theNumMajor,theMinor,theNumMinor);
380 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
381 CORBA::Boolean theMinor, CORBA::Long theNumMinor){
382 if(MYDEBUG) MESSAGE("XYPlot_i::EnableYGrid");
383 Mutex mt(myMutex,qApp);
384 myView->setYGrid(theMajor,theNumMajor,theMinor,theNumMinor);
387 void XYPlot_i::SetHorScaling(VISU::Scaling theScaling){
388 if(MYDEBUG) MESSAGE("XYPlot_i::SetHorScaling");
389 Mutex mt(myMutex,qApp);
390 if(theScaling == VISU::LOGARITHMIC)
391 myView->setHorScaleMode(1);
393 myView->setHorScaleMode(0);
395 VISU::Scaling XYPlot_i::GetHorScaling(){
396 if(MYDEBUG) MESSAGE("XYPlot_i::GetHorScaling");
397 Mutex mt(myMutex,qApp);
398 return (VISU::Scaling)myView->getHorScaleMode();
401 void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){
402 if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling");
403 Mutex mt(myMutex,qApp);
404 if(theScaling == VISU::LOGARITHMIC)
405 myView->setVerScaleMode(1);
407 myView->setVerScaleMode(0);
409 VISU::Scaling XYPlot_i::GetVerScaling(){
410 if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling");
411 Mutex mt(myMutex,qApp);
412 return (VISU::Scaling)myView->getVerScaleMode();
415 void XYPlot_i::SetXTitle(const char* theTitle){
416 if(MYDEBUG) MESSAGE("XYPlot_i::SetXTitle");
417 Mutex mt(myMutex,qApp);
418 myView->setXTitle(true,theTitle);
420 char* XYPlot_i::GetXTitle() {
421 if(MYDEBUG) MESSAGE("XYPlot_i::GetXTitle");
422 Mutex mt(myMutex,qApp);
423 return CORBA::string_dup(myView->getXTitle());
426 void XYPlot_i::SetYTitle(const char* theTitle){
427 if(MYDEBUG) MESSAGE("XYPlot_i::SetYTitle");
428 Mutex mt(myMutex,qApp);
429 myView->setYTitle(true,theTitle);
431 char* XYPlot_i::GetYTitle() {
432 if(MYDEBUG) MESSAGE("XYPlot_i::GetYTitle");
433 Mutex mt(myMutex,qApp);
434 return CORBA::string_dup(myView->getYTitle());
437 void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){
438 if(MYDEBUG) MESSAGE("XYPlot_i::ShowLegend");
439 Mutex mt(myMutex,qApp);
440 myView->showLegend(theShowing);
443 void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){
444 if(MYDEBUG) MESSAGE("XYPlot_i::SetBackground");
445 Mutex mt(myMutex,qApp);
446 QColor aColor(255.0*theColor.R,255.0*theColor.G,255.0*theColor.B);
447 myView->setBackgroundColor(aColor);
449 SALOMEDS::Color XYPlot_i::GetBackground() {
450 if(MYDEBUG) MESSAGE("XYPlot_i::GetBackground");
451 Mutex mt(myMutex,qApp);
452 SALOMEDS::Color aColor;
453 aColor.R = myView->backgroundColor().red()/255.0;
454 aColor.G = myView->backgroundColor().green()/255.0;
455 aColor.B = myView->backgroundColor().blue()/255.0;
458 void XYPlot_i::Minimize() {
459 if(MYDEBUG) MESSAGE("XYPlot_i::Minimize");
460 Mutex mt(myMutex,qApp);
461 myStudyFrame->showMinimized();
463 void XYPlot_i::Restore() {
464 if(MYDEBUG) MESSAGE("XYPlot_i::Restore");
465 Mutex mt(myMutex,qApp);
466 myStudyFrame->showNormal();
468 void XYPlot_i::Maximize() {
469 if(MYDEBUG) MESSAGE("XYPlot_i::Maximize");
470 Mutex mt(myMutex,qApp);
471 myStudyFrame->showMaximized();
473 void XYPlot_i::Display(PrsObject_ptr thePrsObj) {
474 if(MYDEBUG) MESSAGE("View3D_i::Display");
475 Mutex mt(myMutex,qApp);
476 CORBA::Object_var anObj = thePrsObj;
478 if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
479 UpdatePlot2d(myView,eDisplay,aCurve);
482 if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
483 int nbCurves = aContainer->GetNbCurves();
484 for ( int i = 1; i <= nbCurves; i++ ) {
485 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
486 if ( aCurve && aCurve->IsValid() ) {
487 UpdatePlot2d(myView,eDisplay,aCurve);
493 if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
494 SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
495 if ( !TableSO->_is_nil() ) {
496 SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
497 for ( ; Iter->More(); Iter->Next() ) {
498 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
499 if( !CORBA::is_nil( childObject ) ) {
500 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
501 if( !CORBA::is_nil( aCurve ) )
502 UpdatePlot2d(myView,eDisplay,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
509 void XYPlot_i::Erase(PrsObject_ptr thePrsObj) {
510 if(MYDEBUG) MESSAGE("View3D_i::Display");
511 Mutex mt(myMutex,qApp);
512 CORBA::Object_var anObj = thePrsObj;
514 if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
515 UpdatePlot2d(myView,eErase,aCurve);
518 if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
519 int nbCurves = aContainer->GetNbCurves();
520 for ( int i = 1; i <= nbCurves; i++ ) {
521 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
522 if ( aCurve && aCurve->IsValid() ) {
523 UpdatePlot2d(myView,eErase,aCurve);
529 if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
530 SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
531 if ( !TableSO->_is_nil() ) {
532 SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
533 for ( ; Iter->More(); Iter->Next() ) {
534 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
535 if( !CORBA::is_nil( childObject ) ) {
536 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
537 if( !CORBA::is_nil( aCurve ) )
538 UpdatePlot2d(myView,eErase,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
545 void XYPlot_i::EraseAll() {
546 if(MYDEBUG) MESSAGE("XYPlot_i::EraseAll");
547 Mutex mt(myMutex,qApp);
550 void XYPlot_i::DisplayOnly(PrsObject_ptr thePrsObj) {
551 if(MYDEBUG) MESSAGE("View3D_i::Display");
552 Mutex mt(myMutex,qApp);
553 CORBA::Object_var anObj = thePrsObj;
555 if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
556 UpdatePlot2d(myView,eDisplayOnly,aCurve);
559 if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
560 int nbCurves = aContainer->GetNbCurves();
561 for ( int i = 1; i <= nbCurves; i++ ) {
562 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
563 if ( aCurve && aCurve->IsValid() ) {
564 UpdatePlot2d(myView,eDisplayOnly,aCurve);
570 if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
571 SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
572 if ( !TableSO->_is_nil() ) {
573 SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
574 for ( ; Iter->More(); Iter->Next() ) {
575 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
576 if( !CORBA::is_nil( childObject ) ) {
577 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
578 if( !CORBA::is_nil( aCurve ) )
579 UpdatePlot2d(myView,eDisplayOnly,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
586 void XYPlot_i::FitAll() {
587 if(MYDEBUG) MESSAGE("XYPlot_i::FitAll");
588 Mutex mt(myMutex,qApp);
591 CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) {
592 if(MYDEBUG) MESSAGE("XYPlot_i::SavePicture");
593 Mutex mt(myMutex,qApp);
594 if (!myView->getViewWidget())
597 QApplication::setOverrideCursor( Qt::waitCursor );
598 QPixmap px = QPixmap::grabWindow(myView->getViewWidget()->winId());
599 QApplication::restoreOverrideCursor();
601 if (!QString(theFileName).isNull()) {
602 QApplication::setOverrideCursor( Qt::waitCursor );
603 QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper();
605 fmt = QString("BMP"); // default format
608 bool bOk = px.save(theFileName, fmt.latin1());
609 QApplication::restoreOverrideCursor();
615 //===========================================================================
616 TableView_i::TableView_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {}
617 Storable* TableView_i::Create(VISU::Table_var theTable){
618 if(MYDEBUG) MESSAGE("TableView_i::Create - "<<(!theTable->_is_nil()));
619 Mutex mt(myMutex,qApp);
620 if(!theTable->_is_nil()){
621 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable.in()));
622 if(MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = "<<table);
624 SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectID(table->GetObjectEntry());
625 if(!aSObject->_is_nil()) {
626 myView = new SALOMEGUI_TableDlg(QAD_Application::getDesktop(),aSObject);
628 myName = (myView->caption()).latin1();
635 void TableView_i::SetTitle(const char* theTitle){
636 if(MYDEBUG) MESSAGE("TableView_i::SetTitle");
637 Mutex mt(myMutex,qApp);
639 myView->setCaption(myName.c_str());
641 char* TableView_i::GetTitle() {
642 if(MYDEBUG) MESSAGE("TableView_i::GetTitle");
643 Mutex mt(myMutex,qApp);
644 myName = (myView->caption()).latin1();
645 return CORBA::string_dup(myName.c_str());
647 void TableView_i::Close(){
648 if(MYDEBUG) MESSAGE("TableView_i::Close");
649 Mutex mt(myMutex,qApp);
652 TableView_i::~TableView_i() {
653 if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
654 Mutex mt(myMutex,qApp);
658 //===========================================================================
659 int View3D_i::myNbViewParams = 0;
660 const string View3D_i::myComment = "VIEW3D";
661 const char* View3D_i::GetComment() const { return myComment.c_str();}
662 const char* View3D_i::GenerateViewParamsName() {
663 return VISU::GenerateName( "ViewParams", ++myNbViewParams );
666 View3D_i::View3D_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
667 if(MYDEBUG) MESSAGE("View3D_i::View3D_i");
670 Storable* View3D_i::Create(int theNew){
671 if(MYDEBUG) MESSAGE("View3D_i::Create");
672 Mutex mt(myMutex,qApp);
674 myStudyFrame = myStudy->newWindow3d("",VIEW_VTK);
676 myStudyFrame = myStudy->getActiveStudyFrame();
678 VTKViewer_NonIsometricTransform *NITr = GetViewFrame(myStudyFrame)->getNonIsometricTransform();
679 myScaleFactor[0] = NITr->GetCoeff(AxisFunction::XAxis);
680 myScaleFactor[1] = NITr->GetCoeff(AxisFunction::YAxis);
681 myScaleFactor[2] = NITr->GetCoeff(AxisFunction::ZAxis);
686 Storable* View3D_i::Build(int theRestoring){
687 if(MYDEBUG) MESSAGE("View3D_i::Build");
689 myStudyFrame->setTitle(myName.c_str());
690 SetBackground(myColor);
691 SetPointOfView(myPosition);
693 SetFocalPoint(myFocalPnt);
694 SetParallelScale(myParallelScale);
695 ScaleView(VISU::View3D::XAxis,myScaleFactor[0]);
696 ScaleView(VISU::View3D::YAxis,myScaleFactor[1]);
697 ScaleView(VISU::View3D::ZAxis,myScaleFactor[2]);
698 RepaintView(myStudyFrame);
702 SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(myStudyDocument);
703 CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID());
704 string anEntry = CreateAttributes(myStudyDocument,aSComponentEntry,"",anIOR,myName.c_str(),"",GetComment());
710 void View3D_i::Update(){
711 if(MYDEBUG) MESSAGE("View3D_i::Update");
712 Mutex mt(myMutex,qApp);
713 myName = myStudyFrame->title();
714 myColor = GetBackground();
715 GetCamera(myStudyFrame)->GetPosition(myPosition);
716 GetCamera(myStudyFrame)->GetViewUp(myViewUp);
717 GetCamera(myStudyFrame)->GetFocalPoint(myFocalPnt);
718 myParallelScale = GetCamera(myStudyFrame)->GetParallelScale();
719 RepaintView(myStudyFrame);
721 VTKViewer_NonIsometricTransform *NITr = GetViewFrame(myStudyFrame)->getNonIsometricTransform();
722 myScaleFactor[0] = NITr->GetCoeff(AxisFunction::XAxis);
723 myScaleFactor[1] = NITr->GetCoeff(AxisFunction::YAxis);
724 myScaleFactor[2] = NITr->GetCoeff(AxisFunction::ZAxis);
727 CORBA::Boolean View3D_i::SavePicture(const char* theFileName) {
728 if(MYDEBUG) MESSAGE("View3D_i::SavePicture");
729 Mutex mt(myMutex,qApp);
730 if (!myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget())
733 QApplication::setOverrideCursor( Qt::waitCursor );
734 QPixmap px = QPixmap::grabWindow(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget()->winId());
735 QApplication::restoreOverrideCursor();
737 if (!QString(theFileName).isNull()) {
738 QApplication::setOverrideCursor( Qt::waitCursor );
739 QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper();
741 fmt = QString("BMP"); // default format
744 bool bOk = px.save(theFileName, fmt.latin1());
745 QApplication::restoreOverrideCursor();
751 CORBA::Boolean View3D_i::SaveViewParams(const char* theName){
752 if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint");
753 Mutex mt(myMutex,qApp);
755 SALOMEDS::Study::ListOfSObject_var aList =
756 myStudy->getStudyDocument()->FindObjectByName(theName,"VISU");
757 SALOMEDS::GenericAttribute_var anAttr;
758 int iEnd = aList->length();
759 for(int i = 0; i < iEnd; i++){
760 SALOMEDS::SObject_var anObj = aList[i];
761 CORBA::String_var aString = anObj->GetID();
762 string anEntry(aString);
763 if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - anEntry = "<<anEntry);
764 if(anObj->FindAttribute(anAttr, "AttributeComment")){
765 SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
766 aString = aCmnt->Value();
767 string aComm(aString);
768 if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = "<<aComm);
769 if(aComm.compare(View3D_i::myComment) >= 0){
770 aCmnt->SetValue(ToString());
778 newName = QString( theName );
780 newName = QString( GenerateViewParamsName() );
781 SALOMEDS::SComponent_var aSComponent =
782 FindOrCreateVisuComponent(myStudy->getStudyDocument());
783 CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID());
784 string anEntry = CreateAttributes(myStudy->getStudyDocument(),aSComponentEntry,"","",newName.latin1(),"",ToString());
788 CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){
789 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - "<<theName);
790 Mutex mt(myMutex,qApp);
791 SALOMEDS::Study::ListOfSObject_var aList =
792 myStudy->getStudyDocument()->FindObjectByName(theName,"VISU");
793 SALOMEDS::GenericAttribute_var anAttr;
794 int iEnd = aList->length();
795 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = "<<iEnd);
796 for(int i = 0; i < iEnd; i++){
797 SALOMEDS::SObject_var anObj = aList[i];
798 CORBA::String_var aString = anObj->GetID();
799 string anEntry(aString);
800 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = "<<anEntry);
801 if(anObj->FindAttribute(anAttr, "AttributeComment")){
802 SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
803 aString = aCmnt->Value();
804 QString strIn(aString);
805 Storable::TRestoringMap aMap;
806 Storable::StrToMap(strIn,aMap);
807 if ( Storable::FindValue( aMap,"myComment").compare( View3D_i::myComment.c_str() ) >= 0 ) {
808 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = "<<strIn);
809 return Restore( aMap ) != NULL;
816 #define RESTORE(MAP,ARG,FMT) ARG = VISU::Storable::FindValue(MAP,#ARG).FMT()
818 Storable* View3D_i::Restore(const Storable::TRestoringMap& theMap) throw(std::logic_error&) {
819 if(MYDEBUG) MESSAGE("View3D_i::Restore");
820 //RESTORE(theMap,myName,latin1);
822 RESTORE(theMap,myColor.R,toDouble);
823 RESTORE(theMap,myColor.G,toDouble);
824 RESTORE(theMap,myColor.B,toDouble);
826 RESTORE(theMap,myPosition[0],toDouble);
827 RESTORE(theMap,myPosition[1],toDouble);
828 RESTORE(theMap,myPosition[2],toDouble);
830 RESTORE(theMap,myFocalPnt[0],toDouble);
831 RESTORE(theMap,myFocalPnt[1],toDouble);
832 RESTORE(theMap,myFocalPnt[2],toDouble);
834 RESTORE(theMap,myViewUp[0],toDouble);
835 RESTORE(theMap,myViewUp[1],toDouble);
836 RESTORE(theMap,myViewUp[2],toDouble);
838 RESTORE(theMap,myParallelScale,toDouble);
840 RESTORE(theMap,myScaleFactor[0],toDouble);
841 RESTORE(theMap,myScaleFactor[1],toDouble);
842 RESTORE(theMap,myScaleFactor[2],toDouble);
849 void View3D_i::ToStream(ostrstream& theStr) {
850 if(MYDEBUG) MESSAGE(GetComment());
852 Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
854 Storable::DataToStream(theStr,"myColor.R",myColor.R);
855 Storable::DataToStream(theStr,"myColor.G",myColor.G);
856 Storable::DataToStream(theStr,"myColor.B",myColor.B);
858 Storable::DataToStream(theStr,"myPosition[0]",myPosition[0]);
859 Storable::DataToStream(theStr,"myPosition[1]",myPosition[1]);
860 Storable::DataToStream(theStr,"myPosition[2]",myPosition[2]);
862 Storable::DataToStream(theStr,"myFocalPnt[0]",myFocalPnt[0]);
863 Storable::DataToStream(theStr,"myFocalPnt[1]",myFocalPnt[1]);
864 Storable::DataToStream(theStr,"myFocalPnt[2]",myFocalPnt[2]);
866 Storable::DataToStream(theStr,"myViewUp[0]",myViewUp[0]);
867 Storable::DataToStream(theStr,"myViewUp[1]",myViewUp[1]);
868 Storable::DataToStream(theStr,"myViewUp[2]",myViewUp[2]);
870 Storable::DataToStream(theStr,"myParallelScale",myParallelScale);
872 Storable::DataToStream(theStr,"myScaleFactor[0]",myScaleFactor[0]);
873 Storable::DataToStream(theStr,"myScaleFactor[1]",myScaleFactor[1]);
874 Storable::DataToStream(theStr,"myScaleFactor[2]",myScaleFactor[2]);
877 Storable* VISU::View3DRestore(SALOMEDS::SComponent_var& theSComponent, SALOMEDS::Study_var& theStudy,
878 const char* thePrefix, const Storable::TRestoringMap& theMap)
881 View3D_i* pView3D = new View3D_i(theStudy);
882 return pView3D->Restore(theMap);
883 }catch(std::logic_error& exc){
884 MESSAGE("Follow exception was accured :\n"<<exc.what());
886 MESSAGE("Unknown exception was accured!");
891 void View3D_i::Close(){
892 if(MYDEBUG) MESSAGE("View3D_i::Close");
893 Mutex mt(myMutex,qApp);
894 myStudyFrame->close();
897 View3D_i::~View3D_i() {
898 if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
899 Mutex mt(myMutex,qApp);
900 myStudyFrame->close();
903 //-------------------- View interface --------------------
904 void View3D_i::SetTitle(const char* theTitle){
905 if(MYDEBUG) MESSAGE("View3D_i::SetTitle");
906 Mutex mt(myMutex,qApp);
909 SALOMEDS::SObject_var aSObject =
910 myStudy->getStudyDocument()->FindObjectID(GetEntry());
911 SALOMEDS::GenericAttribute_var anAttr;
912 if(aSObject->FindAttribute(anAttr,"AttributeName")){
913 SALOMEDS::AttributeName_ptr aName = SALOMEDS::AttributeName::_narrow(anAttr);
914 aName->SetValue(myName.c_str());
917 myStudyFrame->setTitle(myName.c_str());
919 char* View3D_i::GetTitle() {
920 if(MYDEBUG) MESSAGE("View3D_i::GetTitle");
921 Mutex mt(myMutex,qApp);
922 myName = myStudyFrame->title();
923 return CORBA::string_dup(myName.c_str());
925 void View3D_i::SetBackground(const SALOMEDS::Color& theColor) {
926 if(MYDEBUG) MESSAGE("View3D_i::SetBackground");
927 Mutex mt(myMutex,qApp);
928 myColor.R = theColor.R;
929 myColor.G = theColor.G;
930 myColor.B = theColor.B;
931 QColor aColor(255.0*myColor.R,255.0*myColor.G,255.0*myColor.B);
932 GetViewFrame(myStudyFrame)->setBackgroundColor(aColor);
934 SALOMEDS::Color View3D_i::GetBackground() {
935 if(MYDEBUG) MESSAGE("View3D_i::GetBackground");
936 Mutex mt(myMutex,qApp);
938 GetRenderer(myStudyFrame)->GetBackground(backint);
939 myColor.R = backint[0];
940 myColor.G = backint[1];
941 myColor.B = backint[2];
944 void View3D_i::Minimize() {
945 if(MYDEBUG) MESSAGE("View3D_i::Minimize");
946 Mutex mt(myMutex,qApp);
947 myStudyFrame->showMinimized();
949 void View3D_i::Restore() {
950 if(MYDEBUG) MESSAGE("View3D_i::Restore");
951 Mutex mt(myMutex,qApp);
952 myStudyFrame->showNormal();
954 void View3D_i::Maximize() {
955 if(MYDEBUG) MESSAGE("View3D_i::Maximize");
956 Mutex mt(myMutex,qApp);
957 myStudyFrame->showMaximized();
959 //===========================================================================
960 void View3D_i::EraseAll() {
961 if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
962 Mutex mt(myMutex,qApp);
963 UpdateViewer(myStudyFrame,eEraseAll);
965 void View3D_i::DisplayAll() {
966 if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
967 Mutex mt(myMutex,qApp);
968 UpdateViewer(myStudyFrame,eDisplayAll);
970 void View3D_i::Erase(PrsObject_ptr thePrsObj) {
971 if(MYDEBUG) MESSAGE("View3D_i::Erase");
972 Mutex mt(myMutex,qApp);
973 CORBA::Object_var anObj = thePrsObj;
974 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
975 UpdateViewer(myStudyFrame,eErase,aPrs);
977 void View3D_i::Display(PrsObject_ptr thePrsObj) {
978 if(MYDEBUG) MESSAGE("View3D_i::Display");
979 Mutex mt(myMutex,qApp);
980 CORBA::Object_var anObj = thePrsObj;
981 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
982 UpdateViewer(myStudyFrame,eDisplay,aPrs);
984 void View3D_i::DisplayOnly(PrsObject_ptr thePrsObj) {
985 if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
986 Mutex mt(myMutex,qApp);
987 CORBA::Object_var anObj = thePrsObj;
988 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
989 UpdateViewer(myStudyFrame,eDisplayOnly,aPrs);
992 //-------------------- View3D interface --------------------
993 void View3D_i::FitAll() {
994 if(MYDEBUG) MESSAGE("View3D_i::FitAll");
995 Mutex mt(myMutex,qApp);
996 GetViewFrame(myStudyFrame)->onViewFitAll();
999 void View3D_i::SetView(VISU::View3D::ViewType theType) {
1000 if(MYDEBUG) MESSAGE("View3D_i::SetView");
1001 Mutex mt(myMutex,qApp);
1003 case VISU::View3D::FRONT : GetViewFrame(myStudyFrame)->onViewFront(); break;
1004 case VISU::View3D::BACK : GetViewFrame(myStudyFrame)->onViewBack(); break;
1005 case VISU::View3D::LEFT : GetViewFrame(myStudyFrame)->onViewLeft(); break;
1006 case VISU::View3D::RIGHT : GetViewFrame(myStudyFrame)->onViewRight(); break;
1007 case VISU::View3D::TOP : GetViewFrame(myStudyFrame)->onViewTop(); break;
1008 case VISU::View3D::BOTTOM : GetViewFrame(myStudyFrame)->onViewBottom(); break;
1013 void View3D_i::SetPointOfView(const VISU::View3D::XYZ theCoord) {
1014 if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
1015 Mutex mt(myMutex,qApp);
1016 VISU::View3D::XYZ_copy(myPosition,theCoord);
1017 GetCamera(myStudyFrame)->SetPosition(myPosition);
1019 VISU::View3D::XYZ_slice* View3D_i::GetPointOfView() {
1020 if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
1021 Mutex mt(myMutex,qApp);
1022 GetCamera(myStudyFrame)->GetPosition(myPosition);
1023 return VISU::View3D::XYZ_dup(myPosition);
1026 void View3D_i::SetViewUp(const VISU::View3D::XYZ theDir) {
1027 if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
1028 Mutex mt(myMutex,qApp);
1029 VISU::View3D::XYZ_copy(myViewUp,theDir);
1030 GetCamera(myStudyFrame)->SetViewUp(myViewUp);
1032 VISU::View3D::XYZ_slice* View3D_i::GetViewUp() {
1033 if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
1034 Mutex mt(myMutex,qApp);
1035 GetCamera(myStudyFrame)->GetViewUp(myViewUp);
1036 return VISU::View3D::XYZ_dup(myViewUp);
1039 void View3D_i::SetFocalPoint(const VISU::View3D::XYZ theCoord) {
1040 if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
1041 Mutex mt(myMutex,qApp);
1042 VISU::View3D::XYZ_copy(myFocalPnt,theCoord);
1043 GetCamera(myStudyFrame)->SetFocalPoint(myFocalPnt);
1045 VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint() {
1046 if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
1047 Mutex mt(myMutex,qApp);
1048 GetCamera(myStudyFrame)->GetFocalPoint(myFocalPnt);
1049 return VISU::View3D::XYZ_dup(myFocalPnt);
1052 void View3D_i::SetParallelScale(CORBA::Double theScale) {
1053 if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
1054 Mutex mt(myMutex,qApp);
1055 myParallelScale = theScale;
1056 GetCamera(myStudyFrame)->SetParallelScale(myParallelScale);
1058 CORBA::Double View3D_i::GetParallelScale() {
1059 if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
1060 Mutex mt(myMutex,qApp);
1061 return myParallelScale = GetCamera(myStudyFrame)->GetParallelScale();
1064 void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1065 Mutex mt(myMutex,qApp);
1066 bool changed = false;
1067 VTKViewer_ViewFrame* vf = GetViewFrame(myStudyFrame);
1068 VTKViewer_NonIsometricTransform *aTransform = vf->getNonIsometricTransform();
1069 static double EPS =1.0E-3;
1070 VTKViewer_NonIsometricTransform::Function
1071 aFunction = (fabs(theParam - 1.0) < EPS?
1072 VTKViewer_NonIsometricTransform::Identical:
1073 VTKViewer_NonIsometricTransform::Linear);
1074 AxisFunction::Axis anAxis;
1075 if(theAxis == VISU::View3D::XAxis){
1076 myScaleFactor[0] = theParam;
1077 anAxis = AxisFunction::XAxis;
1078 }else if(theAxis == VISU::View3D::YAxis){
1079 myScaleFactor[1] = theParam;
1080 anAxis = AxisFunction::YAxis;
1082 myScaleFactor[2] = theParam;
1083 anAxis = AxisFunction::ZAxis;
1086 MESSAGE("View3D_i::ScaleView - theParam = "<<theParam<<"; aFunction = "<<aFunction);
1087 vtkRenderer* Renderer = vf->getRenderer();
1088 vtkActorCollection* theActors = Renderer->GetActors();
1089 theActors->InitTraversal();
1090 vtkActor *actor = theActors->GetNextActor();
1092 //SALOME_Actor* pSA = dynamic_cast<SALOME_Actor*> (actor);
1093 SALOME_Actor* pSA = dynamic_cast<VISU_Actor*> (actor);
1095 vtkPolyDataMapper* mapper = NULL;
1096 vtkMapper* initialMapper = pSA->GetInitialMapper();
1097 if ( initialMapper == NULL )
1098 initialMapper = actor->GetMapper();
1099 if ( initialMapper->IsA("vtkDataSetMapper") )
1100 mapper = vtkDataSetMapper::SafeDownCast( initialMapper )->GetPolyDataMapper ();
1102 mapper = vtkPolyDataMapper::SafeDownCast( initialMapper );
1104 //create transformation
1105 if(MYDEBUG) MESSAGE("View3D_i::ScaleView - theActors->GetNextActor()");
1106 aTransform->SetFunction(anAxis,aFunction,theParam);
1108 vtkTransformPolyDataFilter *aTransformFilter = vtkTransformPolyDataFilter::New();
1109 aTransformFilter->SetInput ( mapper->GetInput() );
1110 aTransformFilter->SetTransform (aTransform);
1112 vtkPolyDataMapper *aMapper = vtkPolyDataMapper::New();
1113 aMapper->SetInput (aTransformFilter->GetOutput());
1114 aMapper->ShallowCopy ( actor->GetMapper());
1116 actor->SetMapper (aMapper);
1117 aTransformFilter->Delete();
1122 actor = theActors->GetNextActor();
1125 MESSAGE("View3D_i::ScaleView - myScaleFactor = "<<
1126 myScaleFactor[0]<<"; "<<myScaleFactor[1]<<"; "<<myScaleFactor[2]);
1128 RepaintView(myStudyFrame);
1130 void View3D_i::RemoveScale() {
1131 if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
1132 Mutex mt(myMutex,qApp);
1133 ScaleView(VISU::View3D::XAxis,1.0);
1134 ScaleView(VISU::View3D::YAxis,1.0);
1135 ScaleView(VISU::View3D::ZAxis,1.0);
1137 //===========================================================================