1 // Copyright (C) 2007-2019 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 "QtxActionToolMgr.h"
41 #include "QtxBackgroundTool.h"
44 #include <QApplication>
45 #include <QColorDialog>
46 #include <QFileDialog>
50 #include <QMouseEvent>
52 #include <QDesktopWidget>
54 #include <AIS_Axis.hxx>
55 #include <Prs3d_Drawer.hxx>
56 #include <AIS_ListIteratorOfListOfInteractive.hxx>
58 #include <Graphic3d_Texture2Dmanual.hxx>
59 #include <Graphic3d_MaterialAspect.hxx>
60 #include <Graphic3d_TextureParams.hxx>
62 #include <Geom_Axis2Placement.hxx>
63 #include <Prs3d_Drawer.hxx>
64 #include <Prs3d_DatumAspect.hxx>
65 #include <Prs3d_LineAspect.hxx>
66 #include <Prs3d_TextAspect.hxx>
68 #include <V3d_DirectionalLight.hxx>
69 #include <V3d_AmbientLight.hxx>
71 #include <Basics_OCCTVersion.hxx>
74 Get data for supported background modes: gradient types, identifiers and supported image formats
76 QString OCCViewer_Viewer::backgroundData( QStringList& gradList, QIntList& idList, QIntList& txtList )
78 gradList << tr("GT_HORIZONTALGRADIENT") << tr("GT_VERTICALGRADIENT") <<
79 tr("GT_FIRSTDIAGONALGRADIENT") << tr("GT_SECONDDIAGONALGRADIENT") <<
80 tr("GT_FIRSTCORNERGRADIENT") << tr("GT_SECONDCORNERGRADIENT") <<
81 tr("GT_THIRDCORNERGRADIENT") << tr("GT_FORTHCORNERGRADIENT");
82 idList << HorizontalGradient << VerticalGradient <<
83 Diagonal1Gradient << Diagonal2Gradient <<
84 Corner1Gradient << Corner2Gradient <<
85 Corner3Gradient << Corner4Gradient;
86 txtList << Qtx::CenterTexture << Qtx::TileTexture << Qtx::StretchTexture;
87 return tr("BG_IMAGE_FILES");
91 Get data for supported stereo pair modes: stereo types and identifiers
93 void OCCViewer_Viewer::stereoData( QStringList& typeList, QIntList& idList)
95 typeList << tr("ST_QUADBUFFER") << tr("ST_ANAGLYPH") <<
96 tr("ST_ROWINTERLACED") << tr("ST_COLUMNINTERLACED") <<
97 tr("ST_CHESSBOARD") << tr("ST_SIDEBYSIDE") <<
99 idList << QuadBufferType << AnaglyphType <<
100 RowInterlacedType << ColumnInterlacedType <<
101 ChessBoardType << SideBySideType <<
107 \param DisplayTrihedron - is trihedron displayed
109 OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
111 myBackgrounds(4, Qtx::BackgroundData( Qt::black )),
114 myTrihedronSize(100),
115 #if OCC_VERSION_LARGE <= 0x07030000
116 myIsUseLocalSelection(false),
120 // init CasCade viewers
121 myV3dViewer = OCCViewer_VService::CreateViewer( TCollection_ExtendedString("Viewer3d").ToExtString() );
122 //myV3dViewer->Init(); // to avoid creation of the useless perspective view (see OCCT issue 0024267)
126 myAISContext = new AIS_InteractiveContext( myV3dViewer );
127 myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_LocalSelected)->SetColor( Quantity_NOC_WHITE );
128 myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_Selected)->SetColor( Quantity_NOC_WHITE );
130 // display isoline on planar faces (box for ex.)
131 myAISContext->IsoOnPlane( true );
133 // create color scale
134 myColorScale = new AIS_ColorScale();
135 myColorScale->SetZLayer( Graphic3d_ZLayerId_TopOSD );
136 myColorScale->SetTransformPersistence( Graphic3d_TransformPers::FromDeprecatedParams( Graphic3d_TMF_2d, gp_Pnt(-1, -1, 0) ) );
138 /* create trihedron */
139 if ( DisplayTrihedron )
141 Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement(gp::XOY());
142 myTrihedron = new AIS_Trihedron(anAxis);
143 myTrihedron->SetInfiniteState( Standard_True );
145 Quantity_Color Col(193/255., 205/255., 193/255., Quantity_TOC_RGB);
146 //myTrihedron->SetColor( Col );
147 myTrihedron->SetArrowColor( Col.Name() );
148 myTrihedron->SetSize(100);
149 Handle(Prs3d_Drawer) drawer = myTrihedron->Attributes();
150 if (drawer->HasOwnDatumAspect()) {
151 Handle(Prs3d_DatumAspect) daspect = drawer->DatumAspect();
152 daspect->FirstAxisAspect()->SetColor(Quantity_Color(1.0, 0.0, 0.0, Quantity_TOC_RGB));
153 daspect->SecondAxisAspect()->SetColor(Quantity_Color(0.0, 1.0, 0.0, Quantity_TOC_RGB));
154 daspect->ThirdAxisAspect()->SetColor(Quantity_Color(0.0, 0.0, 1.0, Quantity_TOC_RGB));
158 // set interaction style to standard
159 myInteractionStyle = 0;
161 // set zooming style to standard
165 myPreselectionEnabled = true;
168 mySelectionEnabled = true;
169 myMultiSelectionEnabled = true;
171 // set projection type to orthographic
172 myProjectionType = 0;
173 // set stereo parameters
175 myAnaglyphFilter = 0;
176 myToReverseStereo = 0;
178 myQuadBufferSupport = 0;
179 myStereographicFocusType = 1;
180 myInterocularDistanceType = 1;
181 myStereographicFocusValue = 1.0;
182 myInterocularDistanceValue = 0.05;
183 //set clipping color and texture to standard
184 myClippingColor = QColor( 50, 50, 50 );
185 myDefaultTextureUsed = true;
186 myClippingTexture = QString();
187 myTextureModulated = true;
188 myClippingTextureScale = 1.0;
195 OCCViewer_Viewer::~OCCViewer_Viewer()
197 myAISContext.Nullify();
198 myV3dViewer.Nullify();
203 \return background color of viewer
205 QColor OCCViewer_Viewer::backgroundColor() const
207 return backgroundColor(0);
211 \return background data of viewer
213 Qtx::BackgroundData OCCViewer_Viewer::background() const
215 return background(0);
219 Sets background color [obsolete]
220 \param c - new background color
222 void OCCViewer_Viewer::setBackgroundColor( const QColor& c )
224 setBackgroundColor( 0, c );
229 \param d - new background data
231 void OCCViewer_Viewer::setBackground( const Qtx::BackgroundData& theBackground )
233 setBackground( 0, theBackground );
237 Start initialization of view window
238 \param view - view window to be initialized
240 void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view )
244 view->initSketchers();
245 view->setInteractionStyle( interactionStyle() );
246 view->setProjectionType( projectionType() );
247 view->setStereoType( stereoType() );
248 view->setAnaglyphFilter( anaglyphFilter() );
249 view->setStereographicFocus( stereographicFocusType(), stereographicFocusValue() );
250 view->setInterocularDistance( interocularDistanceType(), interocularDistanceValue() );
251 view->setReverseStereo( isReverseStereo() );
252 view->setVSync( isVSync() );
253 view->setQuadBufferSupport( isQuadBufferSupport() );
254 view->setZoomingStyle( zoomingStyle() );
255 view->enablePreselection( isPreselectionEnabled() );
256 view->enableSelection( isSelectionEnabled() );
258 OCCViewer_ViewPort3d* vp3d = view->getViewPort();
261 // connect signal from viewport
262 connect(vp3d, SIGNAL(vpClosed(OCCViewer_ViewPort3d*)), this, SLOT(onViewClosed(OCCViewer_ViewPort3d*)));
263 connect(vp3d, SIGNAL(vpMapped(OCCViewer_ViewPort3d*)), this, SLOT(onViewMapped(OCCViewer_ViewPort3d*)));
269 Creates new view window
270 \param theDesktop - main window of application
272 SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop )
275 OCCViewer_ViewFrame* view = new OCCViewer_ViewFrame(theDesktop, this);
276 // get main view window (created by view frame)
277 OCCViewer_ViewWindow* vw = view->getView(OCCViewer_ViewFrame::MAIN_VIEW);
278 // initialize main view window
280 // set default background for view window
281 vw->setBackground( background(0) ); // 0 means MAIN_VIEW (other views are not yet created here)
287 Sets new view manager
288 \param theViewManager - new view manager
290 void OCCViewer_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
292 SUIT_ViewModel::setViewManager(theViewManager);
293 if (theViewManager) {
294 connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
295 this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
297 connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)),
298 this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
300 connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
301 this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
303 connect(theViewManager, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)),
304 this, SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*)));
309 SLOT: called on mouse button press, stores current mouse position as start point for transformations
311 void OCCViewer_Viewer::onMousePress(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
313 myStartPnt.setX(theEvent->x()); myStartPnt.setY(theEvent->y());
317 SLOT: called on mouse move, processes transformation or hilighting
319 void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
321 if (!mySelectionEnabled) return;
322 if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
324 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
326 myCurPnt.setX(theEvent->x()); myCurPnt.setY(theEvent->y());
328 if ( isSelectionEnabled() && isPreselectionEnabled() ) {
329 if (aView->getViewPort()->isBusy()) {
330 QCoreApplication::processEvents();
331 return; // Check that the ViewPort initialization completed
332 // To Prevent call move event if the View port is not initialized
335 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
336 if ( !aView3d.IsNull() ) {
337 myAISContext->MoveTo( theEvent->x(), theEvent->y(), aView3d, Standard_True );
344 SLOT: called on mouse button release, finishes transformation or selection
346 void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
348 if (!mySelectionEnabled) return;
349 if (theEvent->button() != Qt::LeftButton) return;
350 if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
352 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
356 myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y());
357 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
360 myAISContext->ClearSelected( false );
364 if (myStartPnt == myEndPnt)
366 if ( !isPreselectionEnabled() ) {
367 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
368 if ( !aView3d.IsNull() ) {
369 myAISContext->MoveTo( myEndPnt.x(), myEndPnt.y(), aView3d, Standard_True );
373 if (aHasShift && myMultiSelectionEnabled)
374 myAISContext->ShiftSelect( Standard_True );
376 myAISContext->Select( Standard_True );
380 if (aHasShift && myMultiSelectionEnabled)
381 myAISContext->ShiftSelect(myStartPnt.x(), myStartPnt.y(),
382 myEndPnt.x(), myEndPnt.y(),
383 aView->getViewPort()->getView(), Standard_False );
385 myAISContext->Select(myStartPnt.x(), myStartPnt.y(),
386 myEndPnt.x(), myEndPnt.y(),
387 aView->getViewPort()->getView(), Standard_False );
389 int Nb = myAISContext->NbSelected();
390 if( Nb>1 && !myMultiSelectionEnabled )
392 myAISContext->InitSelected();
393 Handle( SelectMgr_EntityOwner ) anOwner = myAISContext->SelectedOwner();
394 if( !anOwner.IsNull() )
396 myAISContext->ClearSelected( Standard_False );
397 myAISContext->AddOrRemoveSelected( anOwner, Standard_False );
401 myAISContext->UpdateCurrentViewer();
403 emit selectionChanged();
407 SLOT: called on key press, processes selection in "key free" interaction style
409 void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEvent)
411 if (!mySelectionEnabled) return;
413 OCCViewer_ViewWindow* aView = qobject_cast<OCCViewer_ViewWindow*>( theWindow );
414 if ( !aView ) return;
416 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
418 switch ( theEvent->key() ) {
421 myAISContext->ClearSelected( false );
425 if ( !isPreselectionEnabled() ) {
426 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
427 if ( !aView3d.IsNull() ) {
428 myAISContext->MoveTo(myCurPnt.x(), myCurPnt.y(), aView3d, Standard_True );
432 if (aHasShift && myMultiSelectionEnabled)
433 myAISContext->ShiftSelect( Standard_True );
435 myAISContext->Select( Standard_True );
437 emit selectionChanged();
441 if ( isPreselectionEnabled() ) {
442 #if OCC_VERSION_LARGE <= 0x07030000
443 if ( useLocalSelection() )
445 getAISContext()->HilightNextDetected( aView->getViewPort()->getView() );
449 if ( isPreselectionEnabled() ) {
450 #if OCC_VERSION_LARGE <= 0x07030000
451 if ( useLocalSelection() )
453 getAISContext()->HilightPreviousDetected( aView->getViewPort()->getView() );
461 void OCCViewer_Viewer::onViewClosed(OCCViewer_ViewPort3d*)
463 Standard_Integer aViewsNb = 0;
464 for ( myV3dViewer->InitActiveViews(); myV3dViewer->MoreActiveViews(); myV3dViewer->NextActiveViews())
466 if ( aViewsNb < 2 ) {
467 //clean up presentations before last view is closed
468 myAISContext->RemoveAll(Standard_False);
472 void OCCViewer_Viewer::onViewMapped(OCCViewer_ViewPort3d* viewPort)
474 setTrihedronShown( true );
475 bool showStaticTrihedron = true;
476 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
477 if ( resMgr ) showStaticTrihedron = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
478 viewPort->showStaticTrihedron( showStaticTrihedron );
481 int OCCViewer_Viewer::getTopLayerId()
483 if ( myTopLayerId == 0 && !myAISContext->CurrentViewer().IsNull() )
484 myAISContext->CurrentViewer()->AddZLayer( myTopLayerId );
490 \return interaction style
492 int OCCViewer_Viewer::interactionStyle() const
494 return myInteractionStyle;
498 Sets interaction style: 0 - standard, 1 - keyboard free interaction
499 \param theStyle - new interaction style
501 void OCCViewer_Viewer::setInteractionStyle( const int theStyle )
503 myInteractionStyle = theStyle;
504 //!! To be done for view windows
505 if ( !myViewManager )
508 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
509 for ( int i = 0; i < (int)wins.count(); i++ )
511 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
513 win->setInteractionStyle( theStyle );
518 \return projection type
520 int OCCViewer_Viewer::projectionType() const
522 return myProjectionType;
526 Sets projection type: 0 - orthographic, 1 - perspective
527 \param theType - new projection type
529 void OCCViewer_Viewer::setProjectionType( const int theType )
531 if ( myProjectionType != theType ) {
532 if ( theType != OCCViewer_ViewWindow::Stereo )
533 myProjectionType = theType;
535 if ( !myViewManager )
538 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
539 for ( int i = 0; i < (int)wins.count(); i++ )
541 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
543 win->setProjectionType( (OCCViewer_ViewWindow::ProjectionType)theType );
551 int OCCViewer_Viewer::stereoType() const
558 \param theType - new stereo type
560 void OCCViewer_Viewer::setStereoType( const int theType )
562 myStereoType = theType;
564 if ( !myViewManager )
567 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
568 for ( int i = 0; i < (int)wins.count(); i++ )
570 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
572 win->setStereoType( (OCCViewer_ViewWindow::StereoType)theType );
577 \return stereographic focus type
579 int OCCViewer_Viewer::stereographicFocusType() const
581 return myStereographicFocusType;
585 \return stereographic focus value
587 double OCCViewer_Viewer::stereographicFocusValue() const
589 return myStereographicFocusValue;
593 Sets stereographic focus parameters
594 \param theType - new stereographic focus type
595 \param theValue - new stereographic focus value
597 void OCCViewer_Viewer::setStereographicFocus( const int theType, const double theValue )
599 myStereographicFocusType = theType;
600 myStereographicFocusValue = theValue;
602 if ( !myViewManager )
605 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
606 for ( int i = 0; i < (int)wins.count(); i++ )
608 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
610 win->setStereographicFocus( (OCCViewer_ViewWindow::FocusIODType)theType, theValue );
615 \return stereographic focus type
617 int OCCViewer_Viewer::interocularDistanceType() const
619 return myInterocularDistanceType;
623 \return stereographic focus value
625 double OCCViewer_Viewer::interocularDistanceValue() const
627 return myInterocularDistanceValue;
631 Sets interocular distance parameters
632 \param theType - new IOD type
633 \param theValue - new IOD value
635 void OCCViewer_Viewer::setInterocularDistance( const int theType, const double theValue )
637 myInterocularDistanceType = theType;
638 myInterocularDistanceValue = theValue;
640 if ( !myViewManager )
643 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
644 for ( int i = 0; i < (int)wins.count(); i++ )
646 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
648 win->setInterocularDistance( (OCCViewer_ViewWindow::FocusIODType)theType, theValue );
653 \return anaglyph filter
655 int OCCViewer_Viewer::anaglyphFilter() const
657 return myAnaglyphFilter;
662 \param theType - new anaglyph filter
664 void OCCViewer_Viewer::setAnaglyphFilter( const int theType )
666 myAnaglyphFilter = theType;
668 if ( !myViewManager )
671 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
672 for ( int i = 0; i < (int)wins.count(); i++ )
674 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
676 win->setAnaglyphFilter( (OCCViewer_ViewWindow::AnaglyphFilter)theType );
681 \return reverse stereo
683 bool OCCViewer_Viewer::isReverseStereo() const
685 return myToReverseStereo;
690 \param theReverse - enable/disable reverse mode
692 void OCCViewer_Viewer::setReverseStereo( const bool theReverse )
694 myToReverseStereo = theReverse;
696 if ( !myViewManager )
699 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
700 for ( int i = 0; i < (int)wins.count(); i++ )
702 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
704 win->setReverseStereo( theReverse );
711 bool OCCViewer_Viewer::isVSync() const
718 \param theEnable - enable/disable V-Sync mode
720 void OCCViewer_Viewer::setVSync( const bool theEnable )
722 myVSyncMode = theEnable;
724 if ( !myViewManager )
727 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
728 for ( int i = 0; i < (int)wins.count(); i++ )
730 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
732 win->setVSync( theEnable );
737 \return support quad-buffered stereo
739 bool OCCViewer_Viewer::isQuadBufferSupport() const
741 return myQuadBufferSupport;
745 Set support quad-buffered stereo
746 \param theEnable - enable/disable support quad-buffered stereo
748 void OCCViewer_Viewer::setQuadBufferSupport( const bool theEnable )
750 myQuadBufferSupport = theEnable;
752 if ( !myViewManager )
755 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
756 for ( int i = 0; i < (int)wins.count(); i++ )
758 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
760 win->setQuadBufferSupport( theEnable );
765 \return zooming style
767 int OCCViewer_Viewer::zoomingStyle() const
769 return myZoomingStyle;
773 Sets zooming style: 0 - standard, 1 - advanced (at cursor)
774 \param theStyle - new zooming style
776 void OCCViewer_Viewer::setZoomingStyle( const int theStyle )
778 myZoomingStyle = theStyle;
779 //!! To be done for view windows
780 if ( !myViewManager )
783 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
784 for ( int i = 0; i < (int)wins.count(); i++ )
786 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
788 win->setZoomingStyle( theStyle );
793 \return true if preselection is enabled
795 bool OCCViewer_Viewer::isPreselectionEnabled() const
797 return myPreselectionEnabled;
801 Enables/disables preselection
802 \param isEnabled - new status
804 void OCCViewer_Viewer::enablePreselection(bool isEnabled)
806 myPreselectionEnabled = isEnabled;
808 if ( !myViewManager )
811 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
812 for ( int i = 0; i < (int)wins.count(); i++ )
814 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
816 win->enablePreselection( isEnabled );
822 \return true if selection is enabled
824 bool OCCViewer_Viewer::isSelectionEnabled() const
826 return mySelectionEnabled;
830 Enables/disables selection
831 \param isEnabled - new status
833 void OCCViewer_Viewer::enableSelection(bool isEnabled)
835 mySelectionEnabled = isEnabled;
837 //!! To be done for view windows
838 if ( !myViewManager )
841 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
842 for ( int i = 0; i < (int)wins.count(); i++ )
844 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
846 win->updateEnabledDrawMode();
847 win->enableSelection( isEnabled );
852 //clear current selection in the viewer
854 myAISContext->ClearSelected( Standard_True );
860 Sets multiselection enabled status
861 \param isEnabled - new status
863 void OCCViewer_Viewer::enableMultiselection(bool isEnable)
865 myMultiSelectionEnabled = isEnable;
866 //!! To be done for view windows
867 if ( !myViewManager )
870 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
871 for ( int i = 0; i < (int)wins.count(); i++ )
873 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
875 win->updateEnabledDrawMode();
880 Sets a color of the clipped region
881 \param theColor - a new color of the clipped region
883 void OCCViewer_Viewer::setClippingColor( const QColor& theColor )
885 myClippingColor = theColor;
887 if( myInternalClipPlanes.IsEmpty() )
890 Graphic3d_MaterialAspect aMaterialAspect = Graphic3d_MaterialAspect();
891 aMaterialAspect.SetColor( Quantity_Color( theColor.redF(), theColor.greenF(),
892 theColor.blueF(), Quantity_TOC_RGB ) );
893 #if OCC_VERSION_LARGE <= 0x07030000
894 for( int i = 1; i <= myInternalClipPlanes.Size(); i++ )
895 myInternalClipPlanes.Value(i)->SetCappingMaterial( aMaterialAspect );
897 for ( Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt ( myInternalClipPlanes ); aPlaneIt.More(); aPlaneIt.Next() )
898 aPlaneIt.Value()->SetCappingMaterial( aMaterialAspect );
904 \return clipping color
906 QColor OCCViewer_Viewer::clippingColor() const
908 return myClippingColor;
911 // initialize a texture for clipped region
912 Handle(Graphic3d_Texture2Dmanual) initClippingTexture( const bool isDefault, const QString& theTexture,
913 const bool isModulate, const double theScale )
915 QString aTextureFile = isDefault ? ":images/hatch.png" : theTexture;
916 QPixmap px( aTextureFile );
917 const Handle(Image_PixMap) aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage() );
918 Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual( aPixmap );
919 if( aTexture->IsDone() ) {
920 aTexture->EnableRepeat();
921 isModulate ? aTexture->EnableModulate() : aTexture->DisableModulate();
922 aTexture->GetParams()->SetScale( Graphic3d_Vec2( 1/( theScale*100 ), -1 / ( theScale*100 ) ) );
928 Sets default texture parameters
929 \param isDefault - use/non-use default texture
930 \param theTexture - new texture of the clipped region
931 \param isModulate - enable/disable texture modulate mode
932 \param theScale - scale factor.
934 void OCCViewer_Viewer::setClippingTextureParams( const bool isDefault, const QString& theTexture,
935 const bool isModulate, const double theScale )
937 myDefaultTextureUsed = isDefault;
938 myClippingTexture = theTexture;
939 myTextureModulated = isModulate;
940 myClippingTextureScale = theScale;
942 if( myInternalClipPlanes.IsEmpty() )
945 Handle(Graphic3d_Texture2Dmanual) aTexture =
946 initClippingTexture( myDefaultTextureUsed, myClippingTexture,
947 myTextureModulated, myClippingTextureScale );
948 #if OCC_VERSION_LARGE <= 0x07030000
949 for( int i = 1; i <= myInternalClipPlanes.Size(); i++ )
950 myInternalClipPlanes.Value(i)->SetCappingTexture( aTexture );
952 for ( Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt ( myInternalClipPlanes ); aPlaneIt.More(); aPlaneIt.Next() )
953 aPlaneIt.Value()->SetCappingTexture( aTexture );
960 \return true if default texture is used
962 bool OCCViewer_Viewer::isDefaultTextureUsed() const
964 return myDefaultTextureUsed;
968 \return clipping texture
970 QString OCCViewer_Viewer::clippingTexture() const
972 return myClippingTexture;
976 \return true if texture is modulated
978 bool OCCViewer_Viewer::isTextureModulated() const
980 return myTextureModulated;
984 \return scale factor of texture
986 double OCCViewer_Viewer::clippingTextureScale() const
988 return myClippingTextureScale;
992 Builds popup for occ viewer
994 void OCCViewer_Viewer::contextMenuPopup(QMenu* thePopup)
996 thePopup->addAction( tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
997 thePopup->addAction( tr( "MEN_CHANGE_BACKGROUND" ), this, SLOT( onChangeBackground() ) );
999 thePopup->addSeparator();
1001 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1003 //Support of several toolbars in the popup menu
1004 QList<QToolBar*> lst = aView->findChildren<QToolBar*>();
1005 QList<QToolBar*>::const_iterator it = lst.begin(), last = lst.end();
1006 for ( ; it!=last; it++ ) {
1007 if ( (*it)->parentWidget()->isVisible() )
1008 thePopup->addAction( (*it)->toggleViewAction() );
1013 SLOT: called on dump view operation is activated, stores scene to raster file
1015 void OCCViewer_Viewer::onDumpView()
1017 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1019 aView->onDumpView();
1023 SLOT: called if background color is to be changed changed, passes new color to view port
1025 void OCCViewer_Viewer::onChangeBackground()
1027 OCCViewer_ViewWindow* aView = dynamic_cast<OCCViewer_ViewWindow*>(myViewManager->getActiveView());
1031 // get supported gradient types
1032 QStringList gradList;
1033 QIntList idList, txtList;
1034 QString formats = backgroundData( gradList, idList, txtList );
1036 // invoke dialog box
1037 Qtx::BackgroundData bgData = QtxBackgroundDialog::getBackground( aView->background(), // initial background
1038 aView, // parent for dialog box
1039 txtList, // allowed texture modes
1040 true, // enable solid color mode
1041 true, // enable gradient mode
1042 false, // disable custom gradient mode
1043 !txtList.isEmpty(), // enable/disable texture mode
1044 gradList, // gradient names
1045 idList, // gradient identifiers
1046 formats ); // image formats
1048 // set chosen background data to the viewer
1049 if ( bgData.isValid() )
1050 aView->setBackground( bgData );
1054 Updates OCC 3D viewer
1056 void OCCViewer_Viewer::update()
1058 if (!myV3dViewer.IsNull())
1059 myV3dViewer->Update();
1061 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1063 aView->updateGravityCoords();
1067 \return objects selected in 3D viewer
1068 \param theList - list to be filled with selected objects
1070 void OCCViewer_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList)
1073 for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected())
1074 theList.Append(myAISContext->SelectedInteractive());
1078 Selects objects in 3D viewer. Other selected objects are left as selected
1079 \param theList - list objects to be selected
1081 void OCCViewer_Viewer::setObjectsSelected(const AIS_ListOfInteractive& theList)
1083 AIS_ListIteratorOfListOfInteractive aIt;
1084 for (aIt.Initialize(theList); aIt.More(); aIt.Next())
1085 myAISContext->AddOrRemoveSelected(aIt.Value(), false);
1086 myAISContext->UpdateCurrentViewer();
1090 Auxiliary method to emit signal selectionChanged()
1092 void OCCViewer_Viewer::performSelectionChanged()
1094 emit selectionChanged();
1098 * Defines default lights
1100 void OCCViewer_Viewer::setDefaultLights()
1102 // clear all light sources
1103 myV3dViewer->InitDefinedLights();
1104 while ( myV3dViewer->MoreDefinedLights() )
1106 myV3dViewer->DelLight( myV3dViewer->DefinedLight() );
1107 myV3dViewer->InitDefinedLights();
1110 // get light source parameters from preferences
1111 QColor aColor = SUIT_Session::session()->resourceMgr()->colorValue( "OCCViewer", "light_color", QColor( 0, 0, 0 ) );
1112 double aDx = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dx", 0.0 );
1113 double aDy = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dy", 0.0 );
1114 double aDz = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dz", -1.0 );
1116 Handle(V3d_DirectionalLight) aLight =
1117 new V3d_DirectionalLight( myV3dViewer, V3d_Zneg, OCCViewer::color( aColor ).Name(), Standard_True );
1118 if( !( aDx == 0 && aDy == 0 && aDz == 0 ) )
1119 aLight->SetDirection( aDx, aDy, aDz );
1120 myV3dViewer->SetLightOn( aLight );
1121 myV3dViewer->SetLightOn( new V3d_AmbientLight( myV3dViewer ) );
1125 Hilights/unhilights object in viewer
1126 \param obj - object to be updated
1127 \param hilight - if it is true, object will be hilighted, otherwise it will be unhilighted
1128 \param update - update current viewer
1130 bool OCCViewer_Viewer::highlight( const Handle(AIS_InteractiveObject)& obj,
1131 bool hilight, bool update )
1133 if( !obj.IsNull() ) {
1134 #if OCC_VERSION_LARGE <= 0x07030000
1135 if( !myAISContext->HasOpenedContext() )
1138 if ( hilight && !myAISContext->IsSelected( obj ) )
1139 myAISContext->AddOrRemoveSelected( obj, false );
1140 else if ( !hilight && myAISContext->IsSelected( obj ) )
1141 myAISContext->AddOrRemoveSelected( obj, false );
1142 #if OCC_VERSION_LARGE <= 0x07030000
1148 myV3dViewer->Redraw();
1154 Unhilights all objects in viewer
1155 \param updateviewer - update current viewer
1157 bool OCCViewer_Viewer::unHighlightAll( bool updateviewer, bool unselect )
1159 #if OCC_VERSION_LARGE <= 0x07030000
1160 if ( myAISContext->HasOpenedContext() ) {
1163 myAISContext->ClearSelected( updateviewer );
1165 myAISContext->UnhilightSelected( updateviewer );
1167 #if OCC_VERSION_LARGE <= 0x07030000
1174 \return true if object is in viewer or in collector
1175 \param obj - object to be checked
1176 \param onlyInViewer - search object only in viewer (so object must be displayed)
1178 bool OCCViewer_Viewer::isInViewer( const Handle(AIS_InteractiveObject)& obj,
1181 AIS_ListOfInteractive List;
1182 myAISContext->DisplayedObjects(List);
1184 AIS_ListIteratorOfListOfInteractive ite(List);
1185 for ( ; ite.More(); ite.Next() )
1186 if( ite.Value()==obj )
1193 \return true if object is displayed in viewer
1194 \param obj - object to be checked
1196 bool OCCViewer_Viewer::isVisible( const Handle(AIS_InteractiveObject)& obj )
1198 return myAISContext->IsDisplayed( obj );
1202 Sets color of object
1203 \param obj - object to be updated
1204 \param color - new color
1205 \param update - update current viewer
1207 void OCCViewer_Viewer::setColor( const Handle(AIS_InteractiveObject)& obj,
1208 const QColor& color,
1213 Quantity_Color CSFColor = Quantity_Color ( color.red() / 255.,
1214 color.green() / 255.,
1215 color.blue() / 255.,
1217 obj->SetColor( CSFColor );
1221 myV3dViewer->Update();
1225 Changes display mode of object
1226 \param obj - object to be processed
1227 \param mode - new display mode
1228 \param update - update current viewer
1230 void OCCViewer_Viewer::switchRepresentation( const Handle(AIS_InteractiveObject)& obj,
1231 int mode, bool update )
1233 myAISContext->SetDisplayMode( obj, (Standard_Integer)mode, update );
1235 myV3dViewer->Update();
1239 Changes transparency of object
1240 \param obj - object to be processed
1241 \param trans - new transparency
1242 \param update - update current viewer
1244 void OCCViewer_Viewer::setTransparency( const Handle(AIS_InteractiveObject)& obj,
1245 float trans, bool update )
1247 myAISContext->SetTransparency( obj, trans, false );
1248 myAISContext->Redisplay( obj, Standard_False, Standard_True );
1250 myV3dViewer->Update();
1253 bool OCCViewer_Viewer::isColorScaleVisible() const
1255 return !myColorScale.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myColorScale );
1258 void OCCViewer_Viewer::setColorScaleShown( const bool on )
1260 if ( myColorScale.IsNull() )
1264 if ( !myAISContext->IsDisplayed( myColorScale ) )
1265 myAISContext->Display( myColorScale, Standard_True );
1266 myAISContext->Redisplay( myColorScale, Standard_True, Standard_True );
1270 if ( myAISContext->IsDisplayed( myColorScale ) )
1271 myAISContext->Erase( myColorScale, Standard_True );
1276 Changes visibility of trihedron to opposite
1278 void OCCViewer_Viewer::toggleTrihedron()
1280 setTrihedronShown( !isTrihedronVisible() );
1284 \return true if trihedron is visible
1286 bool OCCViewer_Viewer::isTrihedronVisible() const
1288 return !myTrihedron.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myTrihedron );
1292 Sets visibility state of trihedron
1293 \param on - new state
1296 void OCCViewer_Viewer::setTrihedronShown( const bool on )
1298 if ( myTrihedron.IsNull() )
1302 myAISContext->Display( myTrihedron,
1304 -1 /* selection mode */,
1305 Standard_True /* update viewer*/,
1306 Standard_False /* allow decomposition */,
1307 AIS_DS_Displayed /* display status */);
1308 myAISContext->Deactivate( myTrihedron );
1311 myAISContext->Erase( myTrihedron , Standard_True );
1316 \return trihedron size
1318 double OCCViewer_Viewer::trihedronSize() const
1321 if ( !myTrihedron.IsNull() )
1322 sz = myTrihedron->Size();
1327 Changes trihedron size
1328 \param sz - new size
1330 void OCCViewer_Viewer::setTrihedronSize( const double sz, bool isRelative )
1332 if ( myTrihedronSize != sz || isRelative != myIsRelative) {
1333 myTrihedronSize = sz;
1334 myIsRelative = isRelative;
1340 Set number of isolines
1341 \param u - u-isolines (first parametric co-ordinate)
1342 \param v - v-isolines (second parametric co-ordinate)
1344 void OCCViewer_Viewer::setIsos( const int u, const int v )
1346 Handle(AIS_InteractiveContext) ic = getAISContext();
1350 ic->SetIsoNumber( u, AIS_TOI_IsoU );
1351 ic->SetIsoNumber( v, AIS_TOI_IsoV );
1355 \return number of isolines
1356 \param u - to return u-isolines (first parametric co-ordinate)
1357 \param v - to return v-isolines (second parametric co-ordinate)
1359 void OCCViewer_Viewer::isos( int& u, int& v ) const
1361 Handle(AIS_InteractiveContext) ic = getAISContext();
1364 u = ic->IsoNumber( AIS_TOI_IsoU );
1365 v = ic->IsoNumber( AIS_TOI_IsoV );
1370 * Returns a new OCCViewer_ViewWindow instance which will be placed as a sub window in ViewFrame
1372 OCCViewer_ViewWindow* OCCViewer_Viewer::createSubWindow()
1374 return new OCCViewer_ViewWindow(0, this);
1377 #if OCC_VERSION_LARGE <= 0x07030000
1379 Sets using local selection state
1380 \param theIsUseLocalSelection - state
1382 void OCCViewer_Viewer::setUseLocalSelection(bool theIsUseLocalSelection)
1384 myIsUseLocalSelection = theIsUseLocalSelection;
1388 * Returns true if local context is opened or view model local state is set
1390 bool OCCViewer_Viewer::useLocalSelection() const
1392 if (myIsUseLocalSelection)
1394 Handle(AIS_InteractiveContext) ic = getAISContext();
1395 return !ic.IsNull() && ic->HasOpenedContext();
1400 QColor OCCViewer_Viewer::backgroundColor( int theViewId ) const
1402 return background( theViewId ).color();
1405 Qtx::BackgroundData OCCViewer_Viewer::background( int theViewId ) const
1407 return ( theViewId >= 0 && theViewId < myBackgrounds.count() ) ? myBackgrounds[theViewId] : Qtx::BackgroundData();
1411 void OCCViewer_Viewer::setBackgroundColor( int theViewId, const QColor& theColor )
1413 if ( theColor.isValid() ) {
1414 Qtx::BackgroundData bg = background( theViewId );
1415 bg.setColor( theColor );
1416 setBackground( theViewId, bg );
1420 void OCCViewer_Viewer::setBackground( int theViewId, const Qtx::BackgroundData& theBackground )
1422 if ( theBackground.isValid() && theViewId >= 0 && theViewId < myBackgrounds.count() )
1423 myBackgrounds[theViewId] = theBackground;
1428 Set the show static trihedron flag
1430 void OCCViewer_Viewer::setStaticTrihedronDisplayed(const bool on)
1432 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1433 if ( aView ) aView->showStaticTrihedron( on );
1437 Get new and current trihedron size corresponding to the current model size
1439 bool OCCViewer_Viewer::computeTrihedronSize( double& theNewSize, double& theSize )
1444 //SRN: BUG IPAL8996, a usage of method ActiveView without an initialization
1445 Handle(V3d_Viewer) viewer = getViewer3d();
1446 viewer->InitActiveViews();
1447 if(!viewer->MoreActiveViews()) return false;
1449 Handle(V3d_View) view3d = viewer->ActiveView();
1452 if ( view3d.IsNull() )
1455 double aMaxSide = computeSceneSize( view3d );
1458 // The boundary box of the view may be initialized but nullified
1459 // (case of infinite objects)
1460 if ( aMaxSide < Precision::Confusion() )
1463 float aSizeInPercents = SUIT_Session::session()->resourceMgr()->doubleValue("3DViewer","trihedron_size", 100.);
1465 static float EPS = 5.0E-3;
1466 theSize = getTrihedron()->Size();
1467 theNewSize = aMaxSide*aSizeInPercents / 100.0;
1469 return fabs( theNewSize - theSize ) > theSize * EPS ||
1470 fabs( theNewSize - theSize ) > theNewSize * EPS;
1474 * Compute scene size
1476 double OCCViewer_Viewer::computeSceneSize(const Handle(V3d_View)& view3d) const
1478 double aMaxSide = 0;
1479 double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
1481 Bnd_Box aBox = view3d->View()->MinMaxValues();
1482 Xmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().X();
1483 Ymin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Y();
1484 Zmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Z();
1485 Xmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().X();
1486 Ymax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Y();
1487 Zmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Z();
1489 if ( Xmin != RealFirst() && Ymin != RealFirst() && Zmin != RealFirst() &&
1490 Xmax != RealLast() && Ymax != RealLast() && Zmax != RealLast() )
1492 aMaxSide = Xmax - Xmin;
1493 if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin;
1494 if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin;
1501 * Update the size of the trihedron
1503 void OCCViewer_Viewer::updateTrihedron() {
1504 if ( myTrihedron.IsNull() )
1508 double newSz, oldSz;
1510 if(computeTrihedronSize(newSz, oldSz))
1511 myTrihedron->SetSize(newSz);
1513 } else if(myTrihedron->Size() != myTrihedronSize) {
1514 myTrihedron->SetSize(myTrihedronSize);
1519 Set number of isolines
1520 \param u - u-isolines (first parametric co-ordinate)
1521 \param v - v-isolines (second parametric co-ordinate)
1523 void OCCViewer_Viewer::setSelectionOptions( bool isPreselectionEnabled, bool isSelectionEnabled )
1525 myPreselectionEnabled = isPreselectionEnabled;
1526 mySelectionEnabled = isSelectionEnabled;
1527 //clear current selection in the viewer
1529 if(!mySelectionEnabled) {
1530 myAISContext->ClearSelected( Standard_True );
1535 Creates clipping plane based on the incoming plane
1537 Handle(Graphic3d_ClipPlane) OCCViewer_Viewer::createClipPlane(const gp_Pln& thePlane, const Standard_Boolean theIsOn)
1539 Handle(Graphic3d_ClipPlane) aGraphic3dPlane = new Graphic3d_ClipPlane( thePlane );
1540 aGraphic3dPlane->SetOn( theIsOn );
1541 aGraphic3dPlane->SetCapping( Standard_True );
1543 // set capping color
1544 Graphic3d_MaterialAspect aMaterialAspect = Graphic3d_MaterialAspect();
1545 aMaterialAspect.SetColor( Quantity_Color( myClippingColor.redF(), myClippingColor.greenF(),
1546 myClippingColor.blueF(), Quantity_TOC_RGB ) );
1547 aGraphic3dPlane->SetCappingMaterial( aMaterialAspect );
1549 // set capping texture
1550 aGraphic3dPlane->SetCappingTexture( initClippingTexture( myDefaultTextureUsed, myClippingTexture,
1551 myTextureModulated, myClippingTextureScale ) );
1553 return aGraphic3dPlane;
1556 Applies clipping planes to clippable objects
1558 void OCCViewer_Viewer::setClipPlanes(ClipPlanesList theList)
1560 // 1. Remove existing clipping planes
1561 myClipPlanes.clear();
1562 myInternalClipPlanes.Clear();
1564 // 2. Create new clipping planes
1565 ClipPlanesList::iterator inIt = theList.begin();
1566 for (;inIt != theList.end(); inIt++ )
1568 OCCViewer_ClipPlane aPlane = *inIt;
1570 double aDx = 0.0, aDy = 0.0, aDz = 0.0;
1571 aPlane.OrientationToXYZ( aDx, aDy, aDz );
1573 gp_Pnt anOrigin( aPlane.X, aPlane.Y, aPlane.Z );
1574 gp_Dir aDirection( aDx, aDy, aDz );
1576 myInternalClipPlanes.Append( createClipPlane( gp_Pln( anOrigin, aDirection ), aPlane.IsOn ) );
1577 myClipPlanes.push_back( aPlane );
1580 // 3. Apply clipping planes
1581 AIS_ListOfInteractive aList;
1582 myAISContext->DisplayedObjects (aList);
1583 for ( AIS_ListIteratorOfListOfInteractive anIter (aList); anIter.More(); anIter.Next() ) {
1584 Handle(AIS_InteractiveObject) anObj = anIter.Value();
1585 Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (anObj);
1586 if (!aShape.IsNull() && aShape->IsClippable()) {
1587 aShape->SetClipPlanes(myInternalClipPlanes);
1593 Returns the clipping planes applied to the displayed objects.
1595 ClipPlanesList OCCViewer_Viewer::getClipPlanes() const {
1596 return myClipPlanes;
1599 Applies clipping planes to given object objects
1601 void OCCViewer_Viewer::applyExistingClipPlanesToObject (const Handle(AIS_InteractiveObject)& theObject)
1603 Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (theObject);
1604 if (!aShape.IsNull() && aShape->IsClippable())
1606 aShape->SetClipPlanes (myInternalClipPlanes);
1611 Returns the pointer to the clipping dialog box.
1613 OCCViewer_ClippingDlg* OCCViewer_Viewer::getClippingDlg() const{
1614 return myClippingDlg;
1619 Stores pointer to the clipping dialog box.
1621 void OCCViewer_Viewer::setClippingDlg(OCCViewer_ClippingDlg* theDlg) {
1622 if(myClippingDlg != theDlg) {
1623 myClippingDlg = theDlg;
1628 bool OCCViewer_Viewer::enableDrawMode( bool on )
1630 //!! To be done for view windows
1631 if ( !myViewManager )
1635 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
1636 for ( int i = 0; i < (int)wins.count(); i++ )
1638 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
1640 prev = prev || win->enableDrawMode( on );