1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 // File : VISU_ViewManager_i.cc
24 // Author : Alexey PETROV
27 #include "VISU_ViewManager_i.hh"
29 #include "VISU_PrsObject_i.hh"
30 #include "VISU_Result_i.hh"
32 #include "VISU_Prs3d_i.hh"
33 #include "VISU_Mesh_i.hh"
34 #include "VISU_ScalarMap_i.hh"
35 #include "VISU_IsoSurfaces_i.hh"
36 #include "VISU_DeformedShape_i.hh"
37 #include "VISU_CutPlanes_i.hh"
38 #include "VISU_CutLines_i.hh"
39 #include "VISU_Vectors_i.hh"
40 #include "VISU_StreamLines_i.hh"
42 #include "VISU_Table_i.hh"
43 #include "VISU_ScalarBarActor.hxx"
44 #include "VISU_Actor.h"
46 #include "QAD_Application.h"
47 #include "QAD_Desktop.h"
48 #include "QAD_Tools.h"
49 #include "QAD_Study.h"
50 #include "QAD_RightFrame.h"
51 #include "QAD_StudyFrame.h"
53 #include "VTKViewer_ViewFrame.h"
54 #include "SALOMEGUI_TableDlg.h"
55 #include "Plot2d_CurveContainer.h"
56 #include "Plot2d_ViewFrame.h"
61 #include <qfileinfo.h>
63 #include <vtkTransformPolyDataFilter.h>
64 #include <vtkDataSetMapper.h>
65 #include <vtkRenderer.h>
66 #include <vtkCamera.h>
71 static int MYDEBUG = 0;
73 static int MYDEBUG = 0;
76 static QFileInfo aFileInfo;
77 static int MYDELAY = 1;
80 //===========================================================================
81 VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame){
82 return dynamic_cast<VTKViewer_ViewFrame*>(theStudyFrame->getRightFrame()->getViewFrame());
84 vtkRenderer* GetRenderer(QAD_StudyFrame* theStudyFrame){
85 return GetViewFrame(theStudyFrame)->getRenderer();
87 vtkCamera* GetCamera(QAD_StudyFrame* theStudyFrame){
88 return GetRenderer(theStudyFrame)->GetActiveCamera();
90 void RepaintView(QAD_StudyFrame* theStudyFrame){
91 GetRenderer(theStudyFrame)->ResetCameraClippingRange();
92 GetViewFrame(theStudyFrame)->getRW()->getRenderWindow()->Render();
93 //GetViewFrame(theStudyFrame)->Repaint();
95 VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs){
96 VTKViewer_ViewFrame* vf = GetViewFrame(theStudyFrame);
98 if(MYDEBUG) MESSAGE("UpdateViewer - theDisplaing = "<<theDisplaing<<"; thePrs = "<<thePrs);
99 vtkRenderer *aRen = vf->getRenderer();
100 vtkActorCollection *anActColl = aRen->GetActors();
102 VISU_Actor *anVISUActor = NULL, *aResActor = NULL;
103 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;){
104 if(anActor->IsA("VISU_Actor")){
105 anVISUActor = VISU_Actor::SafeDownCast(anActor);
106 if (thePrs == anVISUActor->GetPrs3d()) {
107 aResActor = anVISUActor->GetParent();
108 if(theDisplaing < eErase)
109 aResActor->VisibilityOn();
111 aResActor->VisibilityOff();
113 if(theDisplaing > eDisplay)
114 anVISUActor->VisibilityOff();
116 anVISUActor->VisibilityOn();
121 RepaintView(theStudyFrame);
124 if(thePrs != NULL && theDisplaing < eErase){
126 anVISUActor = thePrs->CreateActor();
127 vf->AddActor(anVISUActor);
128 }catch(std::runtime_error& exc){
129 INFOS("Null actor is created");
133 RepaintView(theStudyFrame);
136 void UpdatePlot2d(Plot2d_ViewFrame *theView,int theDisplaying, Curve_i* theCurve) {
137 if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = "<<theDisplaying);
140 QList<Plot2d_Curve> clist;
141 theView->getCurves( clist );
142 if ( theDisplaying == eEraseAll ) {
143 for ( int i = 0; i < clist.count(); i++ ) {
144 if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing all : curve - "<<clist.at( i ));
145 theView->eraseCurve( clist.at( i ) );
148 else if ( theDisplaying == eErase ) {
149 for ( int i = 0; i < clist.count(); i++ ) {
150 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
151 if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - "<<clist.at( i ) );
152 theView->eraseCurve( clist.at( i ) );
156 else if ( theDisplaying == eDisplay ) {
158 for ( int i = 0; i < clist.count(); i++ ) {
159 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
160 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - "<<clist.at( i ) );
161 clist.at( i )->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
162 clist.at( i )->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
163 clist.at( i )->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
164 clist.at( i )->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
165 /* - DATA NOT UPDATED */
166 if ( !clist.at( i )->isAutoAssign() ) {
167 clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
168 clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
169 SALOMEDS::Color color = theCurve->GetColor();
170 clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
171 clist.at( i )->setAutoAssign( theCurve->IsAuto() );
173 theView->displayCurve( clist.at( i ) );
178 Plot2d_Curve* crv = theCurve->CreatePresentation();
179 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
181 theView->displayCurve( crv );
184 else if ( theDisplaying == eDisplayOnly ) {
186 for ( int i = 0; i < clist.count(); i++ ) {
187 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
188 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - "<<clist.at( i ) );
189 clist.at( i )->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
190 clist.at( i )->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
191 clist.at( i )->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
192 clist.at( i )->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
193 /* - DATA NOT UPDATED */
194 if ( !clist.at( i )->isAutoAssign() ) {
195 clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
196 clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
197 SALOMEDS::Color color = theCurve->GetColor();
198 clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
199 clist.at( i )->setAutoAssign( theCurve->IsAuto() );
201 theView->displayCurve( clist.at( i ) );
205 theView->eraseCurve( clist.at( i ) );
209 Plot2d_Curve* crv = theCurve->CreatePresentation();
210 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - "<<crv );
212 theView->displayCurve( crv );
216 //===========================================================================
219 class TViewManager: public QThread{
221 TViewManager(SALOMEDS::Study_ptr theStudy) : myStudyDocument(theStudy) {};
224 QAD_Desktop* aDesktop = QAD_Application::getDesktop();
225 QAD_Study* aStudy = aDesktop->findStudy(myStudyDocument);
227 CORBA::String_var aName = myStudyDocument->Name();
228 aFileInfo.setFile(aName.in());
229 aStudy = aDesktop->loadStudy(aFileInfo.baseName());
233 SALOMEDS::Study_ptr myStudyDocument;
236 ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy) {
237 if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i");
238 Mutex mt(myMutex,qApp,MYDELAY);
239 myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
240 //TViewManager* aTViewManager = new TViewManager(theStudy);
241 //aTViewManager->start();
242 QAD_Desktop* aDesktop = QAD_Application::getDesktop();
243 QAD_Study* aStudy = aDesktop->findStudy(theStudy);
245 CORBA::String_var aName = theStudy->Name();
246 aFileInfo.setFile(aName.in());
247 aStudy = aDesktop->loadStudy(aFileInfo.baseName());
249 MESSAGE("ViewManager_i::ERROR: Can't load study");
254 VISU::View3D_ptr ViewManager_i::Create3DView(){
255 Mutex mt(myMutex,qApp,MYDELAY);
256 if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
257 VISU::View3D_i* pView = new View3D_i(myStudyDocument);
258 if(pView->Create(1) != NULL)
259 return VISU::View3D::_duplicate(pView->_this());
260 return VISU::View3D::_nil();
264 VISU::View_ptr ViewManager_i::GetCurrentView(){
265 Mutex mt(myMutex,qApp,MYDELAY);
266 QAD_Study* Study = QAD_Application::getDesktop()->findStudy( myStudyDocument );
267 if(MYDEBUG) MESSAGE("ViewManager_i::GetCurrent3DView - Study = "<<Study);
268 QAD_StudyFrame* StudyFrame;
269 if ( Study && ( StudyFrame = Study->getActiveStudyFrame() ) ) {
271 MESSAGE("ViewManager_i::GetCurrent3DView - TypeView = "<<StudyFrame->getTypeView());
272 if ( StudyFrame->getTypeView() == VIEW_VTK ) {
273 VISU::View3D_i* pView = new View3D_i(myStudyDocument);
274 if(pView->Create(0) != NULL)
275 return VISU::View3D::_duplicate(pView->_this());
277 else if ( StudyFrame->getTypeView() == VIEW_PLOT2D ) {
278 VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
279 if(pView->Create(0) != NULL)
280 return VISU::XYPlot::_duplicate(pView->_this());
283 return VISU::View::_nil();
287 VISU::XYPlot_ptr ViewManager_i::CreateXYPlot(){
288 if(MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot");
289 Mutex mt(myMutex,qApp,MYDELAY);
290 VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
291 if(pView->Create(1) != NULL)
292 return VISU::XYPlot::_duplicate(pView->_this());
293 return VISU::XYPlot::_nil();
297 VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){
298 if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
299 Mutex mt(myMutex,qApp,MYDELAY);
300 VISU::TableView_i* pView = new TableView_i(myStudyDocument);
301 if(pView->Create(VISU::Table::_duplicate(theTable)) != NULL)
302 return VISU::TableView::_duplicate(pView->_this());
303 return VISU::TableView::_nil();
307 void ViewManager_i::Destroy(View_ptr theView){
308 if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<<theView->_is_nil());
309 if(theView->_is_nil()) return;
310 CORBA::Object_var aView = VISU::View::_narrow(theView);
311 if(!CORBA::is_nil(aView)){
312 if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - VISU::View"<<(!CORBA::is_nil(aView)));
313 VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(aView));
314 if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - dynamic_cast"<<pView);
317 pView->_remove_ref();
319 //if(pView) delete pView;
325 void ViewManager_i::ProcessEvents() {
330 qApp->processEvents();
337 //===========================================================================
338 View_i::View_i(SALOMEDS::Study_ptr theStudy) {
339 if(MYDEBUG) MESSAGE("View_i::View_i");
340 CORBA::String_var aName = theStudy->Name();
341 QAD_Desktop* aDesktop = QAD_Application::getDesktop();
342 myStudy = aDesktop->findStudy(theStudy);
344 aFileInfo.setFile(aName.in());
345 myStudy = aDesktop->loadStudy(aFileInfo.baseName());
347 if(MYDEBUG) MESSAGE("View_i::View_i - isStudyOpened = "<<myStudy<<"; aName = "<<aName.in());
351 if(MYDEBUG) MESSAGE("View_i::~View_i");
354 void View_i::SetBackground(const SALOMEDS::Color& theColor) {}
355 SALOMEDS::Color View_i::GetBackground() { return SALOMEDS::Color();}
356 void View_i::Minimize() {}
357 void View_i::Restore() {}
358 void View_i::Maximize() {}
359 void View_i::EraseAll() {}
360 void View_i::DisplayAll() {}
361 void View_i::Erase(PrsObject_ptr thePrsObj) {}
362 void View_i::Display(PrsObject_ptr thePrsObj) {}
363 void View_i::DisplayOnly(PrsObject_ptr thePrsObj) {}
364 void View_i::Update() {}
366 CORBA::Boolean View_i::SavePicture(const char* theFileName) { return false; }
368 const char* View_i::GetComment() const { return "";}
369 void View_i::ToStream(std::ostringstream& theStr) {}
371 const char* View_i::GetEntry(){
372 SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectIOR(GetID());
373 CORBA::String_var anEntry = aSObject->GetID();
374 string aString(anEntry);
375 if(MYDEBUG) MESSAGE("Result_i::GetEntry - "<<aString);
376 return aString.c_str();
378 //===========================================================================
379 XYPlot_i::XYPlot_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
380 if(MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
382 Storable* XYPlot_i::Create(int theNew){
383 if(MYDEBUG) MESSAGE("XYPlot_i::Create");
384 Mutex mt(myMutex,qApp,MYDELAY);
386 myStudyFrame = myStudy->newWindow3d("",VIEW_PLOT2D);
388 myStudyFrame = myStudy->getActiveStudyFrame();
389 myView = dynamic_cast<Plot2d_ViewFrame*>(myStudyFrame->getRightFrame()->getViewFrame());
393 void XYPlot_i::Update() {
394 if(MYDEBUG) MESSAGE("XYPlot_i::Update");
395 Mutex mt(myMutex,qApp,MYDELAY);
396 myName = (const char*)(myStudyFrame->title());
399 void XYPlot_i::Close(){
400 if(MYDEBUG) MESSAGE("XYPlot_i::Close");
401 Mutex mt(myMutex,qApp,MYDELAY);
402 myStudyFrame->close();
404 XYPlot_i::~XYPlot_i() {
405 if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
406 Mutex mt(myMutex,qApp,MYDELAY);
407 myStudyFrame->close();
409 void XYPlot_i::SetTitle(const char* theTitle){
410 if(MYDEBUG) MESSAGE("XYPlot_i::SetTitle");
411 Mutex mt(myMutex,qApp,MYDELAY);
413 myStudyFrame->setCaption(myName.c_str());
415 char* XYPlot_i::GetTitle() {
416 if(MYDEBUG) MESSAGE("XYPlot_i::GetTitle");
417 Mutex mt(myMutex,qApp);
418 myName = (const char*)(myStudyFrame->title());
419 return CORBA::string_dup(myName.c_str());
422 void XYPlot_i::SetSubTitle(const char* theTitle){
423 if(MYDEBUG) MESSAGE("XYPlot_i::SetSubTitle");
424 Mutex mt(myMutex,qApp,MYDELAY);
425 myView->setTitle(theTitle);
427 char* XYPlot_i::GetSubTitle() {
428 if(MYDEBUG) MESSAGE("XYPlot_i::GetSubTitle");
429 Mutex mt(myMutex,qApp,MYDELAY);
430 return CORBA::string_dup(myView->getTitle());
433 void XYPlot_i::SetCurveType(VISU::XYPlot::CurveType theType){
434 if(MYDEBUG) MESSAGE("XYPlot_i::SetCurveType");
435 Mutex mt(myMutex,qApp,MYDELAY);
436 myView->setCurveType(theType);
438 VISU::XYPlot::CurveType XYPlot_i::GetCurveType(){
439 if(MYDEBUG) MESSAGE("XYPlot_i::GetCurveType");
440 Mutex mt(myMutex,qApp);
441 return (VISU::XYPlot::CurveType)myView->getCurveType();
444 void XYPlot_i::SetMarkerSize(CORBA::Long theSize){
445 if(MYDEBUG) MESSAGE("XYPlot_i::SetMarkerSize");
446 Mutex mt(myMutex,qApp,MYDELAY);
447 myView->setMarkerSize(theSize);
449 CORBA::Long XYPlot_i::GetMarkerSize(){
450 if(MYDEBUG) MESSAGE("XYPlot_i::GetMarkerSize");
451 Mutex mt(myMutex,qApp);
452 return myView->getMarkerSize();
455 void XYPlot_i::EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
456 CORBA::Boolean theMinor, CORBA::Long theNumMinor){
457 if(MYDEBUG) MESSAGE("XYPlot_i::EnableXGrid");
458 Mutex mt(myMutex,qApp,MYDELAY);
459 myView->setXGrid(theMajor,theNumMajor,theMinor,theNumMinor);
461 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
462 CORBA::Boolean theMinor, CORBA::Long theNumMinor){
463 if(MYDEBUG) MESSAGE("XYPlot_i::EnableYGrid");
464 Mutex mt(myMutex,qApp,MYDELAY);
465 myView->setYGrid(theMajor,theNumMajor,theMinor,theNumMinor);
468 void XYPlot_i::SetHorScaling(VISU::Scaling theScaling){
469 if(MYDEBUG) MESSAGE("XYPlot_i::SetHorScaling");
470 Mutex mt(myMutex,qApp,MYDELAY);
471 if(theScaling == VISU::LOGARITHMIC)
472 myView->setHorScaleMode(1);
474 myView->setHorScaleMode(0);
476 VISU::Scaling XYPlot_i::GetHorScaling(){
477 if(MYDEBUG) MESSAGE("XYPlot_i::GetHorScaling");
478 Mutex mt(myMutex,qApp,MYDELAY);
479 return (VISU::Scaling)myView->getHorScaleMode();
482 void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){
483 if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling");
484 Mutex mt(myMutex,qApp,MYDELAY);
485 if(theScaling == VISU::LOGARITHMIC)
486 myView->setVerScaleMode(1);
488 myView->setVerScaleMode(0);
490 VISU::Scaling XYPlot_i::GetVerScaling(){
491 if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling");
492 Mutex mt(myMutex,qApp);
493 return (VISU::Scaling)myView->getVerScaleMode();
496 void XYPlot_i::SetXTitle(const char* theTitle){
497 if(MYDEBUG) MESSAGE("XYPlot_i::SetXTitle");
498 Mutex mt(myMutex,qApp,MYDELAY);
499 myView->setXTitle(true,theTitle);
501 char* XYPlot_i::GetXTitle() {
502 if(MYDEBUG) MESSAGE("XYPlot_i::GetXTitle");
503 Mutex mt(myMutex,qApp);
504 return CORBA::string_dup(myView->getXTitle());
507 void XYPlot_i::SetYTitle(const char* theTitle){
508 if(MYDEBUG) MESSAGE("XYPlot_i::SetYTitle");
509 Mutex mt(myMutex,qApp,MYDELAY);
510 myView->setYTitle(true,theTitle);
512 char* XYPlot_i::GetYTitle() {
513 if(MYDEBUG) MESSAGE("XYPlot_i::GetYTitle");
514 Mutex mt(myMutex,qApp);
515 return CORBA::string_dup(myView->getYTitle());
518 void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){
519 if(MYDEBUG) MESSAGE("XYPlot_i::ShowLegend");
520 Mutex mt(myMutex,qApp,MYDELAY);
521 myView->showLegend(theShowing);
524 void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){
525 if(MYDEBUG) MESSAGE("XYPlot_i::SetBackground");
526 Mutex mt(myMutex,qApp,MYDELAY);
528 aColor[0] = (int)(255.0*theColor.R);
529 aColor[1] = (int)(255.0*theColor.G);
530 aColor[2] = (int)(255.0*theColor.B);
531 QColor aNewColor(aColor[0],aColor[1],aColor[2]);
532 myView->setBackgroundColor(aNewColor);
534 SALOMEDS::Color XYPlot_i::GetBackground() {
535 if(MYDEBUG) MESSAGE("XYPlot_i::GetBackground");
536 Mutex mt(myMutex,qApp);
537 SALOMEDS::Color aColor;
538 aColor.R = myView->backgroundColor().red()/255.0;
539 aColor.G = myView->backgroundColor().green()/255.0;
540 aColor.B = myView->backgroundColor().blue()/255.0;
543 void XYPlot_i::Minimize() {
544 if(MYDEBUG) MESSAGE("XYPlot_i::Minimize");
545 Mutex mt(myMutex,qApp,MYDELAY);
546 myStudyFrame->showMinimized();
548 void XYPlot_i::Restore() {
549 if(MYDEBUG) MESSAGE("XYPlot_i::Restore");
550 Mutex mt(myMutex,qApp,MYDELAY);
551 myStudyFrame->showNormal();
553 void XYPlot_i::Maximize() {
554 if(MYDEBUG) MESSAGE("XYPlot_i::Maximize");
555 Mutex mt(myMutex,qApp,MYDELAY);
556 myStudyFrame->showMaximized();
558 void XYPlot_i::Display(PrsObject_ptr thePrsObj) {
559 if(MYDEBUG) MESSAGE("XYPlot_i::Display");
560 Mutex mt(myMutex,qApp,MYDELAY);
561 CORBA::Object_ptr anObj = thePrsObj;
563 if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
564 UpdatePlot2d(myView,eDisplay,aCurve);
567 if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
568 int nbCurves = aContainer->GetNbCurves();
569 for ( int i = 1; i <= nbCurves; i++ ) {
570 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
571 if ( aCurve && aCurve->IsValid() ) {
572 UpdatePlot2d(myView,eDisplay,aCurve);
578 if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
579 SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
580 if ( !TableSO->_is_nil() ) {
581 SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
582 for ( ; Iter->More(); Iter->Next() ) {
583 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
584 if( !CORBA::is_nil( childObject ) ) {
585 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
586 if( !CORBA::is_nil( aCurve ) )
587 UpdatePlot2d(myView,eDisplay,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
594 void XYPlot_i::Erase(PrsObject_ptr thePrsObj) {
595 if(MYDEBUG) MESSAGE("XYPlot_i::Erase");
596 Mutex mt(myMutex,qApp,MYDELAY);
597 CORBA::Object_ptr anObj = thePrsObj;
599 if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
600 UpdatePlot2d(myView,eErase,aCurve);
603 if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
604 int nbCurves = aContainer->GetNbCurves();
605 for ( int i = 1; i <= nbCurves; i++ ) {
606 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
607 if ( aCurve && aCurve->IsValid() ) {
608 UpdatePlot2d(myView,eErase,aCurve);
614 if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
615 SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
616 if ( !TableSO->_is_nil() ) {
617 SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
618 for ( ; Iter->More(); Iter->Next() ) {
619 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
620 if( !CORBA::is_nil( childObject ) ) {
621 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
622 if( !CORBA::is_nil( aCurve ) )
623 UpdatePlot2d(myView,eErase,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
630 void XYPlot_i::EraseAll() {
631 if(MYDEBUG) MESSAGE("XYPlot_i::EraseAll");
632 Mutex mt(myMutex,qApp,MYDELAY);
635 void XYPlot_i::DisplayOnly(PrsObject_ptr thePrsObj) {
636 if(MYDEBUG) MESSAGE("XYPlot_i::DisplayOnly");
637 Mutex mt(myMutex,qApp,MYDELAY);
638 CORBA::Object_ptr anObj = thePrsObj;
640 if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
641 UpdatePlot2d(myView,eDisplayOnly,aCurve);
644 if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
645 int nbCurves = aContainer->GetNbCurves();
646 for ( int i = 1; i <= nbCurves; i++ ) {
647 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
648 if ( aCurve && aCurve->IsValid() ) {
649 UpdatePlot2d(myView,eDisplayOnly,aCurve);
655 if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
656 SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
657 if ( !TableSO->_is_nil() ) {
658 SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
659 for ( ; Iter->More(); Iter->Next() ) {
660 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
661 if( !CORBA::is_nil( childObject ) ) {
662 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
663 if( !CORBA::is_nil( aCurve ) )
664 UpdatePlot2d(myView,eDisplayOnly,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
671 void XYPlot_i::FitAll() {
672 if(MYDEBUG) MESSAGE("XYPlot_i::FitAll");
673 Mutex mt(myMutex,qApp,MYDELAY);
676 CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) {
677 if(MYDEBUG) MESSAGE("XYPlot_i::SavePicture");
678 Mutex mt(myMutex,qApp,MYDELAY);
679 if (!myView->getViewWidget())
682 QApplication::setOverrideCursor( Qt::waitCursor );
683 QPixmap px = QPixmap::grabWindow(myView->getViewWidget()->winId());
684 QApplication::restoreOverrideCursor();
686 if (!QString(theFileName).isNull()) {
687 QApplication::setOverrideCursor( Qt::waitCursor );
688 QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper();
690 fmt = QString("BMP"); // default format
693 bool bOk = px.save(theFileName, fmt.latin1());
694 QApplication::restoreOverrideCursor();
700 //===========================================================================
701 TableView_i::TableView_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {}
702 Storable* TableView_i::Create(VISU::Table_var theTable){
703 if(MYDEBUG) MESSAGE("TableView_i::Create - "<<(!theTable->_is_nil()));
704 Mutex mt(myMutex,qApp,MYDELAY);
705 if(!theTable->_is_nil()){
706 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable.in()));
707 if(MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = "<<table);
709 SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectID(table->GetObjectEntry());
710 if(!aSObject->_is_nil()) {
711 myView = new SALOMEGUI_TableDlg(QAD_Application::getDesktop(),
714 SALOMEGUI_TableDlg::ttAuto,
717 myName = (myView->caption()).latin1();
724 void TableView_i::SetTitle(const char* theTitle){
725 if(MYDEBUG) MESSAGE("TableView_i::SetTitle");
726 Mutex mt(myMutex,qApp,MYDELAY);
728 myView->setCaption(myName.c_str());
730 char* TableView_i::GetTitle() {
731 if(MYDEBUG) MESSAGE("TableView_i::GetTitle");
732 Mutex mt(myMutex,qApp);
733 myName = (myView->caption()).latin1();
734 return CORBA::string_dup(myName.c_str());
736 void TableView_i::Close(){
737 if(MYDEBUG) MESSAGE("TableView_i::Close");
738 Mutex mt(myMutex,qApp,MYDELAY);
741 TableView_i::~TableView_i() {
742 if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
743 Mutex mt(myMutex,qApp,MYDELAY);
747 //===========================================================================
748 int View3D_i::myNbViewParams = 0;
749 const string View3D_i::myComment = "VIEW3D";
750 const char* View3D_i::GetComment() const { return myComment.c_str();}
751 QString View3D_i::GenerateViewParamsName() {
752 return VISU::GenerateName( "ViewParams", ++myNbViewParams );
755 View3D_i::View3D_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
756 if(MYDEBUG) MESSAGE("View3D_i::View3D_i");
759 Storable* View3D_i::Create(int theNew){
760 if(MYDEBUG) MESSAGE("View3D_i::Create");
762 myStudyFrame = myStudy->newWindow3d("",VIEW_VTK);
764 myStudyFrame = myStudy->getActiveStudyFrame();
766 //GetViewFrame(myStudyFrame)->GetScale(myScaleFactor);
768 return this; //Build(false);
771 // Storable* View3D_i::Build(int theRestoring){
772 // if(MYDEBUG) MESSAGE("View3D_i::Build");
774 // myStudyFrame->setTitle(myName.c_str());
775 // SetBackground(myColor);
776 // SetPointOfView(myPosition);
777 // SetViewUp(myViewUp);
778 // SetFocalPoint(myFocalPnt);
779 // SetParallelScale(myParallelScale);
780 // ScaleView(VISU::View3D::XAxis,myScaleFactor[0]);
781 // ScaleView(VISU::View3D::YAxis,myScaleFactor[1]);
782 // ScaleView(VISU::View3D::ZAxis,myScaleFactor[2]);
783 // RepaintView(myStudyFrame);
787 // SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(myStudyDocument);
788 // CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID());
789 // string anEntry = CreateAttributes(myStudyDocument,aSComponentEntry,"",anIOR,myName.c_str(),"",GetComment());
795 void View3D_i::Update(){
796 if(MYDEBUG) MESSAGE("View3D_i::Update");
797 Mutex mt(myMutex,qApp,MYDELAY);
798 myName = (const char*)myStudyFrame->title();
799 // myColor = GetBackground();
800 // GetCamera(myStudyFrame)->GetPosition(myPosition);
801 // GetCamera(myStudyFrame)->GetViewUp(myViewUp);
802 // GetCamera(myStudyFrame)->GetFocalPoint(myFocalPnt);
803 // myParallelScale = GetCamera(myStudyFrame)->GetParallelScale();
804 //RepaintView(myStudyFrame);
806 //GetViewFrame(myStudyFrame)->GetScale(myScaleFactor);
808 VTKViewer_ViewFrame* vf = GetViewFrame(myStudyFrame);
809 vtkRenderer* Renderer = vf->getRenderer();
810 vtkActorCollection* theActors = Renderer->GetActors();
811 theActors->InitTraversal();
813 while(actor = theActors->GetNextActor()){
814 if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(actor)){
815 VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d();
816 if(anActor->GetVisibility() && aPrs3d){
818 aPrs3d->UpdateActor(anActor);
824 CORBA::Boolean View3D_i::SavePicture(const char* theFileName) {
825 if(MYDEBUG) MESSAGE("View3D_i::SavePicture");
826 Mutex mt(myMutex,qApp,MYDELAY);
827 if (!myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget())
830 QApplication::setOverrideCursor( Qt::waitCursor );
831 QPixmap px = QPixmap::grabWindow(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget()->winId());
832 QApplication::restoreOverrideCursor();
834 if (!QString(theFileName).isNull()) {
835 QApplication::setOverrideCursor( Qt::waitCursor );
836 QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper();
838 fmt = QString("BMP"); // default format
841 bool bOk = px.save(theFileName, fmt.latin1());
842 QApplication::restoreOverrideCursor();
848 CORBA::Boolean View3D_i::SaveViewParams(const char* theName){
849 if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint");
850 Mutex mt(myMutex,qApp,MYDELAY);
852 SALOMEDS::Study::ListOfSObject_var aList =
853 myStudy->getStudyDocument()->FindObjectByName(theName,"VISU");
854 SALOMEDS::GenericAttribute_var anAttr;
855 int iEnd = aList->length();
856 for(int i = 0; i < iEnd; i++){
857 SALOMEDS::SObject_var anObj = aList[i];
858 CORBA::String_var aString = anObj->GetID();
859 string anEntry(aString);
860 if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - anEntry = "<<anEntry);
861 if(anObj->FindAttribute(anAttr, "AttributeComment")){
862 SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
863 aString = aCmnt->Value();
864 string aComm(aString);
865 if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = "<<aComm);
866 if(aComm.compare(View3D_i::myComment) >= 0){
867 aCmnt->SetValue(ToString().c_str());
875 newName = QString( theName );
877 newName = QString( GenerateViewParamsName() );
878 SALOMEDS::SComponent_var aSComponent =
879 FindOrCreateVisuComponent(myStudy->getStudyDocument());
880 CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID());
881 string anEntry = CreateAttributes(myStudy->getStudyDocument(),aSComponentEntry,"","",newName.latin1(),"",ToString().c_str());
885 CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){
886 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - "<<theName);
887 Mutex mt(myMutex,qApp,MYDELAY);
888 SALOMEDS::Study::ListOfSObject_var aList =
889 myStudy->getStudyDocument()->FindObjectByName(theName,"VISU");
890 SALOMEDS::GenericAttribute_var anAttr;
891 int iEnd = aList->length();
892 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = "<<iEnd);
893 for(int i = 0; i < iEnd; i++){
894 SALOMEDS::SObject_var anObj = aList[i];
895 CORBA::String_var aString = anObj->GetID();
896 string anEntry(aString);
897 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = "<<anEntry);
898 if(anObj->FindAttribute(anAttr, "AttributeComment")){
899 SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
900 aString = aCmnt->Value();
901 QString strIn(aString);
902 Storable::TRestoringMap aMap;
903 Storable::StrToMap(strIn,aMap);
904 if ( Storable::FindValue( aMap,"myComment").compare( View3D_i::myComment.c_str() ) >= 0 ) {
905 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = "<<strIn);
906 return Restore( aMap ) != NULL;
913 Storable* View3D_i::Restore(const Storable::TRestoringMap& theMap) throw(std::logic_error&) {
914 // if(MYDEBUG) MESSAGE("View3D_i::Restore");
915 //myName = VISU::Storable::FindValue(theMap,"myName").latin1();
917 SALOMEDS::Color aColor;
918 aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
919 aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
920 aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
923 aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
924 aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
925 aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
928 aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
929 aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
930 aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
933 aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
934 aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
935 aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
937 double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
939 double aScaleFactor[3];
940 aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
941 aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
942 aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
944 myStudyFrame->setTitle(myName.c_str());
945 SetBackground(aColor);
946 SetPointOfView(aPosition);
948 SetFocalPoint(aFocalPnt);
949 SetParallelScale(aParallelScale);
950 ScaleView(VISU::View3D::XAxis,aScaleFactor[0]);
951 ScaleView(VISU::View3D::YAxis,aScaleFactor[1]);
952 ScaleView(VISU::View3D::ZAxis,aScaleFactor[2]);
953 RepaintView(myStudyFrame);
958 void View3D_i::ToStream(std::ostringstream& theStr) {
959 Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
962 GetRenderer(myStudyFrame)->GetBackground(backint);
963 Storable::DataToStream(theStr,"myColor.R",backint[0]);
964 Storable::DataToStream(theStr,"myColor.G",backint[1]);
965 Storable::DataToStream(theStr,"myColor.B",backint[2]);
968 GetPointOfView(myStudyFrame,aPosition);
969 Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
970 Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
971 Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
974 GetFocalPoint(myStudyFrame,aFocalPnt);
975 Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
976 Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
977 Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
980 GetCamera(myStudyFrame)->GetViewUp(aViewUp);
981 Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
982 Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
983 Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
985 Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(myStudyFrame));
987 double aScaleFactor[3];
988 GetViewFrame(myStudyFrame)->GetScale(aScaleFactor);
989 Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
990 Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
991 Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
995 // Storable* VISU::View3DRestore(SALOMEDS::SComponent_var& theSComponent, SALOMEDS::Study_var& theStudy,
996 // const char* thePrefix, const Storable::TRestoringMap& theMap)
999 // View3D_i* pView3D = new View3D_i(theStudy);
1000 // return pView3D->Restore(theMap);
1001 // }catch(std::logic_error& exc){
1002 // MESSAGE("Follow exception was accured :\n"<<exc.what());
1004 // MESSAGE("Unknown exception was accured!");
1009 void View3D_i::Close(){
1010 if(MYDEBUG) MESSAGE("View3D_i::Close");
1011 Mutex mt(myMutex,qApp,MYDELAY);
1012 myStudyFrame->close();
1015 View3D_i::~View3D_i() {
1016 if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1017 Mutex mt(myMutex,qApp,MYDELAY);
1018 myStudyFrame->close();
1021 //-------------------- View interface --------------------
1022 void View3D_i::SetTitle(const char* theTitle){
1023 if(MYDEBUG) MESSAGE("View3D_i::SetTitle");
1024 Mutex mt(myMutex,qApp,MYDELAY);
1026 myStudyFrame->setTitle(myName.c_str());
1028 char* View3D_i::GetTitle() {
1029 if(MYDEBUG) MESSAGE("View3D_i::GetTitle");
1030 Mutex mt(myMutex,qApp,MYDELAY);
1031 myName = (const char*)myStudyFrame->title();
1032 return CORBA::string_dup(myName.c_str());
1035 void View3D_i::SetBackground(QAD_StudyFrame* theStudyFrame, const SALOMEDS::Color& theColor) {
1037 aColor[0] = (int)(255.0*theColor.R);
1038 aColor[1] = (int)(255.0*theColor.G);
1039 aColor[2] = (int)(255.0*theColor.B);
1040 QColor aNewColor(aColor[0],aColor[1],aColor[2]);
1041 GetViewFrame(theStudyFrame)->setBackgroundColor(aNewColor);
1043 void View3D_i::SetBackground(const SALOMEDS::Color& theColor) {
1044 if(MYDEBUG) MESSAGE("View3D_i::SetBackground");
1045 Mutex mt(myMutex,qApp,MYDELAY);
1046 //myColor.R = theColor.R; myColor.G = theColor.G; myColor.B = theColor.B;
1047 SetBackground(myStudyFrame,theColor);
1050 SALOMEDS::Color View3D_i::GetBackground(QAD_StudyFrame* theStudyFrame) {
1051 SALOMEDS::Color aColor;
1053 GetRenderer(theStudyFrame)->GetBackground(backint);
1054 aColor.R = backint[0]; aColor.G = backint[1]; aColor.B = backint[2];
1057 SALOMEDS::Color View3D_i::GetBackground() {
1058 if(MYDEBUG) MESSAGE("View3D_i::GetBackground");
1059 Mutex mt(myMutex,qApp,MYDELAY);
1060 //myColor = GetBackground(myStudyFrame);
1061 return GetBackground(myStudyFrame); //myColor;
1064 void View3D_i::Minimize() {
1065 if(MYDEBUG) MESSAGE("View3D_i::Minimize");
1066 Mutex mt(myMutex,qApp,MYDELAY);
1067 myStudyFrame->showMinimized();
1069 void View3D_i::Restore() {
1070 if(MYDEBUG) MESSAGE("View3D_i::Restore");
1071 Mutex mt(myMutex,qApp,MYDELAY);
1072 myStudyFrame->showNormal();
1074 void View3D_i::Maximize() {
1075 if(MYDEBUG) MESSAGE("View3D_i::Maximize");
1076 Mutex mt(myMutex,qApp,MYDELAY);
1077 myStudyFrame->showMaximized();
1079 //===========================================================================
1080 void View3D_i::EraseAll() {
1081 if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1082 Mutex mt(myMutex,qApp,MYDELAY);
1083 UpdateViewer(myStudyFrame,eEraseAll);
1085 void View3D_i::DisplayAll() {
1086 if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1087 Mutex mt(myMutex,qApp,MYDELAY);
1088 UpdateViewer(myStudyFrame,eDisplayAll);
1090 void View3D_i::Erase(PrsObject_ptr thePrsObj) {
1091 if(MYDEBUG) MESSAGE("View3D_i::Erase");
1092 Mutex mt(myMutex,qApp,MYDELAY);
1093 CORBA::Object_ptr anObj = thePrsObj;
1094 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
1095 UpdateViewer(myStudyFrame,eErase,aPrs);
1097 void View3D_i::Display(PrsObject_ptr thePrsObj) {
1098 if(MYDEBUG) MESSAGE("View3D_i::Display");
1099 Mutex mt(myMutex,qApp,MYDELAY);
1100 CORBA::Object_ptr anObj = thePrsObj;
1101 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
1102 UpdateViewer(myStudyFrame,eDisplay,aPrs);
1104 void View3D_i::DisplayOnly(PrsObject_ptr thePrsObj) {
1105 if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
1106 Mutex mt(myMutex,qApp,MYDELAY);
1107 CORBA::Object_ptr anObj = thePrsObj;
1108 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
1109 UpdateViewer(myStudyFrame,eDisplayOnly,aPrs);
1112 //-------------------- View3D interface --------------------
1113 void View3D_i::FitAll() {
1114 if(MYDEBUG) MESSAGE("View3D_i::FitAll");
1115 Mutex mt(myMutex,qApp,MYDELAY);
1116 GetViewFrame(myStudyFrame)->onViewFitAll();
1119 void View3D_i::SetView(VISU::View3D::ViewType theType) {
1120 if(MYDEBUG) MESSAGE("View3D_i::SetView");
1121 Mutex mt(myMutex,qApp,MYDELAY);
1123 case VISU::View3D::FRONT : GetViewFrame(myStudyFrame)->onViewFront(); break;
1124 case VISU::View3D::BACK : GetViewFrame(myStudyFrame)->onViewBack(); break;
1125 case VISU::View3D::LEFT : GetViewFrame(myStudyFrame)->onViewLeft(); break;
1126 case VISU::View3D::RIGHT : GetViewFrame(myStudyFrame)->onViewRight(); break;
1127 case VISU::View3D::TOP : GetViewFrame(myStudyFrame)->onViewTop(); break;
1128 case VISU::View3D::BOTTOM : GetViewFrame(myStudyFrame)->onViewBottom(); break;
1133 void View3D_i::SetPointOfView(QAD_StudyFrame* theStudyFrame, const CORBA::Double thePosition[3]) {
1134 GetCamera(theStudyFrame)->SetPosition(thePosition);
1136 void View3D_i::SetPointOfView(const VISU::View3D::XYZ theCoord) {
1137 if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
1138 Mutex mt(myMutex,qApp,MYDELAY);
1139 //VISU::View3D::XYZ_copy(myPosition,theCoord);
1140 SetPointOfView(myStudyFrame, theCoord);
1143 void View3D_i::GetPointOfView(QAD_StudyFrame* theStudyFrame, CORBA::Double thePosition[3]) {
1144 GetCamera(theStudyFrame)->GetPosition(thePosition);
1146 VISU::View3D::XYZ_slice* View3D_i::GetPointOfView() {
1147 if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
1148 Mutex mt(myMutex,qApp,MYDELAY);
1149 CORBA::Double aPosition[3];
1150 GetPointOfView(myStudyFrame,aPosition);
1151 return VISU::View3D::XYZ_dup(aPosition);
1154 void View3D_i::SetViewUp(QAD_StudyFrame* theStudyFrame, const CORBA::Double theViewUp[3]) {
1155 GetCamera(theStudyFrame)->SetViewUp(theViewUp);
1157 void View3D_i::SetViewUp(const VISU::View3D::XYZ theDir) {
1158 if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
1159 Mutex mt(myMutex,qApp,MYDELAY);
1160 //VISU::View3D::XYZ_copy(myViewUp,theDir);
1161 SetViewUp(myStudyFrame, theDir);
1164 void View3D_i::GetViewUp(QAD_StudyFrame* theStudyFrame, CORBA::Double theViewUp[3]) {
1165 GetCamera(theStudyFrame)->GetViewUp(theViewUp);
1167 VISU::View3D::XYZ_slice* View3D_i::GetViewUp() {
1168 if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
1169 Mutex mt(myMutex,qApp,MYDELAY);
1170 CORBA::Double aViewUp[3];
1171 GetCamera(myStudyFrame)->GetViewUp(aViewUp);
1172 return VISU::View3D::XYZ_dup(aViewUp);
1175 void View3D_i::SetFocalPoint(QAD_StudyFrame* theStudyFrame, const CORBA::Double theFocalPnt[3]) {
1176 GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt);
1178 void View3D_i::SetFocalPoint(const VISU::View3D::XYZ theCoord) {
1179 if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
1180 Mutex mt(myMutex,qApp,MYDELAY);
1181 //VISU::View3D::XYZ_copy(myFocalPnt,theCoord);
1182 SetFocalPoint(myStudyFrame,theCoord);
1185 void View3D_i::GetFocalPoint(QAD_StudyFrame* theStudyFrame, CORBA::Double theFocalPnt[3]) {
1186 GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt);
1188 VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint() {
1189 if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
1190 Mutex mt(myMutex,qApp,MYDELAY);
1191 CORBA::Double aFocalPnt[3];
1192 GetFocalPoint(myStudyFrame,aFocalPnt);
1193 return VISU::View3D::XYZ_dup(aFocalPnt);
1196 void View3D_i::SetParallelScale(QAD_StudyFrame* theStudyFrame, CORBA::Double theScale) {
1197 GetCamera(theStudyFrame)->SetParallelScale(theScale);
1199 void View3D_i::SetParallelScale(CORBA::Double theScale) {
1200 if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
1201 Mutex mt(myMutex,qApp,MYDELAY);
1202 //myParallelScale = theScale;
1203 SetParallelScale(myStudyFrame, theScale);
1206 CORBA::Double View3D_i::GetParallelScale(QAD_StudyFrame* theStudyFrame) {
1207 return GetCamera(theStudyFrame)->GetParallelScale();
1209 CORBA::Double View3D_i::GetParallelScale() {
1210 if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
1211 Mutex mt(myMutex,qApp);
1212 return GetParallelScale(myStudyFrame);
1215 void View3D_i::ScaleView(QAD_StudyFrame* theStudyFrame, VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1216 VTKViewer_ViewFrame* aViewFrame = GetViewFrame(theStudyFrame);
1217 double aScaleFactor[3];
1218 aViewFrame->GetScale(aScaleFactor);
1219 aScaleFactor[theAxis] = theParam;
1220 aViewFrame->SetScale(aScaleFactor);
1222 void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1223 if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
1224 Mutex mt(myMutex,qApp);
1225 //myScaleFactor[theAxis] = theParam;
1226 ScaleView(myStudyFrame,theAxis,theParam);
1228 void View3D_i::RemoveScale() {
1229 if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
1230 Mutex mt(myMutex,qApp);
1231 double aScaleFactor[]={1,1,1};
1232 //myScaleFactor[0] = myScaleFactor[0] = myScaleFactor[0] = 1.0;
1233 GetViewFrame(myStudyFrame)->SetScale(aScaleFactor);
1235 //===========================================================================