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){
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 if (aFileInfo.exists())
248 aStudy = aDesktop->loadStudy(aFileInfo.baseName());
249 else aStudy = aDesktop->loadStudy(aName.in());
251 MESSAGE("ViewManager_i::ERROR: Can't load study");
256 VISU::View3D_ptr ViewManager_i::Create3DView(){
257 Mutex mt(myMutex,qApp,MYDELAY);
258 if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
259 VISU::View3D_i* pView = new View3D_i(myStudyDocument);
260 if(pView->Create(1) != NULL)
261 return VISU::View3D::_duplicate(pView->_this());
262 return VISU::View3D::_nil();
266 VISU::View_ptr ViewManager_i::GetCurrentView(){
267 Mutex mt(myMutex,qApp,MYDELAY);
268 QAD_Study* Study = QAD_Application::getDesktop()->findStudy( myStudyDocument );
269 if(MYDEBUG) MESSAGE("ViewManager_i::GetCurrent3DView - Study = "<<Study);
270 QAD_StudyFrame* StudyFrame;
271 if ( Study && ( StudyFrame = Study->getActiveStudyFrame() ) ) {
273 MESSAGE("ViewManager_i::GetCurrent3DView - TypeView = "<<StudyFrame->getTypeView());
274 if ( StudyFrame->getTypeView() == VIEW_VTK ) {
275 VISU::View3D_i* pView = new View3D_i(myStudyDocument);
276 if(pView->Create(0) != NULL)
277 return VISU::View3D::_duplicate(pView->_this());
279 else if ( StudyFrame->getTypeView() == VIEW_PLOT2D ) {
280 VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
281 if(pView->Create(0) != NULL)
282 return VISU::XYPlot::_duplicate(pView->_this());
285 return VISU::View::_nil();
289 VISU::XYPlot_ptr ViewManager_i::CreateXYPlot(){
290 if(MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot");
291 Mutex mt(myMutex,qApp,MYDELAY);
292 VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
293 if(pView->Create(1) != NULL)
294 return VISU::XYPlot::_duplicate(pView->_this());
295 return VISU::XYPlot::_nil();
299 VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){
300 if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
301 Mutex mt(myMutex,qApp,MYDELAY);
302 VISU::TableView_i* pView = new TableView_i(myStudyDocument);
303 if(pView->Create(VISU::Table::_duplicate(theTable)) != NULL)
304 return VISU::TableView::_duplicate(pView->_this());
305 return VISU::TableView::_nil();
309 void ViewManager_i::Destroy(View_ptr theView){
310 if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<<theView->_is_nil());
311 if(theView->_is_nil()) return;
312 CORBA::Object_var aView = VISU::View::_narrow(theView);
313 if(!CORBA::is_nil(aView)){
314 if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - VISU::View"<<(!CORBA::is_nil(aView)));
315 VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(aView).in());
316 if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - dynamic_cast"<<pView);
319 pView->_remove_ref();
321 //if(pView) delete pView;
327 void ViewManager_i::ProcessEvents() {
332 qApp->processEvents();
339 //===========================================================================
340 View_i::View_i(SALOMEDS::Study_ptr theStudy) {
341 if(MYDEBUG) MESSAGE("View_i::View_i");
342 CORBA::String_var aName = theStudy->Name();
343 QAD_Desktop* aDesktop = QAD_Application::getDesktop();
344 myStudy = aDesktop->findStudy(theStudy);
346 aFileInfo.setFile(aName.in());
347 if ( aFileInfo.exists() )
348 myStudy = aDesktop->loadStudy(aFileInfo.baseName());
349 else myStudy = aDesktop->loadStudy(aName.in());
351 if(MYDEBUG) MESSAGE("View_i::View_i - isStudyOpened = "<<myStudy<<"; aName = "<<aName.in());
355 if(MYDEBUG) MESSAGE("View_i::~View_i");
358 void View_i::SetBackground(const SALOMEDS::Color& theColor) {}
359 SALOMEDS::Color View_i::GetBackground() { return SALOMEDS::Color();}
360 void View_i::Minimize() {}
361 void View_i::Restore() {}
362 void View_i::Maximize() {}
363 void View_i::EraseAll() {}
364 void View_i::DisplayAll() {}
365 void View_i::Erase(PrsObject_ptr thePrsObj) {}
366 void View_i::Display(PrsObject_ptr thePrsObj) {}
367 void View_i::DisplayOnly(PrsObject_ptr thePrsObj) {}
368 void View_i::Update() {}
370 CORBA::Boolean View_i::SavePicture(const char* theFileName) { return false; }
372 const char* View_i::GetComment() const { return "";}
373 void View_i::ToStream(std::ostringstream& theStr) {}
375 const char* View_i::GetEntry(){
376 SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectIOR(GetID());
377 CORBA::String_var anEntry = aSObject->GetID();
378 string aString(anEntry);
379 if(MYDEBUG) MESSAGE("Result_i::GetEntry - "<<aString);
380 return aString.c_str();
382 //===========================================================================
383 XYPlot_i::XYPlot_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
384 if(MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
386 Storable* XYPlot_i::Create(int theNew){
387 if(MYDEBUG) MESSAGE("XYPlot_i::Create");
388 Mutex mt(myMutex,qApp,MYDELAY);
390 myStudyFrame = myStudy->newWindow3d("",VIEW_PLOT2D);
392 myStudyFrame = myStudy->getActiveStudyFrame();
393 myView = dynamic_cast<Plot2d_ViewFrame*>(myStudyFrame->getRightFrame()->getViewFrame());
397 void XYPlot_i::Update() {
398 if(MYDEBUG) MESSAGE("XYPlot_i::Update");
399 Mutex mt(myMutex,qApp,MYDELAY);
400 myName = (const char*)(myStudyFrame->title());
403 void XYPlot_i::Close(){
404 if(MYDEBUG) MESSAGE("XYPlot_i::Close");
405 Mutex mt(myMutex,qApp,MYDELAY);
406 myStudyFrame->close();
408 XYPlot_i::~XYPlot_i() {
409 if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
410 Mutex mt(myMutex,qApp,MYDELAY);
411 myStudyFrame->close();
413 void XYPlot_i::SetTitle(const char* theTitle){
414 if(MYDEBUG) MESSAGE("XYPlot_i::SetTitle");
415 Mutex mt(myMutex,qApp,MYDELAY);
417 myStudyFrame->setCaption(myName.c_str());
419 char* XYPlot_i::GetTitle() {
420 if(MYDEBUG) MESSAGE("XYPlot_i::GetTitle");
421 Mutex mt(myMutex,qApp);
422 myName = (const char*)(myStudyFrame->title());
423 return CORBA::string_dup(myName.c_str());
426 void XYPlot_i::SetSubTitle(const char* theTitle){
427 if(MYDEBUG) MESSAGE("XYPlot_i::SetSubTitle");
428 Mutex mt(myMutex,qApp,MYDELAY);
429 myView->setTitle(theTitle);
431 char* XYPlot_i::GetSubTitle() {
432 if(MYDEBUG) MESSAGE("XYPlot_i::GetSubTitle");
433 Mutex mt(myMutex,qApp,MYDELAY);
434 return CORBA::string_dup(myView->getTitle());
437 void XYPlot_i::SetCurveType(VISU::XYPlot::CurveType theType){
438 if(MYDEBUG) MESSAGE("XYPlot_i::SetCurveType");
439 Mutex mt(myMutex,qApp,MYDELAY);
440 myView->setCurveType(theType);
442 VISU::XYPlot::CurveType XYPlot_i::GetCurveType(){
443 if(MYDEBUG) MESSAGE("XYPlot_i::GetCurveType");
444 Mutex mt(myMutex,qApp);
445 return (VISU::XYPlot::CurveType)myView->getCurveType();
448 void XYPlot_i::SetMarkerSize(CORBA::Long theSize){
449 if(MYDEBUG) MESSAGE("XYPlot_i::SetMarkerSize");
450 Mutex mt(myMutex,qApp,MYDELAY);
451 myView->setMarkerSize(theSize);
453 CORBA::Long XYPlot_i::GetMarkerSize(){
454 if(MYDEBUG) MESSAGE("XYPlot_i::GetMarkerSize");
455 Mutex mt(myMutex,qApp);
456 return myView->getMarkerSize();
459 void XYPlot_i::EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
460 CORBA::Boolean theMinor, CORBA::Long theNumMinor){
461 if(MYDEBUG) MESSAGE("XYPlot_i::EnableXGrid");
462 Mutex mt(myMutex,qApp,MYDELAY);
463 myView->setXGrid(theMajor,theNumMajor,theMinor,theNumMinor);
465 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
466 CORBA::Boolean theMinor, CORBA::Long theNumMinor){
467 if(MYDEBUG) MESSAGE("XYPlot_i::EnableYGrid");
468 Mutex mt(myMutex,qApp,MYDELAY);
469 myView->setYGrid(theMajor,theNumMajor,theMinor,theNumMinor);
472 void XYPlot_i::SetHorScaling(VISU::Scaling theScaling){
473 if(MYDEBUG) MESSAGE("XYPlot_i::SetHorScaling");
474 Mutex mt(myMutex,qApp,MYDELAY);
475 if(theScaling == VISU::LOGARITHMIC)
476 myView->setHorScaleMode(1);
478 myView->setHorScaleMode(0);
480 VISU::Scaling XYPlot_i::GetHorScaling(){
481 if(MYDEBUG) MESSAGE("XYPlot_i::GetHorScaling");
482 Mutex mt(myMutex,qApp,MYDELAY);
483 return (VISU::Scaling)myView->getHorScaleMode();
486 void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){
487 if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling");
488 Mutex mt(myMutex,qApp,MYDELAY);
489 if(theScaling == VISU::LOGARITHMIC)
490 myView->setVerScaleMode(1);
492 myView->setVerScaleMode(0);
494 VISU::Scaling XYPlot_i::GetVerScaling(){
495 if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling");
496 Mutex mt(myMutex,qApp);
497 return (VISU::Scaling)myView->getVerScaleMode();
500 void XYPlot_i::SetXTitle(const char* theTitle){
501 if(MYDEBUG) MESSAGE("XYPlot_i::SetXTitle");
502 Mutex mt(myMutex,qApp,MYDELAY);
503 myView->setXTitle(true,theTitle);
505 char* XYPlot_i::GetXTitle() {
506 if(MYDEBUG) MESSAGE("XYPlot_i::GetXTitle");
507 Mutex mt(myMutex,qApp);
508 return CORBA::string_dup(myView->getXTitle());
511 void XYPlot_i::SetYTitle(const char* theTitle){
512 if(MYDEBUG) MESSAGE("XYPlot_i::SetYTitle");
513 Mutex mt(myMutex,qApp,MYDELAY);
514 myView->setYTitle(true,theTitle);
516 char* XYPlot_i::GetYTitle() {
517 if(MYDEBUG) MESSAGE("XYPlot_i::GetYTitle");
518 Mutex mt(myMutex,qApp);
519 return CORBA::string_dup(myView->getYTitle());
522 void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){
523 if(MYDEBUG) MESSAGE("XYPlot_i::ShowLegend");
524 Mutex mt(myMutex,qApp,MYDELAY);
525 myView->showLegend(theShowing);
528 void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){
529 if(MYDEBUG) MESSAGE("XYPlot_i::SetBackground");
530 Mutex mt(myMutex,qApp,MYDELAY);
532 aColor[0] = (int)(255.0*theColor.R);
533 aColor[1] = (int)(255.0*theColor.G);
534 aColor[2] = (int)(255.0*theColor.B);
535 QColor aNewColor(aColor[0],aColor[1],aColor[2]);
536 myView->setBackgroundColor(aNewColor);
538 SALOMEDS::Color XYPlot_i::GetBackground() {
539 if(MYDEBUG) MESSAGE("XYPlot_i::GetBackground");
540 Mutex mt(myMutex,qApp);
541 SALOMEDS::Color aColor;
542 aColor.R = myView->backgroundColor().red()/255.0;
543 aColor.G = myView->backgroundColor().green()/255.0;
544 aColor.B = myView->backgroundColor().blue()/255.0;
547 void XYPlot_i::Minimize() {
548 if(MYDEBUG) MESSAGE("XYPlot_i::Minimize");
549 Mutex mt(myMutex,qApp,MYDELAY);
550 myStudyFrame->showMinimized();
552 void XYPlot_i::Restore() {
553 if(MYDEBUG) MESSAGE("XYPlot_i::Restore");
554 Mutex mt(myMutex,qApp,MYDELAY);
555 myStudyFrame->showNormal();
557 void XYPlot_i::Maximize() {
558 if(MYDEBUG) MESSAGE("XYPlot_i::Maximize");
559 Mutex mt(myMutex,qApp,MYDELAY);
560 myStudyFrame->showMaximized();
562 void XYPlot_i::Display(PrsObject_ptr thePrsObj) {
563 if(MYDEBUG) MESSAGE("XYPlot_i::Display");
564 Mutex mt(myMutex,qApp,MYDELAY);
565 CORBA::Object_ptr anObj = thePrsObj;
567 if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj).in())) {
568 UpdatePlot2d(myView,eDisplay,aCurve);
571 if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj).in())) {
572 int nbCurves = aContainer->GetNbCurves();
573 for ( int i = 1; i <= nbCurves; i++ ) {
574 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
575 if ( aCurve && aCurve->IsValid() ) {
576 UpdatePlot2d(myView,eDisplay,aCurve);
582 if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj).in())) {
583 SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
584 if ( !TableSO->_is_nil() ) {
585 SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
586 for ( ; Iter->More(); Iter->Next() ) {
587 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
588 if( !CORBA::is_nil( childObject ) ) {
589 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
590 if( !CORBA::is_nil( aCurve ) )
591 UpdatePlot2d(myView,eDisplay,dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aCurve).in()));
598 void XYPlot_i::Erase(PrsObject_ptr thePrsObj) {
599 if(MYDEBUG) MESSAGE("XYPlot_i::Erase");
600 Mutex mt(myMutex,qApp,MYDELAY);
601 CORBA::Object_ptr anObj = thePrsObj;
603 if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj).in())) {
604 UpdatePlot2d(myView,eErase,aCurve);
607 if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj).in())) {
608 int nbCurves = aContainer->GetNbCurves();
609 for ( int i = 1; i <= nbCurves; i++ ) {
610 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
611 if ( aCurve && aCurve->IsValid() ) {
612 UpdatePlot2d(myView,eErase,aCurve);
618 if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj).in())) {
619 SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
620 if ( !TableSO->_is_nil() ) {
621 SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
622 for ( ; Iter->More(); Iter->Next() ) {
623 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
624 if( !CORBA::is_nil( childObject ) ) {
625 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
626 if( !CORBA::is_nil( aCurve ) )
627 UpdatePlot2d(myView,eErase,dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aCurve).in()));
634 void XYPlot_i::EraseAll() {
635 if(MYDEBUG) MESSAGE("XYPlot_i::EraseAll");
636 Mutex mt(myMutex,qApp,MYDELAY);
639 void XYPlot_i::DisplayOnly(PrsObject_ptr thePrsObj) {
640 if(MYDEBUG) MESSAGE("XYPlot_i::DisplayOnly");
641 Mutex mt(myMutex,qApp,MYDELAY);
642 CORBA::Object_ptr anObj = thePrsObj;
644 if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj).in())) {
645 UpdatePlot2d(myView,eDisplayOnly,aCurve);
648 if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj).in())) {
649 int nbCurves = aContainer->GetNbCurves();
650 for ( int i = 1; i <= nbCurves; i++ ) {
651 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
652 if ( aCurve && aCurve->IsValid() ) {
653 UpdatePlot2d(myView,eDisplayOnly,aCurve);
659 if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj).in())) {
660 SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
661 if ( !TableSO->_is_nil() ) {
662 SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
663 for ( ; Iter->More(); Iter->Next() ) {
664 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
665 if( !CORBA::is_nil( childObject ) ) {
666 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
667 if( !CORBA::is_nil( aCurve ) )
668 UpdatePlot2d(myView,eDisplayOnly,dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aCurve).in()));
675 void XYPlot_i::FitAll() {
676 if(MYDEBUG) MESSAGE("XYPlot_i::FitAll");
677 Mutex mt(myMutex,qApp,MYDELAY);
680 CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) {
681 if(MYDEBUG) MESSAGE("XYPlot_i::SavePicture");
682 Mutex mt(myMutex,qApp,MYDELAY);
683 if (!myView->getViewWidget())
686 QApplication::setOverrideCursor( Qt::waitCursor );
687 QPixmap px = QPixmap::grabWindow(myView->getViewWidget()->winId());
688 QApplication::restoreOverrideCursor();
690 if (!QString(theFileName).isNull()) {
691 QApplication::setOverrideCursor( Qt::waitCursor );
692 QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper();
694 fmt = QString("BMP"); // default format
697 bool bOk = px.save(theFileName, fmt.latin1());
698 QApplication::restoreOverrideCursor();
704 //===========================================================================
705 TableView_i::TableView_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {}
706 Storable* TableView_i::Create(VISU::Table_var theTable){
707 if(MYDEBUG) MESSAGE("TableView_i::Create - "<<(!theTable->_is_nil()));
708 Mutex mt(myMutex,qApp,MYDELAY);
709 if(!theTable->_is_nil()){
710 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable.in()).in());
711 if(MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = "<<table);
713 SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectID(table->GetObjectEntry());
714 if(!aSObject->_is_nil()) {
715 myView = new SALOMEGUI_TableDlg(QAD_Application::getDesktop(),
718 SALOMEGUI_TableDlg::ttAuto,
721 myName = (myView->caption()).latin1();
728 void TableView_i::SetTitle(const char* theTitle){
729 if(MYDEBUG) MESSAGE("TableView_i::SetTitle");
730 Mutex mt(myMutex,qApp,MYDELAY);
732 myView->setCaption(myName.c_str());
734 char* TableView_i::GetTitle() {
735 if(MYDEBUG) MESSAGE("TableView_i::GetTitle");
736 Mutex mt(myMutex,qApp);
737 myName = (myView->caption()).latin1();
738 return CORBA::string_dup(myName.c_str());
740 void TableView_i::Close(){
741 if(MYDEBUG) MESSAGE("TableView_i::Close");
742 Mutex mt(myMutex,qApp,MYDELAY);
745 TableView_i::~TableView_i() {
746 if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
747 Mutex mt(myMutex,qApp,MYDELAY);
751 //===========================================================================
752 int View3D_i::myNbViewParams = 0;
753 const string View3D_i::myComment = "VIEW3D";
754 const char* View3D_i::GetComment() const { return myComment.c_str();}
755 QString View3D_i::GenerateViewParamsName() {
756 return VISU::GenerateName( "ViewParams", ++myNbViewParams );
759 View3D_i::View3D_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
760 if(MYDEBUG) MESSAGE("View3D_i::View3D_i");
763 Storable* View3D_i::Create(int theNew){
764 if(MYDEBUG) MESSAGE("View3D_i::Create");
766 myStudyFrame = myStudy->newWindow3d("",VIEW_VTK);
768 myStudyFrame = myStudy->getActiveStudyFrame();
770 //GetViewFrame(myStudyFrame)->GetScale(myScaleFactor);
772 return this; //Build(false);
775 // Storable* View3D_i::Build(int theRestoring){
776 // if(MYDEBUG) MESSAGE("View3D_i::Build");
778 // myStudyFrame->setTitle(myName.c_str());
779 // SetBackground(myColor);
780 // SetPointOfView(myPosition);
781 // SetViewUp(myViewUp);
782 // SetFocalPoint(myFocalPnt);
783 // SetParallelScale(myParallelScale);
784 // ScaleView(VISU::View3D::XAxis,myScaleFactor[0]);
785 // ScaleView(VISU::View3D::YAxis,myScaleFactor[1]);
786 // ScaleView(VISU::View3D::ZAxis,myScaleFactor[2]);
787 // RepaintView(myStudyFrame);
791 // SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(myStudyDocument);
792 // CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID());
793 // string anEntry = CreateAttributes(myStudyDocument,aSComponentEntry,"",anIOR,myName.c_str(),"",GetComment());
799 void View3D_i::Update(){
800 if(MYDEBUG) MESSAGE("View3D_i::Update");
801 Mutex mt(myMutex,qApp,MYDELAY);
802 myName = (const char*)myStudyFrame->title();
803 // myColor = GetBackground();
804 // GetCamera(myStudyFrame)->GetPosition(myPosition);
805 // GetCamera(myStudyFrame)->GetViewUp(myViewUp);
806 // GetCamera(myStudyFrame)->GetFocalPoint(myFocalPnt);
807 // myParallelScale = GetCamera(myStudyFrame)->GetParallelScale();
808 //RepaintView(myStudyFrame);
810 //GetViewFrame(myStudyFrame)->GetScale(myScaleFactor);
812 VTKViewer_ViewFrame* vf = GetViewFrame(myStudyFrame);
813 vtkRenderer* Renderer = vf->getRenderer();
814 vtkActorCollection* theActors = Renderer->GetActors();
815 theActors->InitTraversal();
817 while(actor = theActors->GetNextActor()){
818 if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(actor)){
819 VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d();
820 if(anActor->GetVisibility() && aPrs3d){
822 aPrs3d->UpdateActor(anActor);
828 CORBA::Boolean View3D_i::SavePicture(const char* theFileName) {
829 if(MYDEBUG) MESSAGE("View3D_i::SavePicture");
830 Mutex mt(myMutex,qApp,MYDELAY);
831 if (!myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget())
834 QApplication::setOverrideCursor( Qt::waitCursor );
835 QPixmap px = QPixmap::grabWindow(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget()->winId());
836 QApplication::restoreOverrideCursor();
838 if (!QString(theFileName).isNull()) {
839 QApplication::setOverrideCursor( Qt::waitCursor );
840 QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper();
842 fmt = QString("BMP"); // default format
845 bool bOk = px.save(theFileName, fmt.latin1());
846 QApplication::restoreOverrideCursor();
852 CORBA::Boolean View3D_i::SaveViewParams(const char* theName){
853 if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint");
854 Mutex mt(myMutex,qApp,MYDELAY);
856 SALOMEDS::Study::ListOfSObject_var aList =
857 myStudy->getStudyDocument()->FindObjectByName(theName,"VISU");
858 SALOMEDS::GenericAttribute_var anAttr;
859 int iEnd = aList->length();
860 for(int i = 0; i < iEnd; i++){
861 SALOMEDS::SObject_var anObj = aList[i];
862 CORBA::String_var aString = anObj->GetID();
863 string anEntry(aString);
864 if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - anEntry = "<<anEntry);
865 if(anObj->FindAttribute(anAttr, "AttributeComment")){
866 SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
867 aString = aCmnt->Value();
868 string aComm(aString);
869 if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = "<<aComm);
870 if(aComm.compare(View3D_i::myComment) >= 0){
871 aCmnt->SetValue(ToString().c_str());
879 newName = QString( theName );
881 newName = QString( GenerateViewParamsName() );
882 SALOMEDS::SComponent_var aSComponent =
883 FindOrCreateVisuComponent(myStudy->getStudyDocument());
884 CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID());
885 string anEntry = CreateAttributes(myStudy->getStudyDocument(),aSComponentEntry,"","",newName.latin1(),"",ToString().c_str());
889 CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){
890 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - "<<theName);
891 Mutex mt(myMutex,qApp,MYDELAY);
892 SALOMEDS::Study::ListOfSObject_var aList =
893 myStudy->getStudyDocument()->FindObjectByName(theName,"VISU");
894 SALOMEDS::GenericAttribute_var anAttr;
895 int iEnd = aList->length();
896 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = "<<iEnd);
897 for(int i = 0; i < iEnd; i++){
898 SALOMEDS::SObject_var anObj = aList[i];
899 CORBA::String_var aString = anObj->GetID();
900 string anEntry(aString);
901 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = "<<anEntry);
902 if(anObj->FindAttribute(anAttr, "AttributeComment")){
903 SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
904 aString = aCmnt->Value();
905 QString strIn(aString);
906 Storable::TRestoringMap aMap;
907 Storable::StrToMap(strIn,aMap);
908 if ( Storable::FindValue( aMap,"myComment").compare( View3D_i::myComment.c_str() ) >= 0 ) {
909 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = "<<strIn);
910 return Restore( aMap ) != NULL;
917 Storable* View3D_i::Restore(const Storable::TRestoringMap& theMap) throw(std::logic_error&) {
918 // if(MYDEBUG) MESSAGE("View3D_i::Restore");
919 //myName = VISU::Storable::FindValue(theMap,"myName").latin1();
921 SALOMEDS::Color aColor;
922 aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
923 aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
924 aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
927 aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
928 aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
929 aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
932 aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
933 aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
934 aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
937 aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
938 aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
939 aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
941 double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
943 double aScaleFactor[3];
944 aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
945 aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
946 aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
948 //myStudyFrame->setTitle(myName.c_str());
949 SetBackground(aColor);
950 SetPointOfView(aPosition);
952 SetFocalPoint(aFocalPnt);
953 SetParallelScale(aParallelScale);
954 ScaleView(VISU::View3D::XAxis,aScaleFactor[0]);
955 ScaleView(VISU::View3D::YAxis,aScaleFactor[1]);
956 ScaleView(VISU::View3D::ZAxis,aScaleFactor[2]);
957 RepaintView(myStudyFrame);
962 void View3D_i::ToStream(std::ostringstream& theStr) {
963 Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
966 GetRenderer(myStudyFrame)->GetBackground(backint);
967 Storable::DataToStream(theStr,"myColor.R",backint[0]);
968 Storable::DataToStream(theStr,"myColor.G",backint[1]);
969 Storable::DataToStream(theStr,"myColor.B",backint[2]);
972 GetPointOfView(myStudyFrame,aPosition);
973 Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
974 Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
975 Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
978 GetFocalPoint(myStudyFrame,aFocalPnt);
979 Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
980 Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
981 Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
984 GetCamera(myStudyFrame)->GetViewUp(aViewUp);
985 Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
986 Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
987 Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
989 Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(myStudyFrame));
991 double aScaleFactor[3];
992 GetViewFrame(myStudyFrame)->GetScale(aScaleFactor);
993 Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
994 Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
995 Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
999 // Storable* VISU::View3DRestore(SALOMEDS::SComponent_var& theSComponent, SALOMEDS::Study_var& theStudy,
1000 // const char* thePrefix, const Storable::TRestoringMap& theMap)
1003 // View3D_i* pView3D = new View3D_i(theStudy);
1004 // return pView3D->Restore(theMap);
1005 // }catch(std::logic_error& exc){
1006 // MESSAGE("Follow exception was accured :\n"<<exc.what());
1008 // MESSAGE("Unknown exception was accured!");
1013 void View3D_i::Close(){
1014 if(MYDEBUG) MESSAGE("View3D_i::Close");
1015 Mutex mt(myMutex,qApp,MYDELAY);
1016 myStudyFrame->close();
1019 View3D_i::~View3D_i() {
1020 if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1021 Mutex mt(myMutex,qApp,MYDELAY);
1022 myStudyFrame->close();
1025 //-------------------- View interface --------------------
1026 void View3D_i::SetTitle(const char* theTitle){
1027 if(MYDEBUG) MESSAGE("View3D_i::SetTitle");
1028 Mutex mt(myMutex,qApp,MYDELAY);
1030 myStudyFrame->setTitle(myName.c_str());
1032 char* View3D_i::GetTitle() {
1033 if(MYDEBUG) MESSAGE("View3D_i::GetTitle");
1034 Mutex mt(myMutex,qApp,MYDELAY);
1035 myName = (const char*)myStudyFrame->title();
1036 return CORBA::string_dup(myName.c_str());
1039 void View3D_i::SetBackground(QAD_StudyFrame* theStudyFrame, const SALOMEDS::Color& theColor) {
1041 aColor[0] = (int)(255.0*theColor.R);
1042 aColor[1] = (int)(255.0*theColor.G);
1043 aColor[2] = (int)(255.0*theColor.B);
1044 QColor aNewColor(aColor[0],aColor[1],aColor[2]);
1045 GetViewFrame(theStudyFrame)->setBackgroundColor(aNewColor);
1047 void View3D_i::SetBackground(const SALOMEDS::Color& theColor) {
1048 if(MYDEBUG) MESSAGE("View3D_i::SetBackground");
1049 Mutex mt(myMutex,qApp,MYDELAY);
1050 //myColor.R = theColor.R; myColor.G = theColor.G; myColor.B = theColor.B;
1051 SetBackground(myStudyFrame,theColor);
1054 SALOMEDS::Color View3D_i::GetBackground(QAD_StudyFrame* theStudyFrame) {
1055 SALOMEDS::Color aColor;
1057 GetRenderer(theStudyFrame)->GetBackground(backint);
1058 aColor.R = backint[0]; aColor.G = backint[1]; aColor.B = backint[2];
1061 SALOMEDS::Color View3D_i::GetBackground() {
1062 if(MYDEBUG) MESSAGE("View3D_i::GetBackground");
1063 Mutex mt(myMutex,qApp,MYDELAY);
1064 //myColor = GetBackground(myStudyFrame);
1065 return GetBackground(myStudyFrame); //myColor;
1068 void View3D_i::Minimize() {
1069 if(MYDEBUG) MESSAGE("View3D_i::Minimize");
1070 Mutex mt(myMutex,qApp,MYDELAY);
1071 myStudyFrame->showMinimized();
1073 void View3D_i::Restore() {
1074 if(MYDEBUG) MESSAGE("View3D_i::Restore");
1075 Mutex mt(myMutex,qApp,MYDELAY);
1076 myStudyFrame->showNormal();
1078 void View3D_i::Maximize() {
1079 if(MYDEBUG) MESSAGE("View3D_i::Maximize");
1080 Mutex mt(myMutex,qApp,MYDELAY);
1081 myStudyFrame->showMaximized();
1083 //===========================================================================
1084 void View3D_i::EraseAll() {
1085 if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1086 Mutex mt(myMutex,qApp,MYDELAY);
1087 UpdateViewer(myStudyFrame,eEraseAll);
1089 void View3D_i::DisplayAll() {
1090 if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1091 Mutex mt(myMutex,qApp,MYDELAY);
1092 UpdateViewer(myStudyFrame,eDisplayAll);
1094 void View3D_i::Erase(PrsObject_ptr thePrsObj) {
1095 if(MYDEBUG) MESSAGE("View3D_i::Erase");
1096 Mutex mt(myMutex,qApp,MYDELAY);
1097 CORBA::Object_ptr anObj = thePrsObj;
1098 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in()))
1099 UpdateViewer(myStudyFrame,eErase,aPrs);
1101 void View3D_i::Display(PrsObject_ptr thePrsObj) {
1102 if(MYDEBUG) MESSAGE("View3D_i::Display");
1103 Mutex mt(myMutex,qApp,MYDELAY);
1104 CORBA::Object_ptr anObj = thePrsObj;
1105 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in()))
1106 UpdateViewer(myStudyFrame,eDisplay,aPrs);
1108 void View3D_i::DisplayOnly(PrsObject_ptr thePrsObj) {
1109 if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
1110 Mutex mt(myMutex,qApp,MYDELAY);
1111 CORBA::Object_ptr anObj = thePrsObj;
1112 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in()))
1113 UpdateViewer(myStudyFrame,eDisplayOnly,aPrs);
1116 //-------------------- View3D interface --------------------
1117 void View3D_i::FitAll() {
1118 if(MYDEBUG) MESSAGE("View3D_i::FitAll");
1119 Mutex mt(myMutex,qApp,MYDELAY);
1120 GetViewFrame(myStudyFrame)->onViewFitAll();
1123 void View3D_i::SetView(VISU::View3D::ViewType theType) {
1124 if(MYDEBUG) MESSAGE("View3D_i::SetView");
1125 Mutex mt(myMutex,qApp,MYDELAY);
1127 case VISU::View3D::FRONT : GetViewFrame(myStudyFrame)->onViewFront(); break;
1128 case VISU::View3D::BACK : GetViewFrame(myStudyFrame)->onViewBack(); break;
1129 case VISU::View3D::LEFT : GetViewFrame(myStudyFrame)->onViewLeft(); break;
1130 case VISU::View3D::RIGHT : GetViewFrame(myStudyFrame)->onViewRight(); break;
1131 case VISU::View3D::TOP : GetViewFrame(myStudyFrame)->onViewTop(); break;
1132 case VISU::View3D::BOTTOM : GetViewFrame(myStudyFrame)->onViewBottom(); break;
1137 void View3D_i::SetPointOfView(QAD_StudyFrame* theStudyFrame, const CORBA::Double thePosition[3]) {
1138 GetCamera(theStudyFrame)->SetPosition(thePosition);
1140 void View3D_i::SetPointOfView(const VISU::View3D::XYZ theCoord) {
1141 if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
1142 Mutex mt(myMutex,qApp,MYDELAY);
1143 //VISU::View3D::XYZ_copy(myPosition,theCoord);
1144 SetPointOfView(myStudyFrame, theCoord);
1147 void View3D_i::GetPointOfView(QAD_StudyFrame* theStudyFrame, CORBA::Double thePosition[3]) {
1148 GetCamera(theStudyFrame)->GetPosition(thePosition);
1150 VISU::View3D::XYZ_slice* View3D_i::GetPointOfView() {
1151 if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
1152 Mutex mt(myMutex,qApp,MYDELAY);
1153 CORBA::Double aPosition[3];
1154 GetPointOfView(myStudyFrame,aPosition);
1155 return VISU::View3D::XYZ_dup(aPosition);
1158 void View3D_i::SetViewUp(QAD_StudyFrame* theStudyFrame, const CORBA::Double theViewUp[3]) {
1159 GetCamera(theStudyFrame)->SetViewUp(theViewUp);
1161 void View3D_i::SetViewUp(const VISU::View3D::XYZ theDir) {
1162 if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
1163 Mutex mt(myMutex,qApp,MYDELAY);
1164 //VISU::View3D::XYZ_copy(myViewUp,theDir);
1165 SetViewUp(myStudyFrame, theDir);
1168 void View3D_i::GetViewUp(QAD_StudyFrame* theStudyFrame, CORBA::Double theViewUp[3]) {
1169 GetCamera(theStudyFrame)->GetViewUp(theViewUp);
1171 VISU::View3D::XYZ_slice* View3D_i::GetViewUp() {
1172 if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
1173 Mutex mt(myMutex,qApp,MYDELAY);
1174 CORBA::Double aViewUp[3];
1175 GetCamera(myStudyFrame)->GetViewUp(aViewUp);
1176 return VISU::View3D::XYZ_dup(aViewUp);
1179 void View3D_i::SetFocalPoint(QAD_StudyFrame* theStudyFrame, const CORBA::Double theFocalPnt[3]) {
1180 GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt);
1182 void View3D_i::SetFocalPoint(const VISU::View3D::XYZ theCoord) {
1183 if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
1184 Mutex mt(myMutex,qApp,MYDELAY);
1185 //VISU::View3D::XYZ_copy(myFocalPnt,theCoord);
1186 SetFocalPoint(myStudyFrame,theCoord);
1189 void View3D_i::GetFocalPoint(QAD_StudyFrame* theStudyFrame, CORBA::Double theFocalPnt[3]) {
1190 GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt);
1192 VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint() {
1193 if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
1194 Mutex mt(myMutex,qApp,MYDELAY);
1195 CORBA::Double aFocalPnt[3];
1196 GetFocalPoint(myStudyFrame,aFocalPnt);
1197 return VISU::View3D::XYZ_dup(aFocalPnt);
1200 void View3D_i::SetParallelScale(QAD_StudyFrame* theStudyFrame, CORBA::Double theScale) {
1201 GetCamera(theStudyFrame)->SetParallelScale(theScale);
1203 void View3D_i::SetParallelScale(CORBA::Double theScale) {
1204 if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
1205 Mutex mt(myMutex,qApp,MYDELAY);
1206 //myParallelScale = theScale;
1207 SetParallelScale(myStudyFrame, theScale);
1210 CORBA::Double View3D_i::GetParallelScale(QAD_StudyFrame* theStudyFrame) {
1211 return GetCamera(theStudyFrame)->GetParallelScale();
1213 CORBA::Double View3D_i::GetParallelScale() {
1214 if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
1215 Mutex mt(myMutex,qApp);
1216 return GetParallelScale(myStudyFrame);
1219 void View3D_i::ScaleView(QAD_StudyFrame* theStudyFrame, VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1220 VTKViewer_ViewFrame* aViewFrame = GetViewFrame(theStudyFrame);
1221 double aScaleFactor[3];
1222 aViewFrame->GetScale(aScaleFactor);
1223 aScaleFactor[theAxis] = theParam;
1224 aViewFrame->SetScale(aScaleFactor);
1226 void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1227 if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
1228 Mutex mt(myMutex,qApp);
1229 //myScaleFactor[theAxis] = theParam;
1230 ScaleView(myStudyFrame,theAxis,theParam);
1232 void View3D_i::RemoveScale() {
1233 if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
1234 Mutex mt(myMutex,qApp);
1235 double aScaleFactor[]={1,1,1};
1236 //myScaleFactor[0] = myScaleFactor[0] = myScaleFactor[0] = 1.0;
1237 GetViewFrame(myStudyFrame)->SetScale(aScaleFactor);
1239 //===========================================================================