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"
31 #include "VISU_Gen_i.hh"
33 #include "VISU_Prs3d_i.hh"
34 #include "VISU_Mesh_i.hh"
35 #include "VISU_ScalarMap_i.hh"
36 #include "VISU_IsoSurfaces_i.hh"
37 #include "VISU_DeformedShape_i.hh"
38 #include "VISU_CutPlanes_i.hh"
39 #include "VISU_CutLines_i.hh"
40 #include "VISU_Vectors_i.hh"
41 #include "VISU_StreamLines_i.hh"
43 #include "VISU_Table_i.hh"
44 #include "VISU_ScalarBarActor.hxx"
45 #include "VISU_Actor.h"
47 #include "SALOME_Event.hxx"
49 #include "QAD_Application.h"
50 #include "QAD_Desktop.h"
51 #include "QAD_Tools.h"
52 #include "QAD_Study.h"
53 #include "QAD_LeftFrame.h"
54 #include "QAD_RightFrame.h"
55 #include "QAD_StudyFrame.h"
56 #include "QAD_PyEditor.h"
58 #include "VTKViewer_ViewFrame.h"
59 #include "VTKViewer_RenderWindow.h"
60 #include "SALOMEGUI_TableDlg.h"
61 #include "Plot2d_CurveContainer.h"
62 #include "Plot2d_ViewFrame.h"
67 #include <qfileinfo.h>
69 #include <vtkRenderer.h>
70 #include <vtkCamera.h>
75 static int MYDEBUG = 0;
77 static int MYDEBUG = 0;
80 static QFileInfo aFileInfo;
83 //===========================================================================
84 typedef TVoidMemFunEvent<QAD_StudyFrame> TFrameActionEvent;
86 template<class TObject>
87 class TSetBackgroundEvent: public SALOME_Event{
89 const SALOMEDS::Color& myColor;
91 TSetBackgroundEvent(TObject* theView, const SALOMEDS::Color& theColor):
92 myView(theView), myColor(theColor)
94 virtual void Execute(){
96 aColor[0] = int(255.0*myColor.R);
97 aColor[1] = int(255.0*myColor.G);
98 aColor[2] = int(255.0*myColor.B);
99 QColor aNewColor(aColor[0],aColor[1],aColor[2]);
100 myView->setBackgroundColor(aNewColor);
104 class TSetViewRepresentation: public SALOME_Event{
105 VISU::View::ViewRepresentation myViewRepr;
107 CORBA::Boolean myState;
109 TSetViewRepresentation( View_i* aView,
110 VISU::View::ViewRepresentation ViewRepr,
111 CORBA::Boolean State ):
112 SALOME_Event(), myViewRepr( ViewRepr ), myView( aView ), myState( State )
114 virtual void Execute(){
116 bool old = myView->IsPartShown( myViewRepr );
118 QAD_RightFrame* fr = myView->myStudyFrame->getRightFrame();
120 if( myView->myStudyFrame != NULL ){
123 case VISU::View::OBJECTBROWSER:
126 myView->myStudyFrame->unCompressLeft();
128 myView->myStudyFrame->compressLeft();
130 case VISU::View::VIEWER:
137 case VISU::View::PYTHON:
140 fr->unCompressLeft();
144 case VISU::View::MESSAGES:
147 fr->unCompressRight();
156 class TGetViewRepresentation: public SALOME_Event
159 typedef CORBA::Boolean TResult;
161 VISU::View::ViewRepresentation myPart;
164 TGetViewRepresentation( View_i* aView, VISU::View::ViewRepresentation Part ):
165 SALOME_Event(), myResult( false ), myPart( Part ), myView( aView )
168 virtual void Execute(){
171 case VISU::View::OBJECTBROWSER:
172 myResult = !myView->myStudyFrame->isCompressedLeft();
174 case VISU::View::VIEWER:
175 myResult = !myView->myStudyFrame->getRightFrame()->isCompressedViewFrame();
177 case VISU::View::PYTHON:
178 myResult = !myView->myStudyFrame->getRightFrame()->isCompressedPython();
180 case VISU::View::MESSAGES:
181 myResult = !myView->myStudyFrame->getRightFrame()->isCompressedMessage();
186 class TSetViewWidthHeight: public SALOME_Event{
191 TSetViewWidthHeight( View_i* aView, CORBA::Long Size, bool IsWidth ):
192 SALOME_Event(), mySize( Size ), myView( aView ), myIsWidth( IsWidth )
194 virtual void Execute(){
195 if( myView->myStudyFrame != NULL ){
196 QWidget* aStudyParent = myView->myStudyFrame->parentWidget(true);
197 int aleft = aStudyParent->frameGeometry().left();
198 int atop = aStudyParent->frameGeometry().top();
199 int aheight = aStudyParent->frameGeometry().height();
200 int awidth = aStudyParent->frameGeometry().width();
203 aQRect = QRect( aleft, atop, mySize, aheight );
205 aQRect = QRect( aleft, atop, awidth, mySize );
207 aStudyParent->setGeometry(aQRect);
212 class TGetViewWidthHeight: public SALOME_Event{
214 typedef CORBA::Long TResult;
219 TGetViewWidthHeight( View_i* aView, bool IsWidth ):
220 SALOME_Event(), myView( aView ), myIsWidth( IsWidth )
223 virtual void Execute()
226 QWidget* aStudyParent = myView->myStudyFrame->parentWidget(true);
228 myResult = aStudyParent->frameGeometry().width();
230 myResult = aStudyParent->frameGeometry().height();
235 class TSetViewPositionHorizontal: public SALOME_Event{
236 VISU::View::ViewPosition myViewPos;
239 TSetViewPositionHorizontal ( View_i* aView,
240 VISU::View::ViewPosition ViewPos ):
241 SALOME_Event(), myView( aView ), myViewPos(ViewPos)
243 virtual void Execute(){
244 QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
245 QWidget* aStudy = dynamic_cast <QWidget*> (myView->myStudyFrame);
246 QWidget* aStudyParent = aStudy->parentWidget(true);
247 if ( aStudyParent != 0 )
248 if ( aWorkspace!=NULL || aStudy != NULL )
250 case VISU::View::LEFT:
251 QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignLeft);
253 case VISU::View::CENTER:
254 QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignHCenter);
256 case VISU::View::RIGHT:
257 QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignRight);
263 class TSetViewPositionVertical: public SALOME_Event{
264 VISU::View::ViewPosition myViewPos;
267 TSetViewPositionVertical ( View_i* aView,
268 VISU::View::ViewPosition ViewPos ):
269 SALOME_Event(), myView( aView ), myViewPos(ViewPos)
271 virtual void Execute(){
272 QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
273 QWidget* aStudy = dynamic_cast <QWidget*>(myView->myStudyFrame);
274 QWidget* aStudyParent = aStudy->parentWidget(true);
275 if ( aStudyParent != 0 )
276 if ( aWorkspace!=NULL || aStudy != NULL )
278 case VISU::View::TOP:
279 QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignTop);
281 case VISU::View::CENTER:
282 QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignVCenter);
284 case VISU::View::BOTTOM:
285 QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignBottom);
291 class TSetRelativePosition : public SALOME_Event
294 CORBA::Double myX, myY;
296 TSetRelativePosition ( View_i* aView, CORBA::Double X, CORBA::Double Y ):
297 SALOME_Event(), myView( aView ), myX( X ), myY( Y )
299 virtual void Execute(){
300 QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
303 QAD_StudyFrame* aFrame = myView->myStudyFrame;
304 QWidget* aStudyParent = aFrame->parentWidget(true);
305 aStudyParent->move( int( myX * aWorkspace->width() ), int( myY * aWorkspace->height() ) );
310 class TSetRelativeSize : public SALOME_Event
313 CORBA::Double myX, myY;
315 TSetRelativeSize ( View_i* aView, CORBA::Double X, CORBA::Double Y ):
316 SALOME_Event(), myView( aView ), myX( X ), myY( Y )
318 virtual void Execute(){
319 QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
322 QAD_StudyFrame* aFrame = myView->myStudyFrame;
323 QWidget* aStudyParent = aFrame->parentWidget(true);
324 aStudyParent->setGeometry( aStudyParent->x(), aStudyParent->y(),
325 int( myX * aWorkspace->width() ), int( myY * aWorkspace->height() ) );
332 class TSavePictureEvent: public SALOME_Event{
334 const char* myFileName;
336 typedef CORBA::Boolean TResult;
338 TSavePictureEvent(QWidget* theWidget, const char* theFileName):
340 myFileName(theFileName),
343 virtual void Execute(){
345 QPixmap px = QPixmap::grabWindow(myWidget->winId());
346 if (!QString(myFileName).isNull()) {
347 QString fmt = QAD_Tools::getFileExtensionFromPath(myFileName).upper();
349 fmt = QString("BMP"); // default format
352 myResult = px.save(myFileName, fmt.latin1());
359 void RepaintView(QAD_StudyFrame* theStudyFrame);
360 class TRepaintViewEvent: public SALOME_Event{
361 QAD_StudyFrame* myStudyFrame;
363 TRepaintViewEvent(QAD_StudyFrame* theStudyFrame):
364 myStudyFrame(theStudyFrame)
366 virtual void Execute(){
367 RepaintView(myStudyFrame);
372 VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame){
373 return dynamic_cast<VTKViewer_ViewFrame*>(theStudyFrame->getRightFrame()->getViewFrame());
375 vtkRenderer* GetRenderer(QAD_StudyFrame* theStudyFrame){
376 return GetViewFrame(theStudyFrame)->getRenderer();
378 vtkCamera* GetCamera(QAD_StudyFrame* theStudyFrame){
379 return GetRenderer(theStudyFrame)->GetActiveCamera();
383 void RepaintView(VTKViewer_ViewFrame* theViewFrame){
384 theViewFrame->getRenderer()->ResetCameraClippingRange();
385 theViewFrame->getRW()->getRenderWindow()->Render();
386 //GetViewFrame(theStudyFrame)->Repaint();
389 void RepaintView(QAD_StudyFrame* theStudyFrame){
390 RepaintView(GetViewFrame(theStudyFrame));
394 VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs){
395 VTKViewer_ViewFrame* vf = GetViewFrame(theStudyFrame);
396 if (!vf) return NULL;
397 if(MYDEBUG) MESSAGE("UpdateViewer - theDisplaing = "<<theDisplaing<<"; thePrs = "<<thePrs);
398 vtkRenderer *aRen = vf->getRenderer();
399 vtkActorCollection *anActColl = aRen->GetActors();
401 VISU_Actor *anVISUActor = NULL, *aResActor = NULL;
402 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;){
403 if(anActor->IsA("VISU_Actor")){
404 anVISUActor = VISU_Actor::SafeDownCast(anActor);
405 if (thePrs == anVISUActor->GetPrs3d()) {
406 aResActor = anVISUActor->GetParent();
407 if(theDisplaing < eErase)
408 aResActor->VisibilityOn();
410 aResActor->VisibilityOff();
412 if(theDisplaing > eDisplay)
413 anVISUActor->VisibilityOff();
415 anVISUActor->VisibilityOn();
420 RepaintView(theStudyFrame);
423 if(thePrs != NULL && theDisplaing < eErase){
425 anVISUActor = thePrs->CreateActor();
426 vf->AddActor(anVISUActor);
427 }catch(std::runtime_error& exc){
432 RepaintView(theStudyFrame);
435 void UpdatePlot2d(Plot2d_ViewFrame *theView,int theDisplaying, Curve_i* theCurve) {
436 if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = "<<theDisplaying);
439 QList<Plot2d_Curve> clist;
440 theView->getCurves( clist );
441 if ( theDisplaying == eEraseAll ) {
442 for ( int i = 0; i < clist.count(); i++ ) {
443 if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing all : curve - "<<clist.at( i ));
444 theView->eraseCurve( clist.at( i ) );
447 else if ( theDisplaying == eErase ) {
448 for ( int i = 0; i < clist.count(); i++ ) {
449 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
450 if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - "<<clist.at( i ) );
451 theView->eraseCurve( clist.at( i ) );
455 else if ( theDisplaying == eDisplay ) {
457 for ( int i = 0; i < clist.count(); i++ ) {
458 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
459 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - "<<clist.at( i ) );
460 clist.at( i )->setHorTitle( theCurve->GetHorTitle().c_str() );
461 clist.at( i )->setVerTitle( theCurve->GetVerTitle().c_str() );
462 clist.at( i )->setHorUnits( theCurve->GetHorUnits().c_str() );
463 clist.at( i )->setVerUnits( theCurve->GetVerUnits().c_str() );
466 int nbPoints = theCurve->GetData( xList, yList );
467 if ( nbPoints > 0 && xList && yList ) {
468 clist.at( i )->setData( xList, yList, nbPoints );
470 if ( !theCurve->IsAuto() ) {
471 clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
472 clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
473 SALOMEDS::Color color = theCurve->GetColor();
474 clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
476 clist.at( i )->setAutoAssign( theCurve->IsAuto() );
477 theView->displayCurve( clist.at( i ) );
482 Plot2d_Curve* crv = theCurve->CreatePresentation();
483 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
485 theView->displayCurve( crv );
486 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
487 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
488 SALOMEDS::Color newColor;
489 newColor.R = crv->getColor().red()/255.;
490 newColor.G = crv->getColor().green()/255.;
491 newColor.B = crv->getColor().blue()/255.;
492 theCurve->SetColor( newColor );
493 crv->setAutoAssign( theCurve->IsAuto() );
497 else if ( theDisplaying == eDisplayOnly ) {
499 for ( int i = 0; i < clist.count(); i++ ) {
500 if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
501 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - "<<clist.at( i ) );
502 clist.at( i )->setHorTitle( theCurve->GetHorTitle().c_str() );
503 clist.at( i )->setVerTitle( theCurve->GetVerTitle().c_str() );
504 clist.at( i )->setHorUnits( theCurve->GetHorUnits().c_str() );
505 clist.at( i )->setVerUnits( theCurve->GetVerUnits().c_str() );
508 int nbPoints = theCurve->GetData( xList, yList );
509 if ( nbPoints > 0 && xList && yList ) {
510 clist.at( i )->setData( xList, yList, nbPoints );
512 if ( !theCurve->IsAuto() ) {
513 clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
514 clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
515 SALOMEDS::Color color = theCurve->GetColor();
516 clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
518 clist.at( i )->setAutoAssign( theCurve->IsAuto() );
519 theView->displayCurve( clist.at( i ) );
523 theView->eraseCurve( clist.at( i ) );
527 Plot2d_Curve* crv = theCurve->CreatePresentation();
528 if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - "<<crv );
530 theView->displayCurve( crv );
531 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
532 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
533 SALOMEDS::Color newColor;
534 newColor.R = crv->getColor().red()/255.;
535 newColor.G = crv->getColor().green()/255.;
536 newColor.B = crv->getColor().blue()/255.;
537 theCurve->SetColor( newColor );
538 crv->setAutoAssign( theCurve->IsAuto() );
544 QAD_Study* CheckStudy( SALOMEDS::Study_ptr theStudy ) {
545 QAD_Desktop* aDesktop = QAD_Application::getDesktop();
546 QAD_Study* aStudy = aDesktop->findStudy(theStudy);
548 CORBA::String_var aName = theStudy->Name();
549 aFileInfo.setFile(aName.in());
550 if (aFileInfo.exists())
551 aStudy = aDesktop->loadStudy(aFileInfo.baseName());
553 aStudy = aDesktop->loadStudy(aName.in());
555 MESSAGE("CheckStudy()::ERROR: Can't load study");
560 //===========================================================================
561 ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy) {
562 if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i");
563 myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
567 class TGetCurrentViewEvent: public SALOME_Event{
568 SALOMEDS::Study_ptr myStudyDocument;
570 TGetCurrentViewEvent( SALOMEDS::Study_ptr theStudy):
571 myStudyDocument(theStudy),
572 myResult(VISU::View::_nil())
574 virtual void Execute(){
575 if(QAD_Study* aStudy = QAD_Application::getDesktop()->findStudy( myStudyDocument )){
576 if ( QAD_StudyFrame* aStudyFrame = aStudy->getActiveStudyFrame() ) {
578 MESSAGE("GetCurrentView::Execute - TypeView = "<<aStudyFrame->getTypeView());
579 if ( aStudyFrame->getTypeView() == VIEW_VTK ) {
580 VISU::View3D_i* pView = new View3D_i(myStudyDocument);
582 myResult = pView->_this();
583 } else if ( aStudyFrame->getTypeView() == VIEW_PLOT2D ) {
584 VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
586 myResult = pView->_this();
591 typedef VISU::View_ptr TResult;
595 VISU::View_ptr ViewManager_i::GetCurrentView(){
596 return ProcessEvent(new TGetCurrentViewEvent( myStudyDocument ));
600 class TCreateViewEvent: public SALOME_Event{
602 TCreateViewEvent( SALOMEDS::Study_ptr theStudy):
603 myStudyDocument(theStudy)
606 SALOMEDS::Study_ptr myStudyDocument;
610 template<class TViewFrame>
611 class TCreateViewFrameEvent: public TCreateViewEvent{
613 typedef typename TViewFrame::TInterface TInterface;
614 typedef typename TInterface::_ptr_type TResult;
616 TCreateViewFrameEvent(SALOMEDS::Study_ptr theStudy):
617 TCreateViewEvent(theStudy),
618 myResult(TInterface::_nil())
620 virtual void Execute(){
621 if(CheckStudy(myStudyDocument)){
622 TViewFrame* pView = new TViewFrame(myStudyDocument);
624 myResult = pView->_this();
630 VISU::View3D_ptr ViewManager_i::Create3DView(){
631 if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
632 return ProcessEvent(new TCreateViewFrameEvent<VISU::View3D_i>(myStudyDocument));
636 VISU::XYPlot_ptr ViewManager_i::CreateXYPlot(){
637 if(MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot");
638 return ProcessEvent(new TCreateViewFrameEvent<VISU::XYPlot_i>(myStudyDocument));
642 class TCreateTableViewEvent: public TCreateViewEvent{
645 TCreateTableViewEvent(SALOMEDS::Study_ptr theStudy,
647 TCreateViewEvent(theStudy),
649 myResult(VISU::TableView::_nil())
651 virtual void Execute(){
652 if ( CheckStudy( myStudyDocument ) ) {
653 VISU::TableView_i* pView = new TableView_i(myStudyDocument);
654 if(pView->Create(myTable) != NULL)
655 myResult = pView->_this();
658 typedef VISU::TableView_ptr TResult;
662 VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){
663 if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
664 return ProcessEvent(new TCreateTableViewEvent(myStudyDocument,theTable));
668 void ViewManager_i::Destroy(View_ptr theView){
669 class TEvent: public SALOME_Event{
672 TEvent(View_ptr theView):
675 virtual void Execute(){
676 if(!CORBA::is_nil(myView)){
677 if(VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(myView).in())) {
679 pView->_remove_ref();
684 if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<<theView->_is_nil());
685 ProcessVoidEvent(new TEvent(theView));
689 //===========================================================================
690 View_i::View_i(SALOMEDS::Study_ptr theStudy) {
692 if(MYDEBUG) MESSAGE("View_i::View_i");
693 CORBA::String_var aName = theStudy->Name();
694 myStudy = CheckStudy(theStudy);
695 if(MYDEBUG) MESSAGE("View_i::View_i - isStudyOpened = "<<myStudy<<"; aName = "<<aName.in());
699 if(MYDEBUG) MESSAGE("View_i::~View_i");
702 void View_i::SetBackground(const SALOMEDS::Color& theColor) {}
703 SALOMEDS::Color View_i::GetBackground() { return SALOMEDS::Color();}
704 void View_i::Minimize() {}
705 void View_i::Restore() {}
706 void View_i::Maximize() {}
707 void View_i::EraseAll() {}
708 void View_i::DisplayAll() {}
709 void View_i::Erase(PrsObject_ptr thePrsObj) {}
710 void View_i::Display(PrsObject_ptr thePrsObj) {}
711 void View_i::DisplayOnly(PrsObject_ptr thePrsObj) {}
712 void View_i::Update() {}
714 CORBA::Boolean View_i::SavePicture(const char* theFileName) { return false; }
716 const char* View_i::GetComment() const { return "";}
717 void View_i::ToStream(std::ostringstream& theStr) {}
719 string View_i::GetEntry(){
720 SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectIOR(GetID());
721 CORBA::String_var anEntry = aSObject->GetID();
722 return string(anEntry.in());
726 //===========================================================================
727 XYPlot_i::XYPlot_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
728 if(MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
731 Storable* XYPlot_i::Create(int theNew){
733 myStudyFrame = myStudy->newWindow3d("",VIEW_PLOT2D);
735 myStudyFrame = myStudy->getActiveStudyFrame();
736 myView = dynamic_cast<Plot2d_ViewFrame*>(myStudyFrame->getRightFrame()->getViewFrame());
742 void XYPlot_i::Update() {
743 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
747 void XYPlot_i::Close(){
748 myStudyFrame->close();
751 XYPlot_i::~XYPlot_i() {
752 if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
756 void XYPlot_i::SetTitle(const char* theTitle){
757 ProcessVoidEvent(new TVoidMemFun1ArgEvent<QAD_StudyFrame,const QString&,QString>
758 (myStudyFrame,&QAD_StudyFrame::setCaption,QString(theTitle)));
760 char* XYPlot_i::GetTitle() {
761 return CORBA::string_dup(myStudyFrame->title().latin1());
765 void XYPlot_i::SetSubTitle(const char* theTitle){
766 ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
767 (myView,&Plot2d_ViewFrame::setTitle,QString(theTitle)));
769 char* XYPlot_i::GetSubTitle() {
770 return CORBA::string_dup(myView->getTitle());
774 void XYPlot_i::SetCurveType(VISU::XYPlot::CurveType theType){
775 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
776 (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
778 VISU::XYPlot::CurveType XYPlot_i::GetCurveType(){
779 return (VISU::XYPlot::CurveType)myView->getCurveType();
783 void XYPlot_i::SetMarkerSize(CORBA::Long theSize){
784 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
785 (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
787 CORBA::Long XYPlot_i::GetMarkerSize(){
788 return myView->getMarkerSize();
792 class TEnbleGridEvent: public SALOME_Event{
794 typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool = true);
795 TEnbleGridEvent(Plot2d_ViewFrame* theView, TFun theFun,
796 CORBA::Boolean theMajor, CORBA::Long theNumMajor,
797 CORBA::Boolean theMinor, CORBA::Long theNumMinor):
798 myView(theView), myFun(theFun),
799 myMajor(theMajor), myNumMajor(theNumMajor),
800 myMinor(theMinor), myNumMinor(theNumMinor)
802 virtual void Execute(){
803 (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor);
806 Plot2d_ViewFrame* myView;
808 CORBA::Boolean myMajor, myNumMajor;
809 CORBA::Boolean myMinor, myNumMinor;
813 void XYPlot_i::EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
814 CORBA::Boolean theMinor, CORBA::Long theNumMinor)
816 ProcessVoidEvent(new TEnbleGridEvent(myView,&Plot2d_ViewFrame::setXGrid,
817 theMajor,theNumMajor,theMinor,theNumMinor));
819 void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
820 CORBA::Boolean theMinor, CORBA::Long theNumMinor)
822 ProcessVoidEvent(new TEnbleGridEvent(myView,&Plot2d_ViewFrame::setYGrid,
823 theMajor,theNumMajor,theMinor,theNumMinor));
827 class TSetScaleModeEvent: public SALOME_Event{
829 typedef void (Plot2d_ViewFrame::* TFun)(const int, bool = true);
830 TSetScaleModeEvent(Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
831 myView(theView), myFun(theFun), myScaling(theScaling)
833 virtual void Execute(){
834 (myView->*myFun)(myScaling);
837 Plot2d_ViewFrame* myView;
843 void XYPlot_i::SetHorScaling(VISU::Scaling theScaling){
844 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
845 theScaling == VISU::LOGARITHMIC));
847 VISU::Scaling XYPlot_i::GetHorScaling(){
848 return (VISU::Scaling)myView->getHorScaleMode();
852 void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){
853 ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
854 theScaling == VISU::LOGARITHMIC));
856 VISU::Scaling XYPlot_i::GetVerScaling(){
857 return (VISU::Scaling)myView->getVerScaleMode();
861 class TSetTitleEvent: public SALOME_Event{
863 typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, bool = true);
864 TSetTitleEvent(Plot2d_ViewFrame* theView, TFun theFun, const char* theTitle):
865 myView(theView), myFun(theFun), myTitle(theTitle)
867 virtual void Execute(){
868 (myView->*myFun)(true,myTitle);
871 Plot2d_ViewFrame* myView;
877 void XYPlot_i::SetXTitle(const char* theTitle){
878 ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setXTitle,theTitle));
880 char* XYPlot_i::GetXTitle() {
881 return CORBA::string_dup(myView->getXTitle());
885 void XYPlot_i::SetYTitle(const char* theTitle){
886 ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setYTitle,theTitle));
888 char* XYPlot_i::GetYTitle() {
889 return CORBA::string_dup(myView->getYTitle());
893 void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){
894 ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
895 (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
899 void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){
900 ProcessVoidEvent(new TSetBackgroundEvent<Plot2d_ViewFrame>(myView,theColor));
902 SALOMEDS::Color XYPlot_i::GetBackground() {
903 SALOMEDS::Color aColor;
904 aColor.R = myView->backgroundColor().red()/255.0;
905 aColor.G = myView->backgroundColor().green()/255.0;
906 aColor.B = myView->backgroundColor().blue()/255.0;
910 void XYPlot_i::Minimize() {
911 ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized));
914 void XYPlot_i::Restore() {
915 ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showNormal));
918 void XYPlot_i::Maximize() {
919 ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showMaximized));
923 class TXYPlotViewEvent: public SALOME_Event{
925 Plot2d_ViewFrame* myView;
926 PrsObject_ptr myPrsObj;
929 TXYPlotViewEvent(QAD_Study* theStudy,
930 Plot2d_ViewFrame* theView,
931 PrsObject_ptr thePrsObj,
936 myDisplaing(theDisplaing)
938 virtual void Execute(){
940 if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
941 UpdatePlot2d(myView,myDisplaing,aCurve);
944 if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
945 int nbCurves = aContainer->GetNbCurves();
946 for ( int i = 1; i <= nbCurves; i++ ) {
947 VISU::Curve_i* aCurve = aContainer->GetCurve( i );
948 if ( aCurve && aCurve->IsValid() ) {
949 UpdatePlot2d(myView,myDisplaing,aCurve);
955 if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
956 SALOMEDS::Study_var aStudy = myStudy->getStudyDocument();
957 SALOMEDS::SObject_var TableSO = aStudy->FindObjectID( aTable->GetEntry() );
958 if ( !TableSO->_is_nil() ) {
959 SALOMEDS::ChildIterator_var Iter = aStudy->NewChildIterator( TableSO );
960 for ( ; Iter->More(); Iter->Next() ) {
961 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
962 if( !CORBA::is_nil( childObject ) ) {
963 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
964 if( !CORBA::is_nil( aCurve ) )
965 UpdatePlot2d(myView,myDisplaing,dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aCurve).in()));
975 void XYPlot_i::Display(PrsObject_ptr thePrsObj) {
976 ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eDisplay));
980 void XYPlot_i::Erase(PrsObject_ptr thePrsObj) {
981 ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eErase));
985 void XYPlot_i::DisplayOnly(PrsObject_ptr thePrsObj) {
986 ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eDisplayOnly));
990 void XYPlot_i::EraseAll() {
991 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::EraseAll));
995 void XYPlot_i::FitAll() {
996 ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::fitAll));
1000 CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) {
1001 return ProcessEvent(new TSavePictureEvent(myView->getViewWidget(),theFileName));
1005 //===========================================================================
1006 TableView_i::TableView_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {}
1007 Storable* TableView_i::Create(VISU::Table_ptr theTable){
1008 if(MYDEBUG) MESSAGE("TableView_i::Create - "<<(!theTable->_is_nil()));
1009 if(!theTable->_is_nil()){
1010 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
1011 if(MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = "<<table);
1013 SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectID(table->GetObjectEntry());
1014 if(!aSObject->_is_nil()) {
1015 myView = new SALOMEGUI_TableDlg(QAD_Application::getDesktop(),
1018 SALOMEGUI_TableDlg::ttAuto,
1029 TableView_i::~TableView_i() {
1030 if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
1035 void TableView_i::SetTitle(const char* theTitle){
1036 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SALOMEGUI_TableDlg,const QString&,QString>
1037 (myView,&SALOMEGUI_TableDlg::setCaption,QString(theTitle)));
1041 char* TableView_i::GetTitle() {
1042 return CORBA::string_dup(myView->caption().latin1());
1046 void TableView_i::Close(){
1051 //===========================================================================
1052 int View3D_i::myNbViewParams = 0;
1053 const string View3D_i::myComment = "VIEW3D";
1054 const char* View3D_i::GetComment() const { return myComment.c_str();}
1055 QString View3D_i::GenerateViewParamsName() {
1056 return VISU::GenerateName( "ViewParams", ++myNbViewParams );
1059 View3D_i::View3D_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
1060 if(MYDEBUG) MESSAGE("View3D_i::View3D_i");
1063 Storable* View3D_i::Create(int theNew){
1064 if(MYDEBUG) MESSAGE("View3D_i::Create");
1066 myStudyFrame = myStudy->newWindow3d("",VIEW_VTK);
1068 myStudyFrame = myStudy->getActiveStudyFrame();
1073 void View3D_i::Update(){
1074 class TEvent: public SALOME_Event{
1075 QAD_StudyFrame* myStudyFrame;
1077 TEvent(QAD_StudyFrame* theStudyFrame):
1078 myStudyFrame(theStudyFrame)
1080 virtual void Execute(){
1081 VTKViewer_ViewFrame* vf = GetViewFrame(myStudyFrame);
1082 vtkRenderer* Renderer = vf->getRenderer();
1083 vtkActorCollection* theActors = Renderer->GetActors();
1084 theActors->InitTraversal();
1085 while(vtkActor *anAct = theActors->GetNextActor()){
1086 if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anAct)){
1087 VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d();
1088 if(anActor->GetVisibility() && aPrs3d){
1090 aPrs3d->UpdateActor(anActor);
1094 RepaintView(myStudyFrame);
1097 ProcessVoidEvent(new TEvent(myStudyFrame));
1101 CORBA::Boolean View3D_i::SavePicture(const char* theFileName) {
1102 return ProcessEvent(new TSavePictureEvent(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget(),theFileName));
1106 bool View3D_i::SaveViewParams(QAD_StudyFrame* theStudyFrame, const char* theName){
1107 QAD_Study* aStudy = theStudyFrame->getStudy();
1108 SALOMEDS::Study_var aStudyDoc = aStudy->getStudyDocument();
1110 SALOMEDS::Study::ListOfSObject_var aList =
1111 aStudyDoc->FindObjectByName(theName,"VISU");
1112 SALOMEDS::GenericAttribute_var anAttr;
1113 int iEnd = aList->length();
1114 for(int i = 0; i < iEnd; i++){
1115 SALOMEDS::SObject_var anObj = aList[i];
1116 CORBA::String_var aString = anObj->GetID();
1117 string anEntry(aString);
1118 if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = "<<anEntry);
1119 if(anObj->FindAttribute(anAttr, "AttributeComment")){
1120 SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
1121 aString = aCmnt->Value();
1122 string aComm(aString);
1123 if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = "<<aComm);
1124 if(aComm.compare(View3D_i::myComment) >= 0){
1125 aCmnt->SetValue(ToString(theStudyFrame).c_str());
1131 SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(aStudyDoc);
1132 CORBA::String_var aSComponentEntry = aSComponent->GetID();
1133 string anEntry = CreateAttributes(aStudyDoc,aSComponentEntry.in(),"","",theName,"",ToString(theStudyFrame).c_str());
1136 CORBA::Boolean View3D_i::SaveViewParams(const char* theName){
1137 return SaveViewParams(myStudyFrame,theName);
1141 bool View3D_i::RestoreViewParams(QAD_StudyFrame* theStudyFrame, const char* theName){
1142 SALOMEDS::Study::ListOfSObject_var aList =
1143 theStudyFrame->getStudy()->getStudyDocument()->FindObjectByName(theName,"VISU");
1144 SALOMEDS::GenericAttribute_var anAttr;
1145 int iEnd = aList->length();
1146 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = "<<iEnd);
1147 for(int i = 0; i < iEnd; i++){
1148 SALOMEDS::SObject_var anObj = aList[i];
1149 CORBA::String_var aString = anObj->GetID();
1150 string anEntry(aString);
1151 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = "<<anEntry);
1152 if(anObj->FindAttribute(anAttr, "AttributeComment")){
1153 SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
1154 aString = aCmnt->Value();
1155 QString strIn(aString);
1156 Storable::TRestoringMap aMap;
1157 Storable::StrToMap(strIn,aMap);
1158 if ( Storable::FindValue( aMap,"myComment").compare( View3D_i::myComment.c_str() ) >= 0 ) {
1159 if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = "<<strIn);
1160 Restore(theStudyFrame,aMap);
1169 class TRestoreViewParamsEvent: public SALOME_Event{
1170 QAD_StudyFrame* myStudyFrame;
1173 TRestoreViewParamsEvent(QAD_StudyFrame* theStudyFrame,
1174 const char* theName):
1175 myStudyFrame(theStudyFrame),
1178 virtual void Execute(){
1179 myResult = View3D_i::RestoreViewParams(myStudyFrame,myName);
1181 typedef CORBA::Boolean TResult;
1185 CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){
1186 return ProcessEvent(new TRestoreViewParamsEvent(myStudyFrame,theName));
1190 void View3D_i::Restore(QAD_StudyFrame* theStudyFrame, const Storable::TRestoringMap& theMap){
1191 SALOMEDS::Color aColor;
1192 aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
1193 aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
1194 aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
1196 double aPosition[3];
1197 aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble();
1198 aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble();
1199 aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble();
1201 double aFocalPnt[3];
1202 aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble();
1203 aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble();
1204 aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble();
1207 aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble();
1208 aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble();
1209 aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble();
1211 double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble();
1213 double aScaleFactor[3];
1214 aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble();
1215 aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
1216 aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
1218 SetBackground(theStudyFrame,aColor);
1219 SetPointOfView(theStudyFrame,aPosition);
1220 SetViewUp(theStudyFrame,aViewUp);
1221 SetFocalPoint(theStudyFrame,aFocalPnt);
1222 SetParallelScale(theStudyFrame,aParallelScale);
1223 ScaleView(theStudyFrame,VISU::View3D::XAxis,aScaleFactor[0]);
1224 ScaleView(theStudyFrame,VISU::View3D::YAxis,aScaleFactor[1]);
1225 ScaleView(theStudyFrame,VISU::View3D::ZAxis,aScaleFactor[2]);
1229 string View3D_i::ToString(QAD_StudyFrame* theStudyFrame){
1230 ostringstream strOut;
1231 Storable::DataToStream( strOut, "myComment", myComment.c_str() );
1232 ToStream(theStudyFrame,strOut);
1234 if(MYDEBUG) MESSAGE("View3D_i::ToString - "<<strOut.str());
1235 return strOut.str();
1237 void View3D_i::ToStream(QAD_StudyFrame* theStudyFrame, std::ostringstream& theStr) {
1238 Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
1241 GetRenderer(theStudyFrame)->GetBackground(backint);
1242 Storable::DataToStream(theStr,"myColor.R",backint[0]);
1243 Storable::DataToStream(theStr,"myColor.G",backint[1]);
1244 Storable::DataToStream(theStr,"myColor.B",backint[2]);
1246 double aPosition[3];
1247 GetPointOfView(theStudyFrame,aPosition);
1248 Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
1249 Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
1250 Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
1252 double aFocalPnt[3];
1253 GetFocalPoint(theStudyFrame,aFocalPnt);
1254 Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
1255 Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
1256 Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
1259 GetCamera(theStudyFrame)->GetViewUp(aViewUp);
1260 Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
1261 Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
1262 Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
1264 Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theStudyFrame));
1266 double aScaleFactor[3];
1267 GetViewFrame(theStudyFrame)->GetScale(aScaleFactor);
1268 Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
1269 Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
1270 Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
1272 void View3D_i::ToStream(std::ostringstream& theStr) {
1273 ToStream(myStudyFrame,theStr);
1277 void View3D_i::Close(){
1278 myStudyFrame->close();
1281 View3D_i::~View3D_i() {
1282 if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
1285 //-------------------- View interface --------------------
1287 void View_i::ShowPart( VISU::View::ViewRepresentation ViewRepr, CORBA::Boolean state ) {
1288 ProcessVoidEvent( new TSetViewRepresentation( this, ViewRepr, state ) );
1292 CORBA::Boolean View_i::IsPartShown( VISU::View::ViewRepresentation Part )
1294 return ProcessEvent( new TGetViewRepresentation( this, Part ) );
1297 void View_i::SetViewWidth(CORBA::Long Width){
1298 ProcessVoidEvent( new TSetViewWidthHeight( this, Width, true ) );
1301 void View_i::SetViewHeight(CORBA::Long Height){
1302 ProcessVoidEvent( new TSetViewWidthHeight( this, Height, false ) );
1305 CORBA::Long View_i::GetViewWidth()
1307 return ProcessEvent( new TGetViewWidthHeight( this, true ) );
1310 CORBA::Long View_i::GetViewHeight()
1312 return ProcessEvent( new TGetViewWidthHeight( this, false ) );
1315 void View_i::SetViewPositionHorizontal( VISU::View::ViewPosition ViewPosHor ){
1316 ProcessVoidEvent( new TSetViewPositionHorizontal( this, ViewPosHor ) );
1319 void View_i::SetViewPositionVertical( VISU::View::ViewPosition ViewPosVer ){
1320 ProcessVoidEvent( new TSetViewPositionVertical( this, ViewPosVer ) );
1323 void View_i::SetRelativePosition( CORBA::Double x, CORBA::Double y )
1325 ProcessVoidEvent( new TSetRelativePosition( this, x, y ) );
1328 void View_i::SetRelativeSize( CORBA::Double x, CORBA::Double y )
1330 ProcessVoidEvent( new TSetRelativeSize( this, x, y ) );
1336 void View3D_i::SetTitle(const char* theTitle){
1337 ProcessVoidEvent(new TVoidMemFun1ArgEvent<QAD_StudyFrame,const QString&,QString>
1338 (myStudyFrame,&QAD_StudyFrame::setTitle,QString(theTitle)));
1340 char* View3D_i::GetTitle() {
1341 return CORBA::string_dup(myStudyFrame->title().latin1());
1345 void View3D_i::SetBackground(QAD_StudyFrame* theStudyFrame, const SALOMEDS::Color& theColor) {
1347 aColor[0] = int(255.0*theColor.R);
1348 aColor[1] = int(255.0*theColor.G);
1349 aColor[2] = int(255.0*theColor.B);
1350 QColor aNewColor(aColor[0],aColor[1],aColor[2]);
1351 GetViewFrame(theStudyFrame)->setBackgroundColor(aNewColor);
1353 void View3D_i::SetBackground(const SALOMEDS::Color& theColor) {
1354 ProcessVoidEvent(new TSetBackgroundEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),theColor));
1358 SALOMEDS::Color View3D_i::GetBackground(QAD_StudyFrame* theStudyFrame) {
1359 SALOMEDS::Color aColor;
1361 GetRenderer(theStudyFrame)->GetBackground(backint);
1362 aColor.R = backint[0]; aColor.G = backint[1]; aColor.B = backint[2];
1365 SALOMEDS::Color View3D_i::GetBackground() {
1366 return GetBackground(myStudyFrame);
1370 void View3D_i::Minimize() {
1371 ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized));
1373 void View3D_i::Restore() {
1374 ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showNormal));
1376 void View3D_i::Maximize() {
1377 ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showMaximized));
1381 //===========================================================================
1382 class TUpdateViewerEvent: public SALOME_Event{
1383 QAD_StudyFrame* myStudyFrame;
1387 TUpdateViewerEvent(QAD_StudyFrame* theStudyFrame,
1390 myStudyFrame(theStudyFrame),
1392 myDisplaing(theDisplaing)
1394 virtual void Execute(){
1395 UpdateViewer(myStudyFrame,myDisplaing,myPrs3d);
1399 void View3D_i::EraseAll() {
1400 if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
1401 ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,NULL,eEraseAll));
1404 void View3D_i::DisplayAll() {
1405 if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
1406 ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,NULL,eDisplayAll));
1409 void View3D_i::Erase(PrsObject_ptr thePrsObj) {
1410 if(MYDEBUG) MESSAGE("View3D_i::Erase");
1411 CORBA::Object_ptr anObj = thePrsObj;
1412 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1413 ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eErase));
1417 void View3D_i::Display(PrsObject_ptr thePrsObj) {
1418 if(MYDEBUG) MESSAGE("View3D_i::Display");
1419 CORBA::Object_ptr anObj = thePrsObj;
1420 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1421 ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eDisplay));
1425 void View3D_i::DisplayOnly(PrsObject_ptr thePrsObj) {
1426 if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
1427 CORBA::Object_ptr anObj = thePrsObj;
1428 if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
1429 ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eDisplayOnly));
1433 //-------------------- View3D interface --------------------
1434 void View3D_i::FitAll() {
1435 ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFitAll));
1440 void View3D_i::SetView(VISU::View3D::ViewType theType) {
1442 case VISU::View3D::FRONT :
1443 ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFront));
1445 case VISU::View3D::BACK :
1446 ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBack));
1448 case VISU::View3D::LEFT :
1449 ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewLeft));
1451 case VISU::View3D::RIGHT :
1452 ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewRight));
1454 case VISU::View3D::TOP :
1455 ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewTop));
1457 case VISU::View3D::BOTTOM :
1458 ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBottom));
1465 class TSet3DViewParamEvent: public SALOME_Event{
1467 typedef void (*TFun)(QAD_StudyFrame* theStudyFrame, const CORBA::Double theParam[3]);
1468 TSet3DViewParamEvent(TFun theFun,
1469 QAD_StudyFrame* theStudyFrame,
1470 const CORBA::Double theParam[3]):
1472 myStudyFrame(theStudyFrame),
1475 virtual void Execute(){
1476 myFun(myStudyFrame,myParam);
1480 QAD_StudyFrame* myStudyFrame;
1481 const CORBA::Double* myParam;
1485 void View3D_i::SetPointOfView(QAD_StudyFrame* theStudyFrame, const CORBA::Double thePosition[3]) {
1486 GetCamera(theStudyFrame)->SetPosition(thePosition);
1488 void View3D_i::SetPointOfView(const VISU::View3D::XYZ thePosition) {
1489 if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
1490 ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,myStudyFrame,thePosition));
1494 void View3D_i::GetPointOfView(QAD_StudyFrame* theStudyFrame, CORBA::Double thePosition[3]) {
1495 GetCamera(theStudyFrame)->GetPosition(thePosition);
1497 VISU::View3D::XYZ_slice* View3D_i::GetPointOfView() {
1498 if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
1499 CORBA::Double aPosition[3];
1500 GetPointOfView(myStudyFrame,aPosition);
1501 return VISU::View3D::XYZ_dup(aPosition);
1505 void View3D_i::SetViewUp(QAD_StudyFrame* theStudyFrame, const CORBA::Double theViewUp[3]) {
1506 GetCamera(theStudyFrame)->SetViewUp(theViewUp);
1508 void View3D_i::SetViewUp(const VISU::View3D::XYZ theViewUp) {
1509 if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
1510 ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,myStudyFrame,theViewUp));
1514 void View3D_i::GetViewUp(QAD_StudyFrame* theStudyFrame, CORBA::Double theViewUp[3]) {
1515 GetCamera(theStudyFrame)->GetViewUp(theViewUp);
1517 VISU::View3D::XYZ_slice* View3D_i::GetViewUp() {
1518 if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
1519 CORBA::Double aViewUp[3];
1520 GetCamera(myStudyFrame)->GetViewUp(aViewUp);
1521 return VISU::View3D::XYZ_dup(aViewUp);
1525 void View3D_i::SetFocalPoint(QAD_StudyFrame* theStudyFrame, const CORBA::Double theFocalPnt[3]) {
1526 GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt);
1528 void View3D_i::SetFocalPoint(const VISU::View3D::XYZ theCoord) {
1529 if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
1530 ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,myStudyFrame,theCoord));
1534 void View3D_i::GetFocalPoint(QAD_StudyFrame* theStudyFrame, CORBA::Double theFocalPnt[3]) {
1535 GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt);
1537 VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint() {
1538 if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
1539 CORBA::Double aFocalPnt[3];
1540 GetFocalPoint(myStudyFrame,aFocalPnt);
1541 return VISU::View3D::XYZ_dup(aFocalPnt);
1545 class TSetViewParamEvent: public SALOME_Event{
1547 typedef void (*TFun)(QAD_StudyFrame* theStudyFrame, CORBA::Double theParam);
1548 TSetViewParamEvent(TFun theFun,
1549 QAD_StudyFrame* theStudyFrame,
1550 CORBA::Double theParam):
1552 myStudyFrame(theStudyFrame),
1555 virtual void Execute(){
1556 myFun(myStudyFrame,myParam);
1560 QAD_StudyFrame* myStudyFrame;
1561 CORBA::Double myParam;
1565 void View3D_i::SetParallelScale(QAD_StudyFrame* theStudyFrame, CORBA::Double theScale) {
1566 GetCamera(theStudyFrame)->SetParallelScale(theScale);
1568 void View3D_i::SetParallelScale(CORBA::Double theScale) {
1569 if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
1570 ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,myStudyFrame,theScale));
1574 CORBA::Double View3D_i::GetParallelScale(QAD_StudyFrame* theStudyFrame) {
1575 return GetCamera(theStudyFrame)->GetParallelScale();
1577 CORBA::Double View3D_i::GetParallelScale() {
1578 if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
1579 return GetParallelScale(myStudyFrame);
1582 void View3D_i::ScaleView(QAD_StudyFrame* theStudyFrame, VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1583 VTKViewer_ViewFrame* aViewFrame = GetViewFrame(theStudyFrame);
1584 double aScaleFactor[3];
1585 aViewFrame->GetScale(aScaleFactor);
1586 aScaleFactor[theAxis] = theParam;
1587 aViewFrame->SetScale(aScaleFactor);
1590 void SetScaleView(QAD_StudyFrame* theStudyFrame, const CORBA::Double theScale[3]){
1591 double aScale[3] = {theScale[0], theScale[1], theScale[2]};
1592 GetViewFrame(theStudyFrame)->SetScale(aScale);
1594 void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam) {
1595 if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
1597 GetViewFrame(myStudyFrame)->GetScale(aScale);
1598 aScale[theAxis] = theParam;
1599 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myStudyFrame,aScale));
1601 void View3D_i::RemoveScale() {
1602 if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
1603 double aScale[3] = {1.0, 1.0, 1.0};
1604 ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myStudyFrame,aScale));
1606 //===========================================================================
1609 VISU_Actor* GetActor(VISU::Prs3d_i* thePrs3d, VTKViewer_ViewFrame* theVTKFrame){
1610 vtkActorCollection *anActColl = theVTKFrame->getRenderer()->GetActors();
1611 anActColl->InitTraversal();
1612 while(vtkActor *anActor = anActColl->GetNextActor())
1613 if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
1614 if(thePrs3d == anVISUActor->GetPrs3d())
1615 return anVISUActor->GetParent();
1620 void DeletePrs3d(Prs3d_ptr thePrs3d){
1621 if(Prs3d_i* aPrs3d = dynamic_cast<Prs3d_i*>(GetServant(thePrs3d).in())){
1622 SALOMEDS::SObject_var aSObject = aPrs3d->GetSObject();
1623 SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy();
1624 if(QAD_Desktop* aDesktop = QAD_Application::getDesktop()){
1625 if(QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument)){
1626 aStudy->unHighlightAll();
1627 int aNbStudyFrames = aStudy->getStudyFramesCount();
1628 for(int aFrameId = 0; aFrameId < aNbStudyFrames; aFrameId++){
1629 if(QAD_StudyFrame* aFrame = aStudy->getStudyFrame(aFrameId)){
1630 QAD_ViewFrame* aViewFrame = aFrame->getRightFrame()->getViewFrame();
1631 if(VTKViewer_ViewFrame* aVTKFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame)){
1632 if(VISU_Actor* anActor = VISU::GetActor(aPrs3d,aVTKFrame)){
1633 aVTKFrame->RemoveActor(anActor);
1636 aVTKFrame->unHighlightAll();
1641 aPrs3d->RemoveFromStudy();
1644 aStudy->updateObjBrowser(); //update Object browser
1651 void VISU_Gen_i::DeleteResult(Result_ptr theResult)
1653 class TEvent: public SALOME_Event{
1654 Result_ptr myResult;
1656 TEvent(Result_ptr theResult): myResult(theResult) {}
1657 virtual void Execute(){
1658 if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(myResult).in())){
1659 SALOMEDS::SObject_var aSObject = aResult->GetSObject();
1660 SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy();
1661 SALOMEDS::ChildIterator_var aChildIter = aStudyDocument->NewChildIterator(aSObject);
1662 for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1663 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1664 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1665 if(CORBA::is_nil(aChildObj)) continue;
1666 VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
1667 if(CORBA::is_nil(aPrs3d)) continue;
1668 VISU::DeletePrs3d(aPrs3d);
1671 aResult->RemoveFromStudy();
1674 if(QAD_Desktop* aDesktop = QAD_Application::getDesktop())
1675 if(QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument))
1676 aStudy->updateObjBrowser(); //update Object browser
1681 ProcessVoidEvent(new TEvent(theResult));
1685 void VISU_Gen_i::DeletePrs3d(Prs3d_ptr thePrs3d)
1687 class TEvent: public SALOME_Event{
1690 TEvent(Prs3d_ptr thePrs3d): myPrs3d(thePrs3d) {}
1691 virtual void Execute(){
1692 VISU::DeletePrs3d(myPrs3d);
1696 ProcessVoidEvent(new TEvent(thePrs3d));