1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "OCCViewer_ViewModel.h"
24 #include "OCCViewer.h"
25 #include "OCCViewer_ViewWindow.h"
26 #include "OCCViewer_ViewFrame.h"
27 #include "OCCViewer_VService.h"
28 #include "OCCViewer_ViewPort3d.h"
29 #include "OCCViewer_ClippingDlg.h"
30 #include "OCCViewer_Utilities.h"
32 #include "SUIT_ViewWindow.h"
33 #include "SUIT_ViewManager.h"
34 #include "SUIT_Desktop.h"
35 #include "SUIT_Session.h"
36 #include "SUIT_ResourceMgr.h"
38 #include "ViewerData_AISShape.hxx"
40 #include <Basics_OCCTVersion.hxx>
42 #include "QtxActionToolMgr.h"
43 #include "QtxBackgroundTool.h"
46 #include <QApplication>
47 #include <QColorDialog>
48 #include <QFileDialog>
52 #include <QMouseEvent>
54 #include <QDesktopWidget>
56 #include <AIS_Axis.hxx>
57 #if OCC_VERSION_LARGE > 0x06080000
58 #include <Prs3d_Drawer.hxx>
60 #include <AIS_Drawer.hxx>
62 #include <AIS_ListIteratorOfListOfInteractive.hxx>
64 #include <Graphic3d_Texture2Dmanual.hxx>
65 #include <Graphic3d_MaterialAspect.hxx>
66 #include <Graphic3d_TextureParams.hxx>
68 #include <Geom_Axis2Placement.hxx>
69 #include <Prs3d_Drawer.hxx>
70 #include <Prs3d_DatumAspect.hxx>
71 #include <Prs3d_LineAspect.hxx>
72 #include <Prs3d_TextAspect.hxx>
74 #include <V3d_DirectionalLight.hxx>
75 #include <V3d_AmbientLight.hxx>
77 #if OCC_VERSION_MAJOR < 7
78 #include <Visual3d_View.hxx>
82 Get data for supported background modes: gradient types, identifiers and supported image formats
84 QString OCCViewer_Viewer::backgroundData( QStringList& gradList, QIntList& idList, QIntList& txtList )
86 gradList << tr("GT_HORIZONTALGRADIENT") << tr("GT_VERTICALGRADIENT") <<
87 tr("GT_FIRSTDIAGONALGRADIENT") << tr("GT_SECONDDIAGONALGRADIENT") <<
88 tr("GT_FIRSTCORNERGRADIENT") << tr("GT_SECONDCORNERGRADIENT") <<
89 tr("GT_THIRDCORNERGRADIENT") << tr("GT_FORTHCORNERGRADIENT");
90 idList << HorizontalGradient << VerticalGradient <<
91 Diagonal1Gradient << Diagonal2Gradient <<
92 Corner1Gradient << Corner2Gradient <<
93 Corner3Gradient << Corner4Gradient;
94 txtList << Qtx::CenterTexture << Qtx::TileTexture << Qtx::StretchTexture;
95 return tr("BG_IMAGE_FILES");
99 Get data for supported stereo pair modes: stereo types and identifiers
101 void OCCViewer_Viewer::stereoData( QStringList& typeList, QIntList& idList)
103 typeList << tr("ST_QUADBUFFER") << tr("ST_ANAGLYPH") <<
104 tr("ST_ROWINTERLACED") << tr("ST_COLUMNINTERLACED") <<
105 tr("ST_CHESSBOARD") << tr("ST_SIDEBYSIDE") <<
107 idList << QuadBufferType << AnaglyphType <<
108 RowInterlacedType << ColumnInterlacedType <<
109 ChessBoardType << SideBySideType <<
115 \param DisplayTrihedron - is trihedron displayed
117 OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
119 myBackgrounds(4, Qtx::BackgroundData( Qt::black )),
122 myTrihedronSize(100),
123 myClippingDlg (NULL),
124 myIsUseLocalSelection(false)
126 // init CasCade viewers
127 myV3dViewer = OCCViewer_VService::CreateViewer( TCollection_ExtendedString("Viewer3d").ToExtString() );
128 //myV3dViewer->Init(); // to avoid creation of the useless perspective view (see OCCT issue 0024267)
132 myAISContext = new AIS_InteractiveContext( myV3dViewer );
133 #if OCC_VERSION_LARGE > 0x07010100
134 myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_LocalSelected)->SetColor( Quantity_NOC_WHITE );
135 myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_Selected)->SetColor( Quantity_NOC_WHITE );
136 #elif OCC_VERSION_LARGE > 0x07000000
137 const Handle(Graphic3d_HighlightStyle)& sStyle = myAISContext->SelectionStyle();
138 sStyle->SetColor( Quantity_NOC_WHITE );
140 myAISContext->SelectionColor( Quantity_NOC_WHITE );
143 // display isoline on planar faces (box for ex.)
144 myAISContext->IsoOnPlane( true );
146 /* create trihedron */
147 if ( DisplayTrihedron )
149 Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement(gp::XOY());
150 myTrihedron = new AIS_Trihedron(anAxis);
151 myTrihedron->SetInfiniteState( Standard_True );
153 Quantity_Color Col(193/255., 205/255., 193/255., Quantity_TOC_RGB);
154 //myTrihedron->SetColor( Col );
155 myTrihedron->SetArrowColor( Col.Name() );
156 myTrihedron->SetSize(100);
157 #if OCC_VERSION_LARGE > 0x06080000
158 Handle(Prs3d_Drawer) drawer = myTrihedron->Attributes();
159 if (drawer->HasOwnDatumAspect()) {
161 Handle(AIS_Drawer) drawer = myTrihedron->Attributes();
162 if (drawer->HasDatumAspect()) {
164 Handle(Prs3d_DatumAspect) daspect = drawer->DatumAspect();
165 daspect->FirstAxisAspect()->SetColor(Quantity_Color(1.0, 0.0, 0.0, Quantity_TOC_RGB));
166 daspect->SecondAxisAspect()->SetColor(Quantity_Color(0.0, 1.0, 0.0, Quantity_TOC_RGB));
167 daspect->ThirdAxisAspect()->SetColor(Quantity_Color(0.0, 0.0, 1.0, Quantity_TOC_RGB));
171 // set interaction style to standard
172 myInteractionStyle = 0;
174 // set zooming style to standard
178 myPreselectionEnabled = true;
181 mySelectionEnabled = true;
182 myMultiSelectionEnabled = true;
184 // set projection type to orthographic
185 myProjectionType = 0;
186 // set stereo parameters
188 myAnaglyphFilter = 0;
189 myToReverseStereo = 0;
191 myQuadBufferSupport = 0;
192 myStereographicFocusType = 1;
193 myInterocularDistanceType = 1;
194 myStereographicFocusValue = 1.0;
195 myInterocularDistanceValue = 0.05;
196 //set clipping color and texture to standard
197 myClippingColor = QColor( 50, 50, 50 );
198 myDefaultTextureUsed = true;
199 myClippingTexture = QString();
200 myTextureModulated = true;
201 myClippingTextureScale = 1.0;
208 OCCViewer_Viewer::~OCCViewer_Viewer()
210 myAISContext.Nullify();
211 myV3dViewer.Nullify();
216 \return background color of viewer
218 QColor OCCViewer_Viewer::backgroundColor() const
220 return backgroundColor(0);
224 \return background data of viewer
226 Qtx::BackgroundData OCCViewer_Viewer::background() const
228 return background(0);
232 Sets background color [obsolete]
233 \param c - new background color
235 void OCCViewer_Viewer::setBackgroundColor( const QColor& c )
237 setBackgroundColor( 0, c );
242 \param d - new background data
244 void OCCViewer_Viewer::setBackground( const Qtx::BackgroundData& theBackground )
246 setBackground( 0, theBackground );
250 Start initialization of view window
251 \param view - view window to be initialized
253 void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view )
257 view->initSketchers();
258 view->setInteractionStyle( interactionStyle() );
259 view->setProjectionType( projectionType() );
260 view->setStereoType( stereoType() );
261 view->setAnaglyphFilter( anaglyphFilter() );
262 view->setStereographicFocus( stereographicFocusType(), stereographicFocusValue() );
263 view->setInterocularDistance( interocularDistanceType(), interocularDistanceValue() );
264 view->setReverseStereo( isReverseStereo() );
265 view->setVSync( isVSync() );
266 view->setQuadBufferSupport( isQuadBufferSupport() );
267 view->setZoomingStyle( zoomingStyle() );
268 view->enablePreselection( isPreselectionEnabled() );
269 view->enableSelection( isSelectionEnabled() );
271 OCCViewer_ViewPort3d* vp3d = view->getViewPort();
274 #if OCC_VERSION_LARGE <= 0x07000000
275 vp3d->getView()->SetSurfaceDetail(V3d_TEX_ALL);
277 // connect signal from viewport
278 connect(vp3d, SIGNAL(vpClosed(OCCViewer_ViewPort3d*)), this, SLOT(onViewClosed(OCCViewer_ViewPort3d*)));
279 connect(vp3d, SIGNAL(vpMapped(OCCViewer_ViewPort3d*)), this, SLOT(onViewMapped(OCCViewer_ViewPort3d*)));
285 Creates new view window
286 \param theDesktop - main window of application
288 SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop )
291 OCCViewer_ViewFrame* view = new OCCViewer_ViewFrame(theDesktop, this);
292 // get main view window (created by view frame)
293 OCCViewer_ViewWindow* vw = view->getView(OCCViewer_ViewFrame::MAIN_VIEW);
294 // initialize main view window
296 // set default background for view window
297 vw->setBackground( background(0) ); // 0 means MAIN_VIEW (other views are not yet created here)
303 Sets new view manager
304 \param theViewManager - new view manager
306 void OCCViewer_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
308 SUIT_ViewModel::setViewManager(theViewManager);
309 if (theViewManager) {
310 connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
311 this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
313 connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)),
314 this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
316 connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
317 this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
319 connect(theViewManager, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)),
320 this, SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*)));
325 SLOT: called on mouse button press, stores current mouse position as start point for transformations
327 void OCCViewer_Viewer::onMousePress(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
329 myStartPnt.setX(theEvent->x()); myStartPnt.setY(theEvent->y());
333 SLOT: called on mouse move, processes transformation or hilighting
335 void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
337 if (!mySelectionEnabled) return;
338 if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
340 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
342 myCurPnt.setX(theEvent->x()); myCurPnt.setY(theEvent->y());
344 if ( isSelectionEnabled() && isPreselectionEnabled() ) {
345 if (aView->getViewPort()->isBusy()) {
346 QCoreApplication::processEvents();
347 return; // Check that the ViewPort initialization completed
348 // To Prevent call move event if the View port is not initialized
351 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
352 if ( !aView3d.IsNull() ) {
353 myAISContext->MoveTo( theEvent->x(), theEvent->y(), aView3d, Standard_True );
360 SLOT: called on mouse button release, finishes transformation or selection
362 void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
364 if (!mySelectionEnabled) return;
365 if (theEvent->button() != Qt::LeftButton) return;
366 if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
368 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
372 myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y());
373 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
376 myAISContext->ClearCurrents( false );
380 if (myStartPnt == myEndPnt)
382 if ( !isPreselectionEnabled() ) {
383 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
384 if ( !aView3d.IsNull() ) {
385 myAISContext->MoveTo( myEndPnt.x(), myEndPnt.y(), aView3d, Standard_True );
389 if (aHasShift && myMultiSelectionEnabled)
390 myAISContext->ShiftSelect( Standard_True );
392 myAISContext->Select( Standard_True );
396 if (aHasShift && myMultiSelectionEnabled)
397 myAISContext->ShiftSelect(myStartPnt.x(), myStartPnt.y(),
398 myEndPnt.x(), myEndPnt.y(),
399 aView->getViewPort()->getView(), Standard_False );
401 myAISContext->Select(myStartPnt.x(), myStartPnt.y(),
402 myEndPnt.x(), myEndPnt.y(),
403 aView->getViewPort()->getView(), Standard_False );
405 int Nb = myAISContext->NbSelected();
406 if( Nb>1 && !myMultiSelectionEnabled )
408 myAISContext->InitSelected();
409 Handle( SelectMgr_EntityOwner ) anOwner = myAISContext->SelectedOwner();
410 if( !anOwner.IsNull() )
412 myAISContext->ClearSelected( Standard_False );
413 myAISContext->AddOrRemoveSelected( anOwner, Standard_False );
417 myAISContext->UpdateCurrentViewer();
419 emit selectionChanged();
423 SLOT: called on key press, processes selection in "key free" interaction style
425 void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEvent)
427 if (!mySelectionEnabled) return;
429 OCCViewer_ViewWindow* aView = qobject_cast<OCCViewer_ViewWindow*>( theWindow );
430 if ( !aView ) return;
432 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
434 switch ( theEvent->key() ) {
437 myAISContext->ClearCurrents( false );
441 if ( !isPreselectionEnabled() ) {
442 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
443 if ( !aView3d.IsNull() ) {
444 myAISContext->MoveTo(myCurPnt.x(), myCurPnt.y(), aView3d, Standard_True );
448 if (aHasShift && myMultiSelectionEnabled)
449 myAISContext->ShiftSelect( Standard_True );
451 myAISContext->Select( Standard_True );
453 emit selectionChanged();
457 if ( isPreselectionEnabled() ) {
458 if ( useLocalSelection() )
459 getAISContext()->HilightNextDetected( aView->getViewPort()->getView() );
463 if ( isPreselectionEnabled() ) {
464 if ( getAISContext()->HasOpenedContext() )
465 getAISContext()->HilightPreviousDetected( aView->getViewPort()->getView() );
473 void OCCViewer_Viewer::onViewClosed(OCCViewer_ViewPort3d*)
475 Standard_Integer aViewsNb = 0;
476 for ( myV3dViewer->InitActiveViews(); myV3dViewer->MoreActiveViews(); myV3dViewer->NextActiveViews())
478 if ( aViewsNb < 2 ) {
479 //clean up presentations before last view is closed
480 myAISContext->RemoveAll(Standard_False);
484 void OCCViewer_Viewer::onViewMapped(OCCViewer_ViewPort3d* viewPort)
486 setTrihedronShown( true );
487 bool showStaticTrihedron = true;
488 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
489 if ( resMgr ) showStaticTrihedron = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
490 viewPort->showStaticTrihedron( showStaticTrihedron );
493 int OCCViewer_Viewer::getTopLayerId()
495 if ( myTopLayerId == 0 && !myAISContext->CurrentViewer().IsNull() )
496 myAISContext->CurrentViewer()->AddZLayer( myTopLayerId );
502 \return interaction style
504 int OCCViewer_Viewer::interactionStyle() const
506 return myInteractionStyle;
510 Sets interaction style: 0 - standard, 1 - keyboard free interaction
511 \param theStyle - new interaction style
513 void OCCViewer_Viewer::setInteractionStyle( const int theStyle )
515 myInteractionStyle = theStyle;
516 //!! To be done for view windows
517 if ( !myViewManager )
520 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
521 for ( int i = 0; i < (int)wins.count(); i++ )
523 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
525 win->setInteractionStyle( theStyle );
530 \return projection type
532 int OCCViewer_Viewer::projectionType() const
534 return myProjectionType;
538 Sets projection type: 0 - orthographic, 1 - perspective
539 \param theType - new projection type
541 void OCCViewer_Viewer::setProjectionType( const int theType )
543 if ( myProjectionType != theType ) {
544 if ( theType != OCCViewer_ViewWindow::Stereo )
545 myProjectionType = theType;
547 if ( !myViewManager )
550 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
551 for ( int i = 0; i < (int)wins.count(); i++ )
553 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
555 win->setProjectionType( (OCCViewer_ViewWindow::ProjectionType)theType );
563 int OCCViewer_Viewer::stereoType() const
570 \param theType - new stereo type
572 void OCCViewer_Viewer::setStereoType( const int theType )
574 myStereoType = theType;
576 if ( !myViewManager )
579 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
580 for ( int i = 0; i < (int)wins.count(); i++ )
582 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
584 win->setStereoType( (OCCViewer_ViewWindow::StereoType)theType );
589 \return stereographic focus type
591 int OCCViewer_Viewer::stereographicFocusType() const
593 return myStereographicFocusType;
597 \return stereographic focus value
599 double OCCViewer_Viewer::stereographicFocusValue() const
601 return myStereographicFocusValue;
605 Sets stereographic focus parameters
606 \param theType - new stereographic focus type
607 \param theValue - new stereographic focus value
609 void OCCViewer_Viewer::setStereographicFocus( const int theType, const double theValue )
611 myStereographicFocusType = theType;
612 myStereographicFocusValue = theValue;
614 if ( !myViewManager )
617 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
618 for ( int i = 0; i < (int)wins.count(); i++ )
620 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
622 win->setStereographicFocus( (OCCViewer_ViewWindow::FocusIODType)theType, theValue );
627 \return stereographic focus type
629 int OCCViewer_Viewer::interocularDistanceType() const
631 return myInterocularDistanceType;
635 \return stereographic focus value
637 double OCCViewer_Viewer::interocularDistanceValue() const
639 return myInterocularDistanceValue;
643 Sets interocular distance parameters
644 \param theType - new IOD type
645 \param theValue - new IOD value
647 void OCCViewer_Viewer::setInterocularDistance( const int theType, const double theValue )
649 myInterocularDistanceType = theType;
650 myInterocularDistanceValue = theValue;
652 if ( !myViewManager )
655 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
656 for ( int i = 0; i < (int)wins.count(); i++ )
658 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
660 win->setInterocularDistance( (OCCViewer_ViewWindow::FocusIODType)theType, theValue );
665 \return anaglyph filter
667 int OCCViewer_Viewer::anaglyphFilter() const
669 return myAnaglyphFilter;
674 \param theType - new anaglyph filter
676 void OCCViewer_Viewer::setAnaglyphFilter( const int theType )
678 myAnaglyphFilter = theType;
680 if ( !myViewManager )
683 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
684 for ( int i = 0; i < (int)wins.count(); i++ )
686 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
688 win->setAnaglyphFilter( (OCCViewer_ViewWindow::AnaglyphFilter)theType );
693 \return reverse stereo
695 bool OCCViewer_Viewer::isReverseStereo() const
697 return myToReverseStereo;
702 \param theReverse - enable/disable reverse mode
704 void OCCViewer_Viewer::setReverseStereo( const bool theReverse )
706 myToReverseStereo = theReverse;
708 if ( !myViewManager )
711 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
712 for ( int i = 0; i < (int)wins.count(); i++ )
714 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
716 win->setReverseStereo( theReverse );
723 bool OCCViewer_Viewer::isVSync() const
730 \param theEnable - enable/disable V-Sync mode
732 void OCCViewer_Viewer::setVSync( const bool theEnable )
734 myVSyncMode = theEnable;
736 if ( !myViewManager )
739 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
740 for ( int i = 0; i < (int)wins.count(); i++ )
742 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
744 win->setVSync( theEnable );
749 \return support quad-buffered stereo
751 bool OCCViewer_Viewer::isQuadBufferSupport() const
753 return myQuadBufferSupport;
757 Set support quad-buffered stereo
758 \param theEnable - enable/disable support quad-buffered stereo
760 void OCCViewer_Viewer::setQuadBufferSupport( const bool theEnable )
762 myQuadBufferSupport = theEnable;
764 if ( !myViewManager )
767 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
768 for ( int i = 0; i < (int)wins.count(); i++ )
770 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
772 win->setQuadBufferSupport( theEnable );
777 \return zooming style
779 int OCCViewer_Viewer::zoomingStyle() const
781 return myZoomingStyle;
785 Sets zooming style: 0 - standard, 1 - advanced (at cursor)
786 \param theStyle - new zooming style
788 void OCCViewer_Viewer::setZoomingStyle( const int theStyle )
790 myZoomingStyle = theStyle;
791 //!! To be done for view windows
792 if ( !myViewManager )
795 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
796 for ( int i = 0; i < (int)wins.count(); i++ )
798 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
800 win->setZoomingStyle( theStyle );
805 \return true if preselection is enabled
807 bool OCCViewer_Viewer::isPreselectionEnabled() const
809 return myPreselectionEnabled;
813 Enables/disables preselection
814 \param isEnabled - new status
816 void OCCViewer_Viewer::enablePreselection(bool isEnabled)
818 myPreselectionEnabled = isEnabled;
820 if ( !myViewManager )
823 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
824 for ( int i = 0; i < (int)wins.count(); i++ )
826 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
828 win->enablePreselection( isEnabled );
834 \return true if selection is enabled
836 bool OCCViewer_Viewer::isSelectionEnabled() const
838 return mySelectionEnabled;
842 Enables/disables selection
843 \param isEnabled - new status
845 void OCCViewer_Viewer::enableSelection(bool isEnabled)
847 mySelectionEnabled = isEnabled;
849 //!! To be done for view windows
850 if ( !myViewManager )
853 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
854 for ( int i = 0; i < (int)wins.count(); i++ )
856 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
858 win->updateEnabledDrawMode();
859 win->enableSelection( isEnabled );
864 //clear current selection in the viewer
866 myAISContext->ClearSelected( Standard_True );
872 Sets multiselection enabled status
873 \param isEnabled - new status
875 void OCCViewer_Viewer::enableMultiselection(bool isEnable)
877 myMultiSelectionEnabled = isEnable;
878 //!! To be done for view windows
879 if ( !myViewManager )
882 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
883 for ( int i = 0; i < (int)wins.count(); i++ )
885 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
887 win->updateEnabledDrawMode();
892 Sets a color of the clipped region
893 \param theColor - a new color of the clipped region
895 void OCCViewer_Viewer::setClippingColor( const QColor& theColor )
897 myClippingColor = theColor;
899 if( myInternalClipPlanes.IsEmpty() )
902 Graphic3d_MaterialAspect aMaterialAspect = Graphic3d_MaterialAspect();
903 aMaterialAspect.SetColor( Quantity_Color( theColor.redF(), theColor.greenF(),
904 theColor.blueF(), Quantity_TOC_RGB ) );
906 for( int i = 1; i <= myInternalClipPlanes.Size(); i++ )
907 myInternalClipPlanes.Value(i)->SetCappingMaterial( aMaterialAspect );
913 \return clipping color
915 QColor OCCViewer_Viewer::clippingColor() const
917 return myClippingColor;
920 // initialize a texture for clipped region
921 Handle(Graphic3d_Texture2Dmanual) initClippingTexture( const bool isDefault, const QString& theTexture,
922 const bool isModulate, const double theScale )
924 QString aTextureFile = isDefault ? ":images/hatch.png" : theTexture;
925 QPixmap px( aTextureFile );
926 const Handle(Image_PixMap) aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage() );
927 Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual( aPixmap );
928 if( aTexture->IsDone() ) {
929 aTexture->EnableRepeat();
930 isModulate ? aTexture->EnableModulate() : aTexture->DisableModulate();
931 aTexture->GetParams()->SetScale( Graphic3d_Vec2( 1/( theScale*100 ), -1 / ( theScale*100 ) ) );
937 Sets default texture parameters
938 \param isDefault - use/non-use default texture
939 \param theTexture - new texture of the clipped region
940 \param isModulate - enable/disable texture modulate mode
941 \param theScale - scale factor.
943 void OCCViewer_Viewer::setClippingTextureParams( const bool isDefault, const QString& theTexture,
944 const bool isModulate, const double theScale )
946 myDefaultTextureUsed = isDefault;
947 myClippingTexture = theTexture;
948 myTextureModulated = isModulate;
949 myClippingTextureScale = theScale;
951 if( myInternalClipPlanes.IsEmpty() )
954 Handle(Graphic3d_Texture2Dmanual) aTexture =
955 initClippingTexture( myDefaultTextureUsed, myClippingTexture,
956 myTextureModulated, myClippingTextureScale );
958 for( int i = 1; i <= myInternalClipPlanes.Size(); i++ )
959 myInternalClipPlanes.Value(i)->SetCappingTexture( aTexture );
965 \return true if default texture is used
967 bool OCCViewer_Viewer::isDefaultTextureUsed() const
969 return myDefaultTextureUsed;
973 \return clipping texture
975 QString OCCViewer_Viewer::clippingTexture() const
977 return myClippingTexture;
981 \return true if texture is modulated
983 bool OCCViewer_Viewer::isTextureModulated() const
985 return myTextureModulated;
989 \return scale factor of texture
991 double OCCViewer_Viewer::clippingTextureScale() const
993 return myClippingTextureScale;
997 Builds popup for occ viewer
999 void OCCViewer_Viewer::contextMenuPopup(QMenu* thePopup)
1001 thePopup->addAction( tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
1002 thePopup->addAction( tr( "MEN_CHANGE_BACKGROUND" ), this, SLOT( onChangeBackground() ) );
1004 thePopup->addSeparator();
1006 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1008 //Support of several toolbars in the popup menu
1009 QList<QToolBar*> lst = aView->findChildren<QToolBar*>();
1010 QList<QToolBar*>::const_iterator it = lst.begin(), last = lst.end();
1011 for ( ; it!=last; it++ ) {
1012 if ( (*it)->parentWidget()->isVisible() )
1013 thePopup->addAction( (*it)->toggleViewAction() );
1018 SLOT: called on dump view operation is activated, stores scene to raster file
1020 void OCCViewer_Viewer::onDumpView()
1022 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1024 aView->onDumpView();
1028 SLOT: called if background color is to be changed changed, passes new color to view port
1030 void OCCViewer_Viewer::onChangeBackground()
1032 OCCViewer_ViewWindow* aView = dynamic_cast<OCCViewer_ViewWindow*>(myViewManager->getActiveView());
1036 // get supported gradient types
1037 QStringList gradList;
1038 QIntList idList, txtList;
1039 QString formats = backgroundData( gradList, idList, txtList );
1041 // invoke dialog box
1042 Qtx::BackgroundData bgData = QtxBackgroundDialog::getBackground( aView->background(), // initial background
1043 aView, // parent for dialog box
1044 txtList, // allowed texture modes
1045 true, // enable solid color mode
1046 true, // enable gradient mode
1047 false, // disable custom gradient mode
1048 !txtList.isEmpty(), // enable/disable texture mode
1049 gradList, // gradient names
1050 idList, // gradient identifiers
1051 formats ); // image formats
1053 // set chosen background data to the viewer
1054 if ( bgData.isValid() )
1055 aView->setBackground( bgData );
1059 Updates OCC 3D viewer
1061 void OCCViewer_Viewer::update()
1063 if (!myV3dViewer.IsNull())
1064 myV3dViewer->Update();
1066 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1068 aView->updateGravityCoords();
1072 \return objects selected in 3D viewer
1073 \param theList - list to be filled with selected objects
1075 void OCCViewer_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList)
1078 for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected())
1079 theList.Append(myAISContext->SelectedInteractive());
1083 Selects objects in 3D viewer. Other selected objects are left as selected
1084 \param theList - list objects to be selected
1086 void OCCViewer_Viewer::setObjectsSelected(const AIS_ListOfInteractive& theList)
1088 AIS_ListIteratorOfListOfInteractive aIt;
1089 for (aIt.Initialize(theList); aIt.More(); aIt.Next())
1090 myAISContext->AddOrRemoveSelected(aIt.Value(), false);
1091 myAISContext->UpdateCurrentViewer();
1095 Auxiliary method to emit signal selectionChanged()
1097 void OCCViewer_Viewer::performSelectionChanged()
1099 emit selectionChanged();
1103 * Defines default lights
1105 void OCCViewer_Viewer::setDefaultLights()
1107 // clear all light sources
1108 myV3dViewer->InitDefinedLights();
1109 while ( myV3dViewer->MoreDefinedLights() )
1111 myV3dViewer->DelLight( myV3dViewer->DefinedLight() );
1112 myV3dViewer->InitDefinedLights();
1115 // get light source parameters from preferences
1116 QColor aColor = SUIT_Session::session()->resourceMgr()->colorValue( "OCCViewer", "light_color", QColor( 0, 0, 0 ) );
1117 double aDx = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dx", 0.0 );
1118 double aDy = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dy", 0.0 );
1119 double aDz = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dz", -1.0 );
1121 Handle(V3d_DirectionalLight) aLight =
1122 new V3d_DirectionalLight( myV3dViewer, V3d_Zneg, OCCViewer::color( aColor ).Name(), Standard_True );
1123 if( !( aDx == 0 && aDy == 0 && aDz == 0 ) )
1124 aLight->SetDirection( aDx, aDy, aDz );
1125 myV3dViewer->SetLightOn( aLight );
1126 myV3dViewer->SetLightOn( new V3d_AmbientLight( myV3dViewer ) );
1130 Hilights/unhilights object in viewer
1131 \param obj - object to be updated
1132 \param hilight - if it is true, object will be hilighted, otherwise it will be unhilighted
1133 \param update - update current viewer
1135 bool OCCViewer_Viewer::highlight( const Handle(AIS_InteractiveObject)& obj,
1136 bool hilight, bool update )
1138 bool isInLocal = myAISContext->HasOpenedContext();
1142 if ( hilight && !myAISContext->IsSelected( obj ) )
1143 myAISContext->AddOrRemoveCurrentObject( obj, false );
1144 else if ( !hilight && myAISContext->IsSelected( obj ) )
1145 myAISContext->AddOrRemoveCurrentObject( obj, false );
1149 myV3dViewer->Redraw();
1155 Unhilights all objects in viewer
1156 \param updateviewer - update current viewer
1158 bool OCCViewer_Viewer::unHighlightAll( bool updateviewer, bool unselect )
1160 if ( myAISContext->HasOpenedContext() ) {
1162 myAISContext->ClearSelected( updateviewer );
1164 myAISContext->UnhilightSelected( updateviewer );
1168 myAISContext->ClearCurrents( updateviewer );
1170 myAISContext->UnhilightCurrents( updateviewer );
1178 \return true if object is in viewer or in collector
1179 \param obj - object to be checked
1180 \param onlyInViewer - search object only in viewer (so object must be displayed)
1182 bool OCCViewer_Viewer::isInViewer( const Handle(AIS_InteractiveObject)& obj,
1185 AIS_ListOfInteractive List;
1186 myAISContext->DisplayedObjects(List);
1188 AIS_ListIteratorOfListOfInteractive ite(List);
1189 for ( ; ite.More(); ite.Next() )
1190 if( ite.Value()==obj )
1197 \return true if object is displayed in viewer
1198 \param obj - object to be checked
1200 bool OCCViewer_Viewer::isVisible( const Handle(AIS_InteractiveObject)& obj )
1202 return myAISContext->IsDisplayed( obj );
1206 Sets color of object
1207 \param obj - object to be updated
1208 \param color - new color
1209 \param update - update current viewer
1211 void OCCViewer_Viewer::setColor( const Handle(AIS_InteractiveObject)& obj,
1212 const QColor& color,
1217 Quantity_Color CSFColor = Quantity_Color ( color.red() / 255.,
1218 color.green() / 255.,
1219 color.blue() / 255.,
1221 obj->SetColor( CSFColor );
1225 myV3dViewer->Update();
1229 Changes display mode of object
1230 \param obj - object to be processed
1231 \param mode - new display mode
1232 \param update - update current viewer
1234 void OCCViewer_Viewer::switchRepresentation( const Handle(AIS_InteractiveObject)& obj,
1235 int mode, bool update )
1237 myAISContext->SetDisplayMode( obj, (Standard_Integer)mode, update );
1239 myV3dViewer->Update();
1243 Changes transparency of object
1244 \param obj - object to be processed
1245 \param trans - new transparency
1246 \param update - update current viewer
1248 void OCCViewer_Viewer::setTransparency( const Handle(AIS_InteractiveObject)& obj,
1249 float trans, bool update )
1251 myAISContext->SetTransparency( obj, trans, false );
1252 myAISContext->Redisplay( obj, Standard_False, Standard_True );
1254 myV3dViewer->Update();
1258 Changes visibility of trihedron to opposite
1260 void OCCViewer_Viewer::toggleTrihedron()
1262 setTrihedronShown( !isTrihedronVisible() );
1266 \return true if trihedron is visible
1268 bool OCCViewer_Viewer::isTrihedronVisible() const
1270 return !myTrihedron.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myTrihedron );
1274 Sets visibility state of trihedron
1275 \param on - new state
1278 void OCCViewer_Viewer::setTrihedronShown( const bool on )
1280 if ( myTrihedron.IsNull() )
1284 myAISContext->Display( myTrihedron,
1286 -1 /* selection mode */,
1287 Standard_True /* update viewer*/,
1288 Standard_False /* allow decomposition */,
1289 AIS_DS_Displayed /* display status */);
1290 myAISContext->Deactivate( myTrihedron );
1293 myAISContext->Erase( myTrihedron , Standard_True );
1298 \return trihedron size
1300 double OCCViewer_Viewer::trihedronSize() const
1303 if ( !myTrihedron.IsNull() )
1304 sz = myTrihedron->Size();
1309 Changes trihedron size
1310 \param sz - new size
1312 void OCCViewer_Viewer::setTrihedronSize( const double sz, bool isRelative )
1314 if ( myTrihedronSize != sz || isRelative != myIsRelative) {
1315 myTrihedronSize = sz;
1316 myIsRelative = isRelative;
1322 Set number of isolines
1323 \param u - u-isolines (first parametric co-ordinate)
1324 \param v - v-isolines (second parametric co-ordinate)
1326 void OCCViewer_Viewer::setIsos( const int u, const int v )
1328 Handle(AIS_InteractiveContext) ic = getAISContext();
1332 ic->SetIsoNumber( u, AIS_TOI_IsoU );
1333 ic->SetIsoNumber( v, AIS_TOI_IsoV );
1337 \return number of isolines
1338 \param u - to return u-isolines (first parametric co-ordinate)
1339 \param v - to return v-isolines (second parametric co-ordinate)
1341 void OCCViewer_Viewer::isos( int& u, int& v ) const
1343 Handle(AIS_InteractiveContext) ic = getAISContext();
1346 u = ic->IsoNumber( AIS_TOI_IsoU );
1347 v = ic->IsoNumber( AIS_TOI_IsoV );
1352 * Returns a new OCCViewer_ViewWindow instance which will be placed as a sub window in ViewFrame
1354 OCCViewer_ViewWindow* OCCViewer_Viewer::createSubWindow()
1356 return new OCCViewer_ViewWindow(0, this);
1360 Sets using local selection state
1361 \param theIsUseLocalSelection - state
1363 void OCCViewer_Viewer::setUseLocalSelection(bool theIsUseLocalSelection)
1365 myIsUseLocalSelection = theIsUseLocalSelection;
1369 * Returns true if local context is opened or view model local state is set
1371 bool OCCViewer_Viewer::useLocalSelection() const
1373 if (myIsUseLocalSelection)
1376 Handle(AIS_InteractiveContext) ic = getAISContext();
1377 return !ic.IsNull() && ic->HasOpenedContext();
1381 QColor OCCViewer_Viewer::backgroundColor( int theViewId ) const
1383 return background( theViewId ).color();
1386 Qtx::BackgroundData OCCViewer_Viewer::background( int theViewId ) const
1388 return ( theViewId >= 0 && theViewId < myBackgrounds.count() ) ? myBackgrounds[theViewId] : Qtx::BackgroundData();
1392 void OCCViewer_Viewer::setBackgroundColor( int theViewId, const QColor& theColor )
1394 if ( theColor.isValid() ) {
1395 Qtx::BackgroundData bg = background( theViewId );
1396 bg.setColor( theColor );
1397 setBackground( theViewId, bg );
1401 void OCCViewer_Viewer::setBackground( int theViewId, const Qtx::BackgroundData& theBackground )
1403 if ( theBackground.isValid() && theViewId >= 0 && theViewId < myBackgrounds.count() )
1404 myBackgrounds[theViewId] = theBackground;
1409 Set the show static trihedron flag
1411 void OCCViewer_Viewer::setStaticTrihedronDisplayed(const bool on)
1413 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1414 if ( aView ) aView->showStaticTrihedron( on );
1418 Get new and current trihedron size corresponding to the current model size
1420 bool OCCViewer_Viewer::computeTrihedronSize( double& theNewSize, double& theSize )
1425 //SRN: BUG IPAL8996, a usage of method ActiveView without an initialization
1426 Handle(V3d_Viewer) viewer = getViewer3d();
1427 viewer->InitActiveViews();
1428 if(!viewer->MoreActiveViews()) return false;
1430 Handle(V3d_View) view3d = viewer->ActiveView();
1433 if ( view3d.IsNull() )
1436 double aMaxSide = computeSceneSize( view3d );
1439 // The boundary box of the view may be initialized but nullified
1440 // (case of infinite objects)
1441 if ( aMaxSide < Precision::Confusion() )
1444 float aSizeInPercents = SUIT_Session::session()->resourceMgr()->doubleValue("3DViewer","trihedron_size", 100.);
1446 static float EPS = 5.0E-3;
1447 theSize = getTrihedron()->Size();
1448 theNewSize = aMaxSide*aSizeInPercents / 100.0;
1450 return fabs( theNewSize - theSize ) > theSize * EPS ||
1451 fabs( theNewSize - theSize ) > theNewSize * EPS;
1455 * Compute scene size
1457 double OCCViewer_Viewer::computeSceneSize(const Handle(V3d_View)& view3d) const
1459 double aMaxSide = 0;
1460 double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
1462 #if OCC_VERSION_LARGE > 0x06070100
1463 Bnd_Box aBox = view3d->View()->MinMaxValues();
1464 Xmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().X();
1465 Ymin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Y();
1466 Zmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Z();
1467 Xmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().X();
1468 Ymax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Y();
1469 Zmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Z();
1471 view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax );
1474 if ( Xmin != RealFirst() && Ymin != RealFirst() && Zmin != RealFirst() &&
1475 Xmax != RealLast() && Ymax != RealLast() && Zmax != RealLast() )
1477 aMaxSide = Xmax - Xmin;
1478 if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin;
1479 if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin;
1486 * Update the size of the trihedron
1488 void OCCViewer_Viewer::updateTrihedron() {
1489 if ( myTrihedron.IsNull() )
1493 double newSz, oldSz;
1495 if(computeTrihedronSize(newSz, oldSz))
1496 myTrihedron->SetSize(newSz);
1498 } else if(myTrihedron->Size() != myTrihedronSize) {
1499 myTrihedron->SetSize(myTrihedronSize);
1504 Set number of isolines
1505 \param u - u-isolines (first parametric co-ordinate)
1506 \param v - v-isolines (second parametric co-ordinate)
1508 void OCCViewer_Viewer::setSelectionOptions( bool isPreselectionEnabled, bool isSelectionEnabled )
1510 myPreselectionEnabled = isPreselectionEnabled;
1511 mySelectionEnabled = isSelectionEnabled;
1512 //clear current selection in the viewer
1514 if(!mySelectionEnabled) {
1515 myAISContext->ClearSelected( Standard_True );
1520 Creates clipping plane based on the incoming plane
1522 Handle(Graphic3d_ClipPlane) OCCViewer_Viewer::createClipPlane(const gp_Pln& thePlane, const Standard_Boolean theIsOn)
1524 Handle(Graphic3d_ClipPlane) aGraphic3dPlane = new Graphic3d_ClipPlane( thePlane );
1525 aGraphic3dPlane->SetOn( theIsOn );
1526 aGraphic3dPlane->SetCapping( Standard_True );
1528 // set capping color
1529 Graphic3d_MaterialAspect aMaterialAspect = Graphic3d_MaterialAspect();
1530 aMaterialAspect.SetColor( Quantity_Color( myClippingColor.redF(), myClippingColor.greenF(),
1531 myClippingColor.blueF(), Quantity_TOC_RGB ) );
1532 aGraphic3dPlane->SetCappingMaterial( aMaterialAspect );
1534 // set capping texture
1535 aGraphic3dPlane->SetCappingTexture( initClippingTexture( myDefaultTextureUsed, myClippingTexture,
1536 myTextureModulated, myClippingTextureScale ) );
1538 return aGraphic3dPlane;
1541 Applies clipping planes to clippable objects
1543 void OCCViewer_Viewer::setClipPlanes(ClipPlanesList theList)
1545 // 1. Remove existing clipping planes
1546 myClipPlanes.clear();
1547 myInternalClipPlanes.Clear();
1549 // 2. Create new clipping planes
1550 ClipPlanesList::iterator inIt = theList.begin();
1551 for (;inIt != theList.end(); inIt++ )
1553 OCCViewer_ClipPlane aPlane = *inIt;
1555 double aDx = 0.0, aDy = 0.0, aDz = 0.0;
1556 aPlane.OrientationToXYZ( aDx, aDy, aDz );
1558 gp_Pnt anOrigin( aPlane.X, aPlane.Y, aPlane.Z );
1559 gp_Dir aDirection( aDx, aDy, aDz );
1561 myInternalClipPlanes.Append( createClipPlane( gp_Pln( anOrigin, aDirection ), aPlane.IsOn ) );
1562 myClipPlanes.push_back( aPlane );
1565 // 3. Apply clipping planes
1566 AIS_ListOfInteractive aList;
1567 myAISContext->DisplayedObjects (aList);
1568 for ( AIS_ListIteratorOfListOfInteractive anIter (aList); anIter.More(); anIter.Next() ) {
1569 Handle(AIS_InteractiveObject) anObj = anIter.Value();
1570 Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (anObj);
1571 if (!aShape.IsNull() && aShape->IsClippable()) {
1572 aShape->SetClipPlanes(myInternalClipPlanes);
1578 Returns the clipping planes applied to the displayed objects.
1580 ClipPlanesList OCCViewer_Viewer::getClipPlanes() const {
1581 return myClipPlanes;
1584 Applies clipping planes to given object objects
1586 void OCCViewer_Viewer::applyExistingClipPlanesToObject (const Handle(AIS_InteractiveObject)& theObject)
1588 Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (theObject);
1589 if (!aShape.IsNull() && aShape->IsClippable())
1591 aShape->SetClipPlanes (myInternalClipPlanes);
1596 Returns the pointer to the clipping dialog box.
1598 OCCViewer_ClippingDlg* OCCViewer_Viewer::getClippingDlg() const{
1599 return myClippingDlg;
1604 Stores pointer to the clipping dialog box.
1606 void OCCViewer_Viewer::setClippingDlg(OCCViewer_ClippingDlg* theDlg) {
1607 if(myClippingDlg != theDlg) {
1608 myClippingDlg = theDlg;
1613 bool OCCViewer_Viewer::enableDrawMode( bool on )
1615 //!! To be done for view windows
1616 if ( !myViewManager )
1620 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
1621 for ( int i = 0; i < (int)wins.count(); i++ )
1623 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
1625 prev = prev || win->enableDrawMode( on );