1 // Copyright (C) 2003 CEA/DEN, EDF R&D
5 // File : VISU_ViewManager_i.cxx
6 // Author : Alexey PETROV
10 #include "VISU_ViewManager_i.hh"
11 #include "VISU_PrsObject_i.hh"
12 #include "VISU_Table_i.hh"
13 #include "VISU_ScalarBarActor.hxx"
14 #include "VISU_Actor.h"
16 #include "QAD_Application.h"
17 #include "QAD_Desktop.h"
18 #include "QAD_Tools.h"
19 #include "QAD_Study.h"
20 #include "QAD_RightFrame.h"
21 #include "QAD_StudyFrame.h"
23 #include <qfileinfo.h>
25 #include "SALOMEGUI_TableDlg.h"
26 #include "Plot2d_CurveContainer.h"
27 #include "Plot2d_ViewFrame.h"
28 //#include "SALOMEGUI_SetupCurveDlg.h"
29 //#include "SALOMEGUI_SetupPlot2dDlg.h"
31 #include "VTKViewer_ViewFrame.h"
32 #include <vtkTransformPolyDataFilter.h>
33 #include <vtkDataSetMapper.h>
34 #include <vtkRenderer.h>
35 #include <vtkCamera.h>
40 static int MYDEBUG = 0;
42 static int MYDEBUG = 0;
45 static QFileInfo aFileInfo;
46 static int MYDELAY = 1;
49 //===========================================================================
50 VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame){
51 return dynamic_cast<VTKViewer_ViewFrame*>(theStudyFrame->getRightFrame()->getViewFrame());
53 vtkRenderer* GetRenderer(QAD_StudyFrame* theStudyFrame){
54 return GetViewFrame(theStudyFrame)->getRenderer();
56 vtkCamera* GetCamera(QAD_StudyFrame* theStudyFrame){
57 return GetRenderer(theStudyFrame)->GetActiveCamera();
59 void RepaintView(QAD_StudyFrame* theStudyFrame){
60 GetRenderer(theStudyFrame)->ResetCameraClippingRange();
61 GetViewFrame(theStudyFrame)->getRW()->getRenderWindow()->Render();
62 //GetViewFrame(theStudyFrame)->Repaint();
64 VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs){
65 VTKViewer_ViewFrame* vf = GetViewFrame(theStudyFrame);
67 if(MYDEBUG) MESSAGE("UpdateViewer - theDisplaing = "<<theDisplaing<<"; thePrs = "<<thePrs);
68 vtkRenderer *aRen = vf->getRenderer();
69 vtkActorCollection *anActColl = aRen->GetActors();
71 VISU_Actor *anVISUActor = NULL, *aResActor = NULL;
72 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;){
73 if(anActor->IsA("VISU_Actor")){
74 anVISUActor = VISU_Actor::SafeDownCast(anActor);
75 if (thePrs == anVISUActor->getPrs3d()) {
76 aResActor = anVISUActor->GetParent();
77 if(theDisplaing < eErase)
78 aResActor->VisibilityOn();
80 aResActor->VisibilityOff();
82 if(theDisplaing > eDisplay)
83 anVISUActor->VisibilityOff();
85 anVISUActor->VisibilityOn();
90 RepaintView(theStudyFrame);
93 if(thePrs != NULL && theDisplaing < eErase){
94 anVISUActor = thePrs->CreateActor();
96 vf->AddActor(anVISUActor);
98 MESSAGE ("Null actor is created");
102 RepaintView(theStudyFrame);
105 void UpdatePlot2d(Plot2d_ViewFrame *theView,int theDisplaying, Curve_i* theCurve) {
106 if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = "<<theDisplaying);
109 QList<Plot2d_Curve> clist;
110 theView->getCurves( clist );
111 if ( theDisplaying == eEraseAll ) {
112 for ( int i = 0; i < clist.count(); i++ ) {
113 if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing all : curve - "<<clist.at( i ));
114 theView->eraseCurve( clist.at( i ) );
117 else if ( theDisplaying == eErase ) {
118 for ( int i = 0; i < clist.count(); i++ ) {
119 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
120 if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - "<<clist.at( i ) );
121 theView->eraseCurve( clist.at( i ) );
125 else if ( theDisplaying == eDisplay ) {
127 for ( int i = 0; i < clist.count(); i++ ) {
128 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
129 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - "<<clist.at( i ) );
130 clist.at( i )->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
131 clist.at( i )->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
132 clist.at( i )->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
133 clist.at( i )->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
134 /* - DATA NOT UPDATED */
135 if ( !clist.at( i )->isAutoAssign() ) {
136 clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
137 clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
138 SALOMEDS::Color color = theCurve->GetColor();
139 clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
140 clist.at( i )->setAutoAssign( theCurve->IsAuto() );
142 theView->displayCurve( clist.at( i ) );
147 Plot2d_Curve* crv = theCurve->CreatePresentation();
148 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
150 theView->displayCurve( crv );
153 else if ( theDisplaying == eDisplayOnly ) {
155 for ( int i = 0; i < clist.count(); i++ ) {
156 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
157 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - "<<clist.at( i ) );
158 clist.at( i )->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
159 clist.at( i )->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
160 clist.at( i )->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
161 clist.at( i )->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
162 /* - DATA NOT UPDATED */
163 if ( !clist.at( i )->isAutoAssign() ) {
164 clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
165 clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
166 SALOMEDS::Color color = theCurve->GetColor();
167 clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
168 clist.at( i )->setAutoAssign( theCurve->IsAuto() );
170 theView->displayCurve( clist.at( i ) );
174 theView->eraseCurve( clist.at( i ) );
178 Plot2d_Curve* crv = theCurve->CreatePresentation();
179 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - "<<crv );
181 theView->displayCurve( crv );
185 //===========================================================================
188 class TViewManager: public QThread{
190 TViewManager(SALOMEDS::Study_ptr theStudy) : myStudyDocument(theStudy) {};
193 QAD_Desktop* aDesktop = QAD_Application::getDesktop();
194 QAD_Study* aStudy = aDesktop->findStudy(myStudyDocument);
196 CORBA::String_var aName = myStudyDocument->Name();
197 aFileInfo.setFile(aName.in());
198 aStudy = aDesktop->loadStudy(aFileInfo.baseName());
202 SALOMEDS::Study_ptr myStudyDocument;
205 ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy) {
206 if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i");
207 Mutex mt(myMutex,qApp,MYDELAY);
208 myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
209 //TViewManager* aTViewManager = new TViewManager(theStudy);
210 //aTViewManager->start();
211 QAD_Desktop* aDesktop = QAD_Application::getDesktop();
212 QAD_Study* aStudy = aDesktop->findStudy(theStudy);
214 CORBA::String_var aName = theStudy->Name();
215 aFileInfo.setFile(aName.in());
216 aStudy = aDesktop->loadStudy(aFileInfo.baseName());
218 MESSAGE("ViewManager_i::ERROR: Can't load study");
223 VISU::View3D_ptr ViewManager_i::Create3DView(){
224 Mutex mt(myMutex,qApp,MYDELAY);
225 if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
226 VISU::View3D_i* pView = new View3D_i(myStudyDocument);
227 if(pView->Create(1) != NULL)
228 return VISU::View3D::_duplicate(pView->_this());
229 return VISU::View3D::_nil();
233 VISU::View_ptr ViewManager_i::GetCurrentView(){
234 Mutex mt(myMutex,qApp,MYDELAY);
235 QAD_Study* Study = QAD_Application::getDesktop()->findStudy( myStudyDocument );
236 if(MYDEBUG) MESSAGE("ViewManager_i::GetCurrent3DView - Study = "<<Study);
237 QAD_StudyFrame* StudyFrame;
238 if ( Study && ( StudyFrame = Study->getActiveStudyFrame() ) ) {
240 MESSAGE("ViewManager_i::GetCurrent3DView - TypeView = "<<StudyFrame->getTypeView());
241 if ( StudyFrame->getTypeView() == VIEW_VTK ) {
242 VISU::View3D_i* pView = new View3D_i(myStudyDocument);
243 if(pView->Create(0) != NULL)
244 return VISU::View3D::_duplicate(pView->_this());
246 else if ( StudyFrame->getTypeView() == VIEW_PLOT2D ) {
247 VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
248 if(pView->Create(0) != NULL)
249 return VISU::XYPlot::_duplicate(pView->_this());
252 return VISU::View::_nil();
256 VISU::XYPlot_ptr ViewManager_i::CreateXYPlot(){
257 if(MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot");
258 Mutex mt(myMutex,qApp,MYDELAY);
259 VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
260 if(pView->Create(1) != NULL)
261 return VISU::XYPlot::_duplicate(pView->_this());
262 return VISU::XYPlot::_nil();
266 VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){
267 if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
268 Mutex mt(myMutex,qApp,MYDELAY);
269 VISU::TableView_i* pView = new TableView_i(myStudyDocument);
270 if(pView->Create(VISU::Table::_duplicate(theTable)) != NULL)
271 return VISU::TableView::_duplicate(pView->_this());
272 return VISU::TableView::_nil();
276 void ViewManager_i::Destroy(View_ptr theView){
277 if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<<theView->_is_nil());
278 if(theView->_is_nil()) return;
279 CORBA::Object_var aView = VISU::View::_narrow(theView);
280 if(!CORBA::is_nil(aView)){
281 if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - VISU::View"<<(!CORBA::is_nil(aView)));
282 VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(aView));
283 if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - dynamic_cast"<<pView);
286 pView->_remove_ref();
288 //if(pView) delete pView;
292 //===========================================================================
293 View_i::View_i(SALOMEDS::Study_ptr theStudy) {
294 if(MYDEBUG) MESSAGE("View_i::View_i");
295 CORBA::String_var aName = theStudy->Name();
296 QAD_Desktop* aDesktop = QAD_Application::getDesktop();
297 myStudy = aDesktop->findStudy(theStudy);
299 aFileInfo.setFile(aName.in());
300 myStudy = aDesktop->loadStudy(aFileInfo.baseName());
302 if(MYDEBUG) MESSAGE("View_i::View_i - isStudyOpened = "<<myStudy<<"; aName = "<<aName.in());
306 if(MYDEBUG) MESSAGE("View_i::~View_i");
309 void View_i::SetBackground(const SALOMEDS::Color& theColor) {}
310 SALOMEDS::Color View_i::GetBackground() { return SALOMEDS::Color();}
311 void View_i::Minimize() {}
312 void View_i::Restore() {}
313 void View_i::Maximize() {}
314 void View_i::EraseAll() {}
315 void View_i::DisplayAll() {}
316 void View_i::Erase(PrsObject_ptr thePrsObj) {}
317 void View_i::Display(PrsObject_ptr thePrsObj) {}
318 void View_i::DisplayOnly(PrsObject_ptr thePrsObj) {}
319 void View_i::Update() {}
321 CORBA::Boolean View_i::SavePicture(const char* theFileName) { return false; }
323 const char* View_i::GetComment() const { return "";}
324 void View_i::ToStream(std::ostringstream& theStr) {}
326 const char* View_i::GetEntry(){
327 SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectIOR(GetID());
328 CORBA::String_var anEntry = aSObject->GetID();
329 string aString(anEntry);
330 if(MYDEBUG) MESSAGE("Result_i::GetEntry - "<<aString);
331 return aString.c_str();
333 //===========================================================================
334 XYPlot_i::XYPlot_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
335 if(MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
337 Storable* XYPlot_i::Create(int theNew){
338 if(MYDEBUG) MESSAGE("XYPlot_i::Create");
339 Mutex mt(myMutex,qApp,MYDELAY);
341 myStudyFrame = myStudy->newWindow3d("",VIEW_PLOT2D);
343 myStudyFrame = myStudy->getActiveStudyFrame();
344 myView = dynamic_cast<Plot2d_ViewFrame*>(myStudyFrame->getRightFrame()->getViewFrame());
348 void XYPlot_i::Update() {
349 if(MYDEBUG) MESSAGE("XYPlot_i::Update");
350 Mutex mt(myMutex,qApp,MYDELAY);
351 myName = myStudyFrame->title();
354 void XYPlot_i::Close(){
355 if(MYDEBUG) MESSAGE("XYPlot_i::Close");
356 Mutex mt(myMutex,qApp,MYDELAY);
357 myStudyFrame->close();
359 XYPlot_i::~XYPlot_i() {
360 if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
361 Mutex mt(myMutex,qApp,MYDELAY);
362 myStudyFrame->close();
364 void XYPlot_i::SetTitle(const char* theTitle){
365 if(MYDEBUG) MESSAGE("XYPlot_i::SetTitle");
366 Mutex mt(myMutex,qApp,MYDELAY);
368 myStudyFrame->setCaption(myName.c_str());
370 char* XYPlot_i::GetTitle() {
371 if(MYDEBUG) MESSAGE("XYPlot_i::GetTitle");
372 Mutex mt(myMutex,qApp);
373 myName = (const char*)(myStudyFrame->title());
374 return CORBA::string_dup(myName.c_str());
377 void XYPlot_i::SetSubTitle(const char* theTitle){
378 if(MYDEBUG) MESSAGE("XYPlot_i::SetSubTitle");
379 Mutex mt(myMutex,qApp,MYDELAY);
380 myView->setTitle(theTitle);
382 char* XYPlot_i::GetSubTitle() {
383 if(MYDEBUG) MESSAGE("XYPlot_i::GetSubTitle");
384 Mutex mt(myMutex,qApp,MYDELAY);
385 return CORBA::string_dup(myView->getTitle());
388 void XYPlot_i::SetCurveType(VISU::XYPlot::CurveType theType){
389 if(MYDEBUG) MESSAGE("XYPlot_i::SetCurveType");
390 Mutex mt(myMutex,qApp,MYDELAY);
391 myView->setCurveType(theType);
393 VISU::XYPlot::CurveType XYPlot_i::GetCurveType(){
394 if(MYDEBUG) MESSAGE("XYPlot_i::GetCurveType");
395 Mutex mt(myMutex,qApp);
396 return (VISU::XYPlot::CurveType)myView->getCurveType();
399 void XYPlot_i::SetMarkerSize(CORBA::Long theSize){
400 if(MYDEBUG) MESSAGE("XYPlot_i::SetMarkerSize");
401 Mutex mt(myMutex,qApp,MYDELAY);
402 myView->setMarkerSize(theSize);
404 CORBA::Long XYPlot_i::GetMarkerSize(){
405 if(MYDEBUG) MESSAGE("XYPlot_i::GetMarkerSize");
406 Mutex mt(myMutex,qApp);
407 return myView->getMarkerSize();
410 void XYPlot_i::EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
411 CORBA::Boolean theMinor, CORBA::Long theNumMinor){
412 if(MYDEBUG) MESSAGE("XYPlot_i::EnableXGrid");
413 Mutex mt(myMutex,qApp,MYDELAY);
414 myView->setXGrid(theMajor,theNumMajor,theMinor,theNumMinor);
416 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
417 CORBA::Boolean theMinor, CORBA::Long theNumMinor){
418 if(MYDEBUG) MESSAGE("XYPlot_i::EnableYGrid");
419 Mutex mt(myMutex,qApp,MYDELAY);
420 myView->setYGrid(theMajor,theNumMajor,theMinor,theNumMinor);
423 void XYPlot_i::SetHorScaling(VISU::Scaling theScaling){
424 if(MYDEBUG) MESSAGE("XYPlot_i::SetHorScaling");
425 Mutex mt(myMutex,qApp,MYDELAY);
426 if(theScaling == VISU::LOGARITHMIC)
427 myView->setHorScaleMode(1);
429 myView->setHorScaleMode(0);
431 VISU::Scaling XYPlot_i::GetHorScaling(){
432 if(MYDEBUG) MESSAGE("XYPlot_i::GetHorScaling");
433 Mutex mt(myMutex,qApp,MYDELAY);
434 return (VISU::Scaling)myView->getHorScaleMode();
437 void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){
438 if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling");
439 Mutex mt(myMutex,qApp,MYDELAY);
440 if(theScaling == VISU::LOGARITHMIC)
441 myView->setVerScaleMode(1);
443 myView->setVerScaleMode(0);
445 VISU::Scaling XYPlot_i::GetVerScaling(){
446 if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling");
447 Mutex mt(myMutex,qApp);
448 return (VISU::Scaling)myView->getVerScaleMode();
451 void XYPlot_i::SetXTitle(const char* theTitle){
452 if(MYDEBUG) MESSAGE("XYPlot_i::SetXTitle");
453 Mutex mt(myMutex,qApp,MYDELAY);
454 myView->setXTitle(true,theTitle);
456 char* XYPlot_i::GetXTitle() {
457 if(MYDEBUG) MESSAGE("XYPlot_i::GetXTitle");
458 Mutex mt(myMutex,qApp);
459 return CORBA::string_dup(myView->getXTitle());
462 void XYPlot_i::SetYTitle(const char* theTitle){
463 if(MYDEBUG) MESSAGE("XYPlot_i::SetYTitle");
464 Mutex mt(myMutex,qApp,MYDELAY);
465 myView->setYTitle(true,theTitle);
467 char* XYPlot_i::GetYTitle() {
468 if(MYDEBUG) MESSAGE("XYPlot_i::GetYTitle");
469 Mutex mt(myMutex,qApp);
470 return CORBA::string_dup(myView->getYTitle());
473 void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){
474 if(MYDEBUG) MESSAGE("XYPlot_i::ShowLegend");
475 Mutex mt(myMutex,qApp,MYDELAY);
476 myView->showLegend(theShowing);
479 void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){
480 if(MYDEBUG) MESSAGE("XYPlot_i::SetBackground");
481 Mutex mt(myMutex,qApp,MYDELAY);
483 aColor[0] = (int)(255.0*theColor.R);
484 aColor[1] = (int)(255.0*theColor.G);
485 aColor[2] = (int)(255.0*theColor.B);
486 QColor aNewColor(aColor[0],aColor[1],aColor[2]);
487 myView->setBackgroundColor(aNewColor);
489 SALOMEDS::Color XYPlot_i::GetBackground() {
490 if(MYDEBUG) MESSAGE("XYPlot_i::GetBackground");
491 Mutex mt(myMutex,qApp);
492 SALOMEDS::Color aColor;
493 aColor.R = myView->backgroundColor().red()/255.0;
494 aColor.G = myView->backgroundColor().green()/255.0;
495 aColor.B = myView->backgroundColor().blue()/255.0;
498 void XYPlot_i::Minimize() {
499 if(MYDEBUG) MESSAGE("XYPlot_i::Minimize");
500 Mutex mt(myMutex,qApp,MYDELAY);
501 myStudyFrame->showMinimized();
503 void XYPlot_i::Restore() {
504 if(MYDEBUG) MESSAGE("XYPlot_i::Restore");
505 Mutex mt(myMutex,qApp,MYDELAY);
506 myStudyFrame->showNormal();
508 void XYPlot_i::Maximize() {
509 if(MYDEBUG) MESSAGE("XYPlot_i::Maximize");
510 Mutex mt(myMutex,qApp,MYDELAY);
511 myStudyFrame->showMaximized();
513 void XYPlot_i::Display(PrsObject_ptr thePrsObj) {
514 if(MYDEBUG) MESSAGE("XYPlot_i::Display");
515 Mutex mt(myMutex,qApp,MYDELAY);
516 CORBA::Object_ptr anObj = thePrsObj;
518 if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
519 UpdatePlot2d(myView,eDisplay,aCurve);
522 if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
523 int nbCurves = aContainer->GetNbCurves();
524 for ( int i = 1; i <= nbCurves; i++ ) {
525 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
526 if ( aCurve && aCurve->IsValid() ) {
527 UpdatePlot2d(myView,eDisplay,aCurve);
533 if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
534 SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
535 if ( !TableSO->_is_nil() ) {
536 SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
537 for ( ; Iter->More(); Iter->Next() ) {
538 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
539 if( !CORBA::is_nil( childObject ) ) {
540 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
541 if( !CORBA::is_nil( aCurve ) )
542 UpdatePlot2d(myView,eDisplay,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
549 void XYPlot_i::Erase(PrsObject_ptr thePrsObj) {
550 if(MYDEBUG) MESSAGE("XYPlot_i::Erase");
551 Mutex mt(myMutex,qApp,MYDELAY);
552 CORBA::Object_ptr anObj = thePrsObj;
554 if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
555 UpdatePlot2d(myView,eErase,aCurve);
558 if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
559 int nbCurves = aContainer->GetNbCurves();
560 for ( int i = 1; i <= nbCurves; i++ ) {
561 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
562 if ( aCurve && aCurve->IsValid() ) {
563 UpdatePlot2d(myView,eErase,aCurve);
569 if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
570 SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
571 if ( !TableSO->_is_nil() ) {
572 SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
573 for ( ; Iter->More(); Iter->Next() ) {
574 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
575 if( !CORBA::is_nil( childObject ) ) {
576 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
577 if( !CORBA::is_nil( aCurve ) )
578 UpdatePlot2d(myView,eErase,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
585 void XYPlot_i::EraseAll() {
586 if(MYDEBUG) MESSAGE("XYPlot_i::EraseAll");
587 Mutex mt(myMutex,qApp,MYDELAY);
590 void XYPlot_i::DisplayOnly(PrsObject_ptr thePrsObj) {
591 if(MYDEBUG) MESSAGE("XYPlot_i::DisplayOnly");
592 Mutex mt(myMutex,qApp,MYDELAY);
593 CORBA::Object_ptr anObj = thePrsObj;
595 if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
596 UpdatePlot2d(myView,eDisplayOnly,aCurve);
599 if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
600 int nbCurves = aContainer->GetNbCurves();
601 for ( int i = 1; i <= nbCurves; i++ ) {
602 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
603 if ( aCurve && aCurve->IsValid() ) {
604 UpdatePlot2d(myView,eDisplayOnly,aCurve);
610 if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
611 SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
612 if ( !TableSO->_is_nil() ) {
613 SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
614 for ( ; Iter->More(); Iter->Next() ) {
615 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
616 if( !CORBA::is_nil( childObject ) ) {
617 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
618 if( !CORBA::is_nil( aCurve ) )
619 UpdatePlot2d(myView,eDisplayOnly,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
626 void XYPlot_i::FitAll() {
627 if(MYDEBUG) MESSAGE("XYPlot_i::FitAll");
628 Mutex mt(myMutex,qApp,MYDELAY);
631 CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) {
632 if(MYDEBUG) MESSAGE("XYPlot_i::SavePicture");
633 Mutex mt(myMutex,qApp,MYDELAY);
634 if (!myView->getViewWidget())
637 QApplication::setOverrideCursor( Qt::waitCursor );
638 QPixmap px = QPixmap::grabWindow(myView->getViewWidget()->winId());
639 QApplication::restoreOverrideCursor();
641 if (!QString(theFileName).isNull()) {
642 QApplication::setOverrideCursor( Qt::waitCursor );
643 QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper();
645 fmt = QString("BMP"); // default format
648 bool bOk = px.save(theFileName, fmt.latin1());
649 QApplication::restoreOverrideCursor();
655 //===========================================================================
656 TableView_i::TableView_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {}
657 Storable* TableView_i::Create(VISU::Table_var theTable){
658 if(MYDEBUG) MESSAGE("TableView_i::Create - "<<(!theTable->_is_nil()));
659 Mutex mt(myMutex,qApp,MYDELAY);
660 if(!theTable->_is_nil()){
661 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable.in()));
662 if(MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = "<<table);
664 SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectID(table->GetObjectEntry());
665 if(!aSObject->_is_nil()) {
666 myView = new SALOMEGUI_TableDlg(QAD_Application::getDesktop(),
669 SALOMEGUI_TableDlg::ttAuto,
672 myName = (myView->caption()).latin1();
679 void TableView_i::SetTitle(const char* theTitle){
680 if(MYDEBUG) MESSAGE("TableView_i::SetTitle");
681 Mutex mt(myMutex,qApp,MYDELAY);
683 myView->setCaption(myName.c_str());
685 char* TableView_i::GetTitle() {
686 if(MYDEBUG) MESSAGE("TableView_i::GetTitle");
687 Mutex mt(myMutex,qApp);
688 myName = (myView->caption()).latin1();
689 return CORBA::string_dup(myName.c_str());
691 void TableView_i::Close(){
692 if(MYDEBUG) MESSAGE("TableView_i::Close");
693 Mutex mt(myMutex,qApp,MYDELAY);
696 TableView_i::~TableView_i() {
697 if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
698 Mutex mt(myMutex,qApp,MYDELAY);
702 //===========================================================================
703 int View3D_i::myNbViewParams = 0;
704 const string View3D_i::myComment = "VIEW3D";
705 const char* View3D_i::GetComment() const { return myComment.c_str();}
706 QString View3D_i::GenerateViewParamsName() {
707 return VISU::GenerateName( "ViewParams", ++myNbViewParams );
710 View3D_i::View3D_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
711 if(MYDEBUG) MESSAGE("View3D_i::View3D_i");
714 Storable* View3D_i::Create(int theNew){
715 if(MYDEBUG) MESSAGE("View3D_i::Create");
717 myStudyFrame = myStudy->newWindow3d("",VIEW_VTK);
719 myStudyFrame = myStudy->getActiveStudyFrame();
721 //GetViewFrame(myStudyFrame)->GetScale(myScaleFactor);
723 return this; //Build(false);
726 // Storable* View3D_i::Build(int theRestoring){
727 // if(MYDEBUG) MESSAGE("View3D_i::Build");
729 // myStudyFrame->setTitle(myName.c_str());
730 // SetBackground(myColor);
731 // SetPointOfView(myPosition);
732 // SetViewUp(myViewUp);
733 // SetFocalPoint(myFocalPnt);
734 // SetParallelScale(myParallelScale);
735 // ScaleView(VISU::View3D::XAxis,myScaleFactor[0]);
736 // ScaleView(VISU::View3D::YAxis,myScaleFactor[1]);
737 // ScaleView(VISU::View3D::ZAxis,myScaleFactor[2]);
738 // RepaintView(myStudyFrame);
742 // SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(myStudyDocument);
743 // CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID());
744 // string anEntry = CreateAttributes(myStudyDocument,aSComponentEntry,"",anIOR,myName.c_str(),"",GetComment());
750 void View3D_i::Update(){
751 if(MYDEBUG) MESSAGE("View3D_i::Update");
752 Mutex mt(myMutex,qApp,MYDELAY);
753 myName = (const char*)myStudyFrame->title();
754 // myColor = GetBackground();
755 // GetCamera(myStudyFrame)->GetPosition(myPosition);
756 // GetCamera(myStudyFrame)->GetViewUp(myViewUp);
757 // GetCamera(myStudyFrame)->GetFocalPoint(myFocalPnt);
758 // myParallelScale = GetCamera(myStudyFrame)->GetParallelScale();
759 //RepaintView(myStudyFrame);
761 //GetViewFrame(myStudyFrame)->GetScale(myScaleFactor);
763 VTKViewer_ViewFrame* vf = GetViewFrame(myStudyFrame);
764 vtkRenderer* Renderer = vf->getRenderer();
765 vtkActorCollection* theActors = Renderer->GetActors();
766 theActors->InitTraversal();
768 while(actor = theActors->GetNextActor()){
769 if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(actor)){
770 VISU::Prs3d_i* aPrs3d = anActor->getPrs3d();
771 if(anActor->GetVisibility() && aPrs3d){
773 aPrs3d->UpdateActor(anActor);
779 CORBA::Boolean View3D_i::SavePicture(const char* theFileName) {
780 if(MYDEBUG) MESSAGE("View3D_i::SavePicture");
781 Mutex mt(myMutex,qApp,MYDELAY);
782 if (!myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget())
785 QApplication::setOverrideCursor( Qt::waitCursor );
786 QPixmap px = QPixmap::grabWindow(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget()->winId());
787 QApplication::restoreOverrideCursor();
789 if (!QString(theFileName).isNull()) {
790 QApplication::setOverrideCursor( Qt::waitCursor );
791 QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper();
793 fmt = QString("BMP"); // default format
796 bool bOk = px.save(theFileName, fmt.latin1());
797 QApplication::restoreOverrideCursor();
803 CORBA::Boolean View3D_i::SaveViewParams(const char* theName){
804 if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint");
805 Mutex mt(myMutex,qApp,MYDELAY);
807 SALOMEDS::Study::ListOfSObject_var aList =
808 myStudy->getStudyDocument()->FindObjectByName(theName,"VISU");
809 SALOMEDS::GenericAttribute_var anAttr;
810 int iEnd = aList->length();
811 for(int i = 0; i < iEnd; i++){
812 SALOMEDS::SObject_var anObj = aList[i];
813 CORBA::String_var aString = anObj->GetID();
814 string anEntry(aString);
815 if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - anEntry = "<<anEntry);
816 if(anObj->FindAttribute(anAttr, "AttributeComment")){
817 SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
818 aString = aCmnt->Value();
819 string aComm(aString);
820 if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = "<<aComm);
821 if(aComm.compare(View3D_i::myComment) >= 0){
822 aCmnt->SetValue(ToString().c_str());
830 newName = QString( theName );
832 newName = QString( GenerateViewParamsName() );
833 SALOMEDS::SComponent_var aSComponent =
834 FindOrCreateVisuComponent(myStudy->getStudyDocument());
835 CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID());
836 string anEntry = CreateAttributes(myStudy->getStudyDocument(),aSComponentEntry,"","",newName.latin1(),"",ToString().c_str());
840 CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){
841 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - "<<theName);
842 Mutex mt(myMutex,qApp,MYDELAY);
843 SALOMEDS::Study::ListOfSObject_var aList =
844 myStudy->getStudyDocument()->FindObjectByName(theName,"VISU");
845 SALOMEDS::GenericAttribute_var anAttr;
846 int iEnd = aList->length();
847 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = "<<iEnd);
848 for(int i = 0; i < iEnd; i++){
849 SALOMEDS::SObject_var anObj = aList[i];
850 CORBA::String_var aString = anObj->GetID();
851 string anEntry(aString);
852 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = "<<anEntry);
853 if(anObj->FindAttribute(anAttr, "AttributeComment")){
854 SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
855 aString = aCmnt->Value();
856 QString strIn(aString);
857 Storable::TRestoringMap aMap;
858 Storable::StrToMap(strIn,aMap);
859 if ( Storable::FindValue( aMap,"myComment").compare( View3D_i::myComment.c_str() ) >= 0 ) {
860 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = "<<strIn);
861 return Restore( aMap ) != NULL;
868 Storable* View3D_i::Restore(const Storable::TRestoringMap& theMap) throw(std::logic_error&) {
869 // if(MYDEBUG) MESSAGE("View3D_i::Restore");
870 //myName = VISU::Storable::FindValue(theMap,"myName").latin1();
872 SALOMEDS::Color aColor;
873 aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
874 aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
875 aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
878 aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
879 aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
880 aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
883 aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
884 aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
885 aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
888 aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
889 aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
890 aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
892 double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
894 double aScaleFactor[3];
895 aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
896 aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
897 aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
899 myStudyFrame->setTitle(myName.c_str());
900 SetBackground(aColor);
901 SetPointOfView(aPosition);
903 SetFocalPoint(aFocalPnt);
904 SetParallelScale(aParallelScale);
905 ScaleView(VISU::View3D::XAxis,aScaleFactor[0]);
906 ScaleView(VISU::View3D::YAxis,aScaleFactor[1]);
907 ScaleView(VISU::View3D::ZAxis,aScaleFactor[2]);
908 RepaintView(myStudyFrame);
913 void View3D_i::ToStream(std::ostringstream& theStr) {
914 Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
917 GetRenderer(myStudyFrame)->GetBackground(backint);
918 Storable::DataToStream(theStr,"myColor.R",backint[0]);
919 Storable::DataToStream(theStr,"myColor.G",backint[1]);
920 Storable::DataToStream(theStr,"myColor.B",backint[2]);
923 GetPointOfView(myStudyFrame,aPosition);
924 Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
925 Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
926 Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
929 GetFocalPoint(myStudyFrame,aFocalPnt);
930 Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
931 Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
932 Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
935 GetCamera(myStudyFrame)->GetViewUp(aViewUp);
936 Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
937 Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
938 Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
940 Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(myStudyFrame));
942 double aScaleFactor[3];
943 GetViewFrame(myStudyFrame)->GetScale(aScaleFactor);
944 Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
945 Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
946 Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
950 // Storable* VISU::View3DRestore(SALOMEDS::SComponent_var& theSComponent, SALOMEDS::Study_var& theStudy,
951 // const char* thePrefix, const Storable::TRestoringMap& theMap)
954 // View3D_i* pView3D = new View3D_i(theStudy);
955 // return pView3D->Restore(theMap);
956 // }catch(std::logic_error& exc){
957 // MESSAGE("Follow exception was accured :\n"<<exc.what());
959 // MESSAGE("Unknown exception was accured!");
964 void View3D_i::Close(){
965 if(MYDEBUG) MESSAGE("View3D_i::Close");
966 Mutex mt(myMutex,qApp,MYDELAY);
967 myStudyFrame->close();
970 View3D_i::~View3D_i() {
971 if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
972 Mutex mt(myMutex,qApp,MYDELAY);
973 myStudyFrame->close();
976 //-------------------- View interface --------------------
977 void View3D_i::SetTitle(const char* theTitle){
978 if(MYDEBUG) MESSAGE("View3D_i::SetTitle");
979 Mutex mt(myMutex,qApp,MYDELAY);
981 myStudyFrame->setTitle(myName.c_str());
983 char* View3D_i::GetTitle() {
984 if(MYDEBUG) MESSAGE("View3D_i::GetTitle");
985 Mutex mt(myMutex,qApp,MYDELAY);
986 myName = (const char*)myStudyFrame->title();
987 return CORBA::string_dup(myName.c_str());
990 void View3D_i::SetBackground(QAD_StudyFrame* theStudyFrame, const SALOMEDS::Color& theColor) {
992 aColor[0] = (int)(255.0*theColor.R);
993 aColor[1] = (int)(255.0*theColor.G);
994 aColor[2] = (int)(255.0*theColor.B);
995 QColor aNewColor(aColor[0],aColor[1],aColor[2]);
996 GetViewFrame(theStudyFrame)->setBackgroundColor(aNewColor);
998 void View3D_i::SetBackground(const SALOMEDS::Color& theColor) {
999 if(MYDEBUG) MESSAGE("View3D_i::SetBackground");
1000 Mutex mt(myMutex,qApp,MYDELAY);
1001 //myColor.R = theColor.R; myColor.G = theColor.G; myColor.B = theColor.B;
1002 SetBackground(myStudyFrame,theColor);
1005 SALOMEDS::Color View3D_i::GetBackground(QAD_StudyFrame* theStudyFrame) {
1006 SALOMEDS::Color aColor;
1008 GetRenderer(theStudyFrame)->GetBackground(backint);
1009 aColor.R = backint[0]; aColor.G = backint[1]; aColor.B = backint[2];
1012 SALOMEDS::Color View3D_i::GetBackground() {
1013 if(MYDEBUG) MESSAGE("View3D_i::GetBackground");
1014 Mutex mt(myMutex,qApp,MYDELAY);
1015 //myColor = GetBackground(myStudyFrame);
1016 return GetBackground(myStudyFrame); //myColor;
1019 void View3D_i::Minimize() {
1020 if(MYDEBUG) MESSAGE("View3D_i::Minimize");
1021 Mutex mt(myMutex,qApp,MYDELAY);
1022 myStudyFrame->showMinimized();
1024 void View3D_i::Restore() {
1025 if(MYDEBUG) MESSAGE("View3D_i::Restore");
1026 Mutex mt(myMutex,qApp,MYDELAY);
1027 myStudyFrame->showNormal();
1029 void View3D_i::Maximize() {
1030 if(MYDEBUG) MESSAGE("View3D_i::Maximize");
1031 Mutex mt(myMutex,qApp,MYDELAY);
1032 myStudyFrame->showMaximized();
1034 //===========================================================================
1035 void View3D_i::EraseAll() {
1036 if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1037 Mutex mt(myMutex,qApp,MYDELAY);
1038 UpdateViewer(myStudyFrame,eEraseAll);
1040 void View3D_i::DisplayAll() {
1041 if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1042 Mutex mt(myMutex,qApp,MYDELAY);
1043 UpdateViewer(myStudyFrame,eDisplayAll);
1045 void View3D_i::Erase(PrsObject_ptr thePrsObj) {
1046 if(MYDEBUG) MESSAGE("View3D_i::Erase");
1047 Mutex mt(myMutex,qApp,MYDELAY);
1048 CORBA::Object_ptr anObj = thePrsObj;
1049 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
1050 UpdateViewer(myStudyFrame,eErase,aPrs);
1052 void View3D_i::Display(PrsObject_ptr thePrsObj) {
1053 if(MYDEBUG) MESSAGE("View3D_i::Display");
1054 Mutex mt(myMutex,qApp,MYDELAY);
1055 CORBA::Object_ptr anObj = thePrsObj;
1056 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
1057 UpdateViewer(myStudyFrame,eDisplay,aPrs);
1059 void View3D_i::DisplayOnly(PrsObject_ptr thePrsObj) {
1060 if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
1061 Mutex mt(myMutex,qApp,MYDELAY);
1062 CORBA::Object_ptr anObj = thePrsObj;
1063 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
1064 UpdateViewer(myStudyFrame,eDisplayOnly,aPrs);
1067 //-------------------- View3D interface --------------------
1068 void View3D_i::FitAll() {
1069 if(MYDEBUG) MESSAGE("View3D_i::FitAll");
1070 Mutex mt(myMutex,qApp,MYDELAY);
1071 GetViewFrame(myStudyFrame)->onViewFitAll();
1074 void View3D_i::SetView(VISU::View3D::ViewType theType) {
1075 if(MYDEBUG) MESSAGE("View3D_i::SetView");
1076 Mutex mt(myMutex,qApp,MYDELAY);
1078 case VISU::View3D::FRONT : GetViewFrame(myStudyFrame)->onViewFront(); break;
1079 case VISU::View3D::BACK : GetViewFrame(myStudyFrame)->onViewBack(); break;
1080 case VISU::View3D::LEFT : GetViewFrame(myStudyFrame)->onViewLeft(); break;
1081 case VISU::View3D::RIGHT : GetViewFrame(myStudyFrame)->onViewRight(); break;
1082 case VISU::View3D::TOP : GetViewFrame(myStudyFrame)->onViewTop(); break;
1083 case VISU::View3D::BOTTOM : GetViewFrame(myStudyFrame)->onViewBottom(); break;
1088 void View3D_i::SetPointOfView(QAD_StudyFrame* theStudyFrame, const CORBA::Double thePosition[3]) {
1089 GetCamera(theStudyFrame)->SetPosition(thePosition);
1091 void View3D_i::SetPointOfView(const VISU::View3D::XYZ theCoord) {
1092 if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
1093 Mutex mt(myMutex,qApp,MYDELAY);
1094 //VISU::View3D::XYZ_copy(myPosition,theCoord);
1095 SetPointOfView(myStudyFrame, theCoord);
1098 void View3D_i::GetPointOfView(QAD_StudyFrame* theStudyFrame, CORBA::Double thePosition[3]) {
1099 GetCamera(theStudyFrame)->GetPosition(thePosition);
1101 VISU::View3D::XYZ_slice* View3D_i::GetPointOfView() {
1102 if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
1103 Mutex mt(myMutex,qApp,MYDELAY);
1104 CORBA::Double aPosition[3];
1105 GetPointOfView(myStudyFrame,aPosition);
1106 return VISU::View3D::XYZ_dup(aPosition);
1109 void View3D_i::SetViewUp(QAD_StudyFrame* theStudyFrame, const CORBA::Double theViewUp[3]) {
1110 GetCamera(theStudyFrame)->SetViewUp(theViewUp);
1112 void View3D_i::SetViewUp(const VISU::View3D::XYZ theDir) {
1113 if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
1114 Mutex mt(myMutex,qApp,MYDELAY);
1115 //VISU::View3D::XYZ_copy(myViewUp,theDir);
1116 SetViewUp(myStudyFrame, theDir);
1119 void View3D_i::GetViewUp(QAD_StudyFrame* theStudyFrame, CORBA::Double theViewUp[3]) {
1120 GetCamera(theStudyFrame)->GetViewUp(theViewUp);
1122 VISU::View3D::XYZ_slice* View3D_i::GetViewUp() {
1123 if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
1124 Mutex mt(myMutex,qApp,MYDELAY);
1125 CORBA::Double aViewUp[3];
1126 GetCamera(myStudyFrame)->GetViewUp(aViewUp);
1127 return VISU::View3D::XYZ_dup(aViewUp);
1130 void View3D_i::SetFocalPoint(QAD_StudyFrame* theStudyFrame, const CORBA::Double theFocalPnt[3]) {
1131 GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt);
1133 void View3D_i::SetFocalPoint(const VISU::View3D::XYZ theCoord) {
1134 if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
1135 Mutex mt(myMutex,qApp,MYDELAY);
1136 //VISU::View3D::XYZ_copy(myFocalPnt,theCoord);
1137 SetFocalPoint(myStudyFrame,theCoord);
1140 void View3D_i::GetFocalPoint(QAD_StudyFrame* theStudyFrame, CORBA::Double theFocalPnt[3]) {
1141 GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt);
1143 VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint() {
1144 if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
1145 Mutex mt(myMutex,qApp,MYDELAY);
1146 CORBA::Double aFocalPnt[3];
1147 GetFocalPoint(myStudyFrame,aFocalPnt);
1148 return VISU::View3D::XYZ_dup(aFocalPnt);
1151 void View3D_i::SetParallelScale(QAD_StudyFrame* theStudyFrame, CORBA::Double theScale) {
1152 GetCamera(theStudyFrame)->SetParallelScale(theScale);
1154 void View3D_i::SetParallelScale(CORBA::Double theScale) {
1155 if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
1156 Mutex mt(myMutex,qApp,MYDELAY);
1157 //myParallelScale = theScale;
1158 SetParallelScale(myStudyFrame, theScale);
1161 CORBA::Double View3D_i::GetParallelScale(QAD_StudyFrame* theStudyFrame) {
1162 return GetCamera(theStudyFrame)->GetParallelScale();
1164 CORBA::Double View3D_i::GetParallelScale() {
1165 if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
1166 Mutex mt(myMutex,qApp);
1167 return GetParallelScale(myStudyFrame);
1170 void View3D_i::ScaleView(QAD_StudyFrame* theStudyFrame, VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1171 VTKViewer_ViewFrame* aViewFrame = GetViewFrame(theStudyFrame);
1172 double aScaleFactor[3];
1173 aViewFrame->GetScale(aScaleFactor);
1174 aScaleFactor[theAxis] = theParam;
1175 aViewFrame->SetScale(aScaleFactor);
1177 void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1178 if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
1179 Mutex mt(myMutex,qApp);
1180 //myScaleFactor[theAxis] = theParam;
1181 ScaleView(myStudyFrame,theAxis,theParam);
1183 void View3D_i::RemoveScale() {
1184 if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
1185 Mutex mt(myMutex,qApp);
1186 double aScaleFactor[]={1,1,1};
1187 //myScaleFactor[0] = myScaleFactor[0] = myScaleFactor[0] = 1.0;
1188 GetViewFrame(myStudyFrame)->SetScale(aScaleFactor);
1190 //===========================================================================