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 "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>
72 Get data for supported background modes: gradient types, identifiers and supported image formats
74 QString OCCViewer_Viewer::backgroundData( QStringList& gradList, QIntList& idList, QIntList& txtList )
76 gradList << tr("GT_HORIZONTALGRADIENT") << tr("GT_VERTICALGRADIENT") <<
77 tr("GT_FIRSTDIAGONALGRADIENT") << tr("GT_SECONDDIAGONALGRADIENT") <<
78 tr("GT_FIRSTCORNERGRADIENT") << tr("GT_SECONDCORNERGRADIENT") <<
79 tr("GT_THIRDCORNERGRADIENT") << tr("GT_FORTHCORNERGRADIENT");
80 idList << HorizontalGradient << VerticalGradient <<
81 Diagonal1Gradient << Diagonal2Gradient <<
82 Corner1Gradient << Corner2Gradient <<
83 Corner3Gradient << Corner4Gradient;
84 txtList << Qtx::CenterTexture << Qtx::TileTexture << Qtx::StretchTexture;
85 return tr("BG_IMAGE_FILES");
89 Get data for supported stereo pair modes: stereo types and identifiers
91 void OCCViewer_Viewer::stereoData( QStringList& typeList, QIntList& idList)
93 typeList << tr("ST_QUADBUFFER") << tr("ST_ANAGLYPH") <<
94 tr("ST_ROWINTERLACED") << tr("ST_COLUMNINTERLACED") <<
95 tr("ST_CHESSBOARD") << tr("ST_SIDEBYSIDE") <<
97 idList << QuadBufferType << AnaglyphType <<
98 RowInterlacedType << ColumnInterlacedType <<
99 ChessBoardType << SideBySideType <<
105 \param DisplayTrihedron - is trihedron displayed
107 OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
109 myBackgrounds(4, Qtx::BackgroundData( Qt::black )),
112 myTrihedronSize(100),
113 myClippingDlg (NULL),
114 myIsUseLocalSelection(false)
116 // init CasCade viewers
117 myV3dViewer = OCCViewer_VService::CreateViewer( TCollection_ExtendedString("Viewer3d").ToExtString() );
118 //myV3dViewer->Init(); // to avoid creation of the useless perspective view (see OCCT issue 0024267)
122 myAISContext = new AIS_InteractiveContext( myV3dViewer );
123 myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_LocalSelected)->SetColor( Quantity_NOC_WHITE );
124 myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_Selected)->SetColor( Quantity_NOC_WHITE );
126 // display isoline on planar faces (box for ex.)
127 myAISContext->IsoOnPlane( true );
129 // create color scale
130 myColorScale = new AIS_ColorScale();
131 myColorScale->SetZLayer( Graphic3d_ZLayerId_TopOSD );
132 myColorScale->SetTransformPersistence( Graphic3d_TransformPers::FromDeprecatedParams( Graphic3d_TMF_2d, gp_Pnt(-1, -1, 0) ) );
134 /* create trihedron */
135 if ( DisplayTrihedron )
137 Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement(gp::XOY());
138 myTrihedron = new AIS_Trihedron(anAxis);
139 myTrihedron->SetInfiniteState( Standard_True );
141 Quantity_Color Col(193/255., 205/255., 193/255., Quantity_TOC_RGB);
142 //myTrihedron->SetColor( Col );
143 myTrihedron->SetArrowColor( Col.Name() );
144 myTrihedron->SetSize(100);
145 Handle(Prs3d_Drawer) drawer = myTrihedron->Attributes();
146 if (drawer->HasOwnDatumAspect()) {
147 Handle(Prs3d_DatumAspect) daspect = drawer->DatumAspect();
148 daspect->FirstAxisAspect()->SetColor(Quantity_Color(1.0, 0.0, 0.0, Quantity_TOC_RGB));
149 daspect->SecondAxisAspect()->SetColor(Quantity_Color(0.0, 1.0, 0.0, Quantity_TOC_RGB));
150 daspect->ThirdAxisAspect()->SetColor(Quantity_Color(0.0, 0.0, 1.0, Quantity_TOC_RGB));
154 // set interaction style to standard
155 myInteractionStyle = 0;
157 // set zooming style to standard
161 myPreselectionEnabled = true;
164 mySelectionEnabled = true;
165 myMultiSelectionEnabled = true;
167 // set projection type to orthographic
168 myProjectionType = 0;
169 // set stereo parameters
171 myAnaglyphFilter = 0;
172 myToReverseStereo = 0;
174 myQuadBufferSupport = 0;
175 myStereographicFocusType = 1;
176 myInterocularDistanceType = 1;
177 myStereographicFocusValue = 1.0;
178 myInterocularDistanceValue = 0.05;
179 //set clipping color and texture to standard
180 myClippingColor = QColor( 50, 50, 50 );
181 myDefaultTextureUsed = true;
182 myClippingTexture = QString();
183 myTextureModulated = true;
184 myClippingTextureScale = 1.0;
191 OCCViewer_Viewer::~OCCViewer_Viewer()
193 myAISContext.Nullify();
194 myV3dViewer.Nullify();
199 \return background color of viewer
201 QColor OCCViewer_Viewer::backgroundColor() const
203 return backgroundColor(0);
207 \return background data of viewer
209 Qtx::BackgroundData OCCViewer_Viewer::background() const
211 return background(0);
215 Sets background color [obsolete]
216 \param c - new background color
218 void OCCViewer_Viewer::setBackgroundColor( const QColor& c )
220 setBackgroundColor( 0, c );
225 \param d - new background data
227 void OCCViewer_Viewer::setBackground( const Qtx::BackgroundData& theBackground )
229 setBackground( 0, theBackground );
233 Start initialization of view window
234 \param view - view window to be initialized
236 void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view )
240 view->initSketchers();
241 view->setInteractionStyle( interactionStyle() );
242 view->setProjectionType( projectionType() );
243 view->setStereoType( stereoType() );
244 view->setAnaglyphFilter( anaglyphFilter() );
245 view->setStereographicFocus( stereographicFocusType(), stereographicFocusValue() );
246 view->setInterocularDistance( interocularDistanceType(), interocularDistanceValue() );
247 view->setReverseStereo( isReverseStereo() );
248 view->setVSync( isVSync() );
249 view->setQuadBufferSupport( isQuadBufferSupport() );
250 view->setZoomingStyle( zoomingStyle() );
251 view->enablePreselection( isPreselectionEnabled() );
252 view->enableSelection( isSelectionEnabled() );
254 OCCViewer_ViewPort3d* vp3d = view->getViewPort();
257 // connect signal from viewport
258 connect(vp3d, SIGNAL(vpClosed(OCCViewer_ViewPort3d*)), this, SLOT(onViewClosed(OCCViewer_ViewPort3d*)));
259 connect(vp3d, SIGNAL(vpMapped(OCCViewer_ViewPort3d*)), this, SLOT(onViewMapped(OCCViewer_ViewPort3d*)));
265 Creates new view window
266 \param theDesktop - main window of application
268 SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop )
271 OCCViewer_ViewFrame* view = new OCCViewer_ViewFrame(theDesktop, this);
272 // get main view window (created by view frame)
273 OCCViewer_ViewWindow* vw = view->getView(OCCViewer_ViewFrame::MAIN_VIEW);
274 // initialize main view window
276 // set default background for view window
277 vw->setBackground( background(0) ); // 0 means MAIN_VIEW (other views are not yet created here)
283 Sets new view manager
284 \param theViewManager - new view manager
286 void OCCViewer_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
288 SUIT_ViewModel::setViewManager(theViewManager);
289 if (theViewManager) {
290 connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
291 this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
293 connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)),
294 this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
296 connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
297 this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
299 connect(theViewManager, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)),
300 this, SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*)));
305 SLOT: called on mouse button press, stores current mouse position as start point for transformations
307 void OCCViewer_Viewer::onMousePress(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
309 myStartPnt.setX(theEvent->x()); myStartPnt.setY(theEvent->y());
313 SLOT: called on mouse move, processes transformation or hilighting
315 void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
317 if (!mySelectionEnabled) return;
318 if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
320 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
322 myCurPnt.setX(theEvent->x()); myCurPnt.setY(theEvent->y());
324 if ( isSelectionEnabled() && isPreselectionEnabled() ) {
325 if (aView->getViewPort()->isBusy()) {
326 QCoreApplication::processEvents();
327 return; // Check that the ViewPort initialization completed
328 // To Prevent call move event if the View port is not initialized
331 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
332 if ( !aView3d.IsNull() ) {
333 myAISContext->MoveTo( theEvent->x(), theEvent->y(), aView3d, Standard_True );
340 SLOT: called on mouse button release, finishes transformation or selection
342 void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
344 if (!mySelectionEnabled) return;
345 if (theEvent->button() != Qt::LeftButton) return;
346 if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
348 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
352 myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y());
353 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
356 myAISContext->ClearCurrents( false );
360 if (myStartPnt == myEndPnt)
362 if ( !isPreselectionEnabled() ) {
363 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
364 if ( !aView3d.IsNull() ) {
365 myAISContext->MoveTo( myEndPnt.x(), myEndPnt.y(), aView3d, Standard_True );
369 if (aHasShift && myMultiSelectionEnabled)
370 myAISContext->ShiftSelect( Standard_True );
372 myAISContext->Select( Standard_True );
376 if (aHasShift && myMultiSelectionEnabled)
377 myAISContext->ShiftSelect(myStartPnt.x(), myStartPnt.y(),
378 myEndPnt.x(), myEndPnt.y(),
379 aView->getViewPort()->getView(), Standard_False );
381 myAISContext->Select(myStartPnt.x(), myStartPnt.y(),
382 myEndPnt.x(), myEndPnt.y(),
383 aView->getViewPort()->getView(), Standard_False );
385 int Nb = myAISContext->NbSelected();
386 if( Nb>1 && !myMultiSelectionEnabled )
388 myAISContext->InitSelected();
389 Handle( SelectMgr_EntityOwner ) anOwner = myAISContext->SelectedOwner();
390 if( !anOwner.IsNull() )
392 myAISContext->ClearSelected( Standard_False );
393 myAISContext->AddOrRemoveSelected( anOwner, Standard_False );
397 myAISContext->UpdateCurrentViewer();
399 emit selectionChanged();
403 SLOT: called on key press, processes selection in "key free" interaction style
405 void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEvent)
407 if (!mySelectionEnabled) return;
409 OCCViewer_ViewWindow* aView = qobject_cast<OCCViewer_ViewWindow*>( theWindow );
410 if ( !aView ) return;
412 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
414 switch ( theEvent->key() ) {
417 myAISContext->ClearCurrents( false );
421 if ( !isPreselectionEnabled() ) {
422 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
423 if ( !aView3d.IsNull() ) {
424 myAISContext->MoveTo(myCurPnt.x(), myCurPnt.y(), aView3d, Standard_True );
428 if (aHasShift && myMultiSelectionEnabled)
429 myAISContext->ShiftSelect( Standard_True );
431 myAISContext->Select( Standard_True );
433 emit selectionChanged();
437 if ( isPreselectionEnabled() ) {
438 if ( useLocalSelection() )
439 getAISContext()->HilightNextDetected( aView->getViewPort()->getView() );
443 if ( isPreselectionEnabled() ) {
444 if ( getAISContext()->HasOpenedContext() )
445 getAISContext()->HilightPreviousDetected( aView->getViewPort()->getView() );
453 void OCCViewer_Viewer::onViewClosed(OCCViewer_ViewPort3d*)
455 Standard_Integer aViewsNb = 0;
456 for ( myV3dViewer->InitActiveViews(); myV3dViewer->MoreActiveViews(); myV3dViewer->NextActiveViews())
458 if ( aViewsNb < 2 ) {
459 //clean up presentations before last view is closed
460 myAISContext->RemoveAll(Standard_False);
464 void OCCViewer_Viewer::onViewMapped(OCCViewer_ViewPort3d* viewPort)
466 setTrihedronShown( true );
467 bool showStaticTrihedron = true;
468 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
469 if ( resMgr ) showStaticTrihedron = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
470 viewPort->showStaticTrihedron( showStaticTrihedron );
473 int OCCViewer_Viewer::getTopLayerId()
475 if ( myTopLayerId == 0 && !myAISContext->CurrentViewer().IsNull() )
476 myAISContext->CurrentViewer()->AddZLayer( myTopLayerId );
482 \return interaction style
484 int OCCViewer_Viewer::interactionStyle() const
486 return myInteractionStyle;
490 Sets interaction style: 0 - standard, 1 - keyboard free interaction
491 \param theStyle - new interaction style
493 void OCCViewer_Viewer::setInteractionStyle( const int theStyle )
495 myInteractionStyle = theStyle;
496 //!! To be done for view windows
497 if ( !myViewManager )
500 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
501 for ( int i = 0; i < (int)wins.count(); i++ )
503 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
505 win->setInteractionStyle( theStyle );
510 \return projection type
512 int OCCViewer_Viewer::projectionType() const
514 return myProjectionType;
518 Sets projection type: 0 - orthographic, 1 - perspective
519 \param theType - new projection type
521 void OCCViewer_Viewer::setProjectionType( const int theType )
523 if ( myProjectionType != theType ) {
524 if ( theType != OCCViewer_ViewWindow::Stereo )
525 myProjectionType = theType;
527 if ( !myViewManager )
530 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
531 for ( int i = 0; i < (int)wins.count(); i++ )
533 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
535 win->setProjectionType( (OCCViewer_ViewWindow::ProjectionType)theType );
543 int OCCViewer_Viewer::stereoType() const
550 \param theType - new stereo type
552 void OCCViewer_Viewer::setStereoType( const int theType )
554 myStereoType = theType;
556 if ( !myViewManager )
559 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
560 for ( int i = 0; i < (int)wins.count(); i++ )
562 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
564 win->setStereoType( (OCCViewer_ViewWindow::StereoType)theType );
569 \return stereographic focus type
571 int OCCViewer_Viewer::stereographicFocusType() const
573 return myStereographicFocusType;
577 \return stereographic focus value
579 double OCCViewer_Viewer::stereographicFocusValue() const
581 return myStereographicFocusValue;
585 Sets stereographic focus parameters
586 \param theType - new stereographic focus type
587 \param theValue - new stereographic focus value
589 void OCCViewer_Viewer::setStereographicFocus( const int theType, const double theValue )
591 myStereographicFocusType = theType;
592 myStereographicFocusValue = theValue;
594 if ( !myViewManager )
597 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
598 for ( int i = 0; i < (int)wins.count(); i++ )
600 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
602 win->setStereographicFocus( (OCCViewer_ViewWindow::FocusIODType)theType, theValue );
607 \return stereographic focus type
609 int OCCViewer_Viewer::interocularDistanceType() const
611 return myInterocularDistanceType;
615 \return stereographic focus value
617 double OCCViewer_Viewer::interocularDistanceValue() const
619 return myInterocularDistanceValue;
623 Sets interocular distance parameters
624 \param theType - new IOD type
625 \param theValue - new IOD value
627 void OCCViewer_Viewer::setInterocularDistance( const int theType, const double theValue )
629 myInterocularDistanceType = theType;
630 myInterocularDistanceValue = theValue;
632 if ( !myViewManager )
635 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
636 for ( int i = 0; i < (int)wins.count(); i++ )
638 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
640 win->setInterocularDistance( (OCCViewer_ViewWindow::FocusIODType)theType, theValue );
645 \return anaglyph filter
647 int OCCViewer_Viewer::anaglyphFilter() const
649 return myAnaglyphFilter;
654 \param theType - new anaglyph filter
656 void OCCViewer_Viewer::setAnaglyphFilter( const int theType )
658 myAnaglyphFilter = theType;
660 if ( !myViewManager )
663 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
664 for ( int i = 0; i < (int)wins.count(); i++ )
666 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
668 win->setAnaglyphFilter( (OCCViewer_ViewWindow::AnaglyphFilter)theType );
673 \return reverse stereo
675 bool OCCViewer_Viewer::isReverseStereo() const
677 return myToReverseStereo;
682 \param theReverse - enable/disable reverse mode
684 void OCCViewer_Viewer::setReverseStereo( const bool theReverse )
686 myToReverseStereo = theReverse;
688 if ( !myViewManager )
691 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
692 for ( int i = 0; i < (int)wins.count(); i++ )
694 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
696 win->setReverseStereo( theReverse );
703 bool OCCViewer_Viewer::isVSync() const
710 \param theEnable - enable/disable V-Sync mode
712 void OCCViewer_Viewer::setVSync( const bool theEnable )
714 myVSyncMode = theEnable;
716 if ( !myViewManager )
719 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
720 for ( int i = 0; i < (int)wins.count(); i++ )
722 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
724 win->setVSync( theEnable );
729 \return support quad-buffered stereo
731 bool OCCViewer_Viewer::isQuadBufferSupport() const
733 return myQuadBufferSupport;
737 Set support quad-buffered stereo
738 \param theEnable - enable/disable support quad-buffered stereo
740 void OCCViewer_Viewer::setQuadBufferSupport( const bool theEnable )
742 myQuadBufferSupport = theEnable;
744 if ( !myViewManager )
747 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
748 for ( int i = 0; i < (int)wins.count(); i++ )
750 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
752 win->setQuadBufferSupport( theEnable );
757 \return zooming style
759 int OCCViewer_Viewer::zoomingStyle() const
761 return myZoomingStyle;
765 Sets zooming style: 0 - standard, 1 - advanced (at cursor)
766 \param theStyle - new zooming style
768 void OCCViewer_Viewer::setZoomingStyle( const int theStyle )
770 myZoomingStyle = theStyle;
771 //!! To be done for view windows
772 if ( !myViewManager )
775 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
776 for ( int i = 0; i < (int)wins.count(); i++ )
778 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
780 win->setZoomingStyle( theStyle );
785 \return true if preselection is enabled
787 bool OCCViewer_Viewer::isPreselectionEnabled() const
789 return myPreselectionEnabled;
793 Enables/disables preselection
794 \param isEnabled - new status
796 void OCCViewer_Viewer::enablePreselection(bool isEnabled)
798 myPreselectionEnabled = isEnabled;
800 if ( !myViewManager )
803 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
804 for ( int i = 0; i < (int)wins.count(); i++ )
806 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
808 win->enablePreselection( isEnabled );
814 \return true if selection is enabled
816 bool OCCViewer_Viewer::isSelectionEnabled() const
818 return mySelectionEnabled;
822 Enables/disables selection
823 \param isEnabled - new status
825 void OCCViewer_Viewer::enableSelection(bool isEnabled)
827 mySelectionEnabled = isEnabled;
829 //!! To be done for view windows
830 if ( !myViewManager )
833 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
834 for ( int i = 0; i < (int)wins.count(); i++ )
836 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
838 win->updateEnabledDrawMode();
839 win->enableSelection( isEnabled );
844 //clear current selection in the viewer
846 myAISContext->ClearSelected( Standard_True );
852 Sets multiselection enabled status
853 \param isEnabled - new status
855 void OCCViewer_Viewer::enableMultiselection(bool isEnable)
857 myMultiSelectionEnabled = isEnable;
858 //!! To be done for view windows
859 if ( !myViewManager )
862 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
863 for ( int i = 0; i < (int)wins.count(); i++ )
865 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
867 win->updateEnabledDrawMode();
872 Sets a color of the clipped region
873 \param theColor - a new color of the clipped region
875 void OCCViewer_Viewer::setClippingColor( const QColor& theColor )
877 myClippingColor = theColor;
879 if( myInternalClipPlanes.IsEmpty() )
882 Graphic3d_MaterialAspect aMaterialAspect = Graphic3d_MaterialAspect();
883 aMaterialAspect.SetColor( Quantity_Color( theColor.redF(), theColor.greenF(),
884 theColor.blueF(), Quantity_TOC_RGB ) );
886 for( int i = 1; i <= myInternalClipPlanes.Size(); i++ )
887 myInternalClipPlanes.Value(i)->SetCappingMaterial( aMaterialAspect );
893 \return clipping color
895 QColor OCCViewer_Viewer::clippingColor() const
897 return myClippingColor;
900 // initialize a texture for clipped region
901 Handle(Graphic3d_Texture2Dmanual) initClippingTexture( const bool isDefault, const QString& theTexture,
902 const bool isModulate, const double theScale )
904 QString aTextureFile = isDefault ? ":images/hatch.png" : theTexture;
905 QPixmap px( aTextureFile );
906 const Handle(Image_PixMap) aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage() );
907 Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual( aPixmap );
908 if( aTexture->IsDone() ) {
909 aTexture->EnableRepeat();
910 isModulate ? aTexture->EnableModulate() : aTexture->DisableModulate();
911 aTexture->GetParams()->SetScale( Graphic3d_Vec2( 1/( theScale*100 ), -1 / ( theScale*100 ) ) );
917 Sets default texture parameters
918 \param isDefault - use/non-use default texture
919 \param theTexture - new texture of the clipped region
920 \param isModulate - enable/disable texture modulate mode
921 \param theScale - scale factor.
923 void OCCViewer_Viewer::setClippingTextureParams( const bool isDefault, const QString& theTexture,
924 const bool isModulate, const double theScale )
926 myDefaultTextureUsed = isDefault;
927 myClippingTexture = theTexture;
928 myTextureModulated = isModulate;
929 myClippingTextureScale = theScale;
931 if( myInternalClipPlanes.IsEmpty() )
934 Handle(Graphic3d_Texture2Dmanual) aTexture =
935 initClippingTexture( myDefaultTextureUsed, myClippingTexture,
936 myTextureModulated, myClippingTextureScale );
938 for( int i = 1; i <= myInternalClipPlanes.Size(); i++ )
939 myInternalClipPlanes.Value(i)->SetCappingTexture( aTexture );
945 \return true if default texture is used
947 bool OCCViewer_Viewer::isDefaultTextureUsed() const
949 return myDefaultTextureUsed;
953 \return clipping texture
955 QString OCCViewer_Viewer::clippingTexture() const
957 return myClippingTexture;
961 \return true if texture is modulated
963 bool OCCViewer_Viewer::isTextureModulated() const
965 return myTextureModulated;
969 \return scale factor of texture
971 double OCCViewer_Viewer::clippingTextureScale() const
973 return myClippingTextureScale;
977 Builds popup for occ viewer
979 void OCCViewer_Viewer::contextMenuPopup(QMenu* thePopup)
981 thePopup->addAction( tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
982 thePopup->addAction( tr( "MEN_CHANGE_BACKGROUND" ), this, SLOT( onChangeBackground() ) );
984 thePopup->addSeparator();
986 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
988 //Support of several toolbars in the popup menu
989 QList<QToolBar*> lst = aView->findChildren<QToolBar*>();
990 QList<QToolBar*>::const_iterator it = lst.begin(), last = lst.end();
991 for ( ; it!=last; it++ ) {
992 if ( (*it)->parentWidget()->isVisible() )
993 thePopup->addAction( (*it)->toggleViewAction() );
998 SLOT: called on dump view operation is activated, stores scene to raster file
1000 void OCCViewer_Viewer::onDumpView()
1002 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1004 aView->onDumpView();
1008 SLOT: called if background color is to be changed changed, passes new color to view port
1010 void OCCViewer_Viewer::onChangeBackground()
1012 OCCViewer_ViewWindow* aView = dynamic_cast<OCCViewer_ViewWindow*>(myViewManager->getActiveView());
1016 // get supported gradient types
1017 QStringList gradList;
1018 QIntList idList, txtList;
1019 QString formats = backgroundData( gradList, idList, txtList );
1021 // invoke dialog box
1022 Qtx::BackgroundData bgData = QtxBackgroundDialog::getBackground( aView->background(), // initial background
1023 aView, // parent for dialog box
1024 txtList, // allowed texture modes
1025 true, // enable solid color mode
1026 true, // enable gradient mode
1027 false, // disable custom gradient mode
1028 !txtList.isEmpty(), // enable/disable texture mode
1029 gradList, // gradient names
1030 idList, // gradient identifiers
1031 formats ); // image formats
1033 // set chosen background data to the viewer
1034 if ( bgData.isValid() )
1035 aView->setBackground( bgData );
1039 Updates OCC 3D viewer
1041 void OCCViewer_Viewer::update()
1043 if (!myV3dViewer.IsNull())
1044 myV3dViewer->Update();
1046 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1048 aView->updateGravityCoords();
1052 \return objects selected in 3D viewer
1053 \param theList - list to be filled with selected objects
1055 void OCCViewer_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList)
1058 for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected())
1059 theList.Append(myAISContext->SelectedInteractive());
1063 Selects objects in 3D viewer. Other selected objects are left as selected
1064 \param theList - list objects to be selected
1066 void OCCViewer_Viewer::setObjectsSelected(const AIS_ListOfInteractive& theList)
1068 AIS_ListIteratorOfListOfInteractive aIt;
1069 for (aIt.Initialize(theList); aIt.More(); aIt.Next())
1070 myAISContext->AddOrRemoveSelected(aIt.Value(), false);
1071 myAISContext->UpdateCurrentViewer();
1075 Auxiliary method to emit signal selectionChanged()
1077 void OCCViewer_Viewer::performSelectionChanged()
1079 emit selectionChanged();
1083 * Defines default lights
1085 void OCCViewer_Viewer::setDefaultLights()
1087 // clear all light sources
1088 myV3dViewer->InitDefinedLights();
1089 while ( myV3dViewer->MoreDefinedLights() )
1091 myV3dViewer->DelLight( myV3dViewer->DefinedLight() );
1092 myV3dViewer->InitDefinedLights();
1095 // get light source parameters from preferences
1096 QColor aColor = SUIT_Session::session()->resourceMgr()->colorValue( "OCCViewer", "light_color", QColor( 0, 0, 0 ) );
1097 double aDx = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dx", 0.0 );
1098 double aDy = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dy", 0.0 );
1099 double aDz = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dz", -1.0 );
1101 Handle(V3d_DirectionalLight) aLight =
1102 new V3d_DirectionalLight( myV3dViewer, V3d_Zneg, OCCViewer::color( aColor ).Name(), Standard_True );
1103 if( !( aDx == 0 && aDy == 0 && aDz == 0 ) )
1104 aLight->SetDirection( aDx, aDy, aDz );
1105 myV3dViewer->SetLightOn( aLight );
1106 myV3dViewer->SetLightOn( new V3d_AmbientLight( myV3dViewer ) );
1110 Hilights/unhilights object in viewer
1111 \param obj - object to be updated
1112 \param hilight - if it is true, object will be hilighted, otherwise it will be unhilighted
1113 \param update - update current viewer
1115 bool OCCViewer_Viewer::highlight( const Handle(AIS_InteractiveObject)& obj,
1116 bool hilight, bool update )
1118 bool isInLocal = myAISContext->HasOpenedContext();
1122 if ( hilight && !myAISContext->IsSelected( obj ) )
1123 myAISContext->AddOrRemoveCurrentObject( obj, false );
1124 else if ( !hilight && myAISContext->IsSelected( obj ) )
1125 myAISContext->AddOrRemoveCurrentObject( obj, false );
1129 myV3dViewer->Redraw();
1135 Unhilights all objects in viewer
1136 \param updateviewer - update current viewer
1138 bool OCCViewer_Viewer::unHighlightAll( bool updateviewer, bool unselect )
1140 if ( myAISContext->HasOpenedContext() ) {
1142 myAISContext->ClearSelected( updateviewer );
1144 myAISContext->UnhilightSelected( updateviewer );
1148 myAISContext->ClearCurrents( updateviewer );
1150 myAISContext->UnhilightCurrents( updateviewer );
1158 \return true if object is in viewer or in collector
1159 \param obj - object to be checked
1160 \param onlyInViewer - search object only in viewer (so object must be displayed)
1162 bool OCCViewer_Viewer::isInViewer( const Handle(AIS_InteractiveObject)& obj,
1165 AIS_ListOfInteractive List;
1166 myAISContext->DisplayedObjects(List);
1168 AIS_ListIteratorOfListOfInteractive ite(List);
1169 for ( ; ite.More(); ite.Next() )
1170 if( ite.Value()==obj )
1177 \return true if object is displayed in viewer
1178 \param obj - object to be checked
1180 bool OCCViewer_Viewer::isVisible( const Handle(AIS_InteractiveObject)& obj )
1182 return myAISContext->IsDisplayed( obj );
1186 Sets color of object
1187 \param obj - object to be updated
1188 \param color - new color
1189 \param update - update current viewer
1191 void OCCViewer_Viewer::setColor( const Handle(AIS_InteractiveObject)& obj,
1192 const QColor& color,
1197 Quantity_Color CSFColor = Quantity_Color ( color.red() / 255.,
1198 color.green() / 255.,
1199 color.blue() / 255.,
1201 obj->SetColor( CSFColor );
1205 myV3dViewer->Update();
1209 Changes display mode of object
1210 \param obj - object to be processed
1211 \param mode - new display mode
1212 \param update - update current viewer
1214 void OCCViewer_Viewer::switchRepresentation( const Handle(AIS_InteractiveObject)& obj,
1215 int mode, bool update )
1217 myAISContext->SetDisplayMode( obj, (Standard_Integer)mode, update );
1219 myV3dViewer->Update();
1223 Changes transparency of object
1224 \param obj - object to be processed
1225 \param trans - new transparency
1226 \param update - update current viewer
1228 void OCCViewer_Viewer::setTransparency( const Handle(AIS_InteractiveObject)& obj,
1229 float trans, bool update )
1231 myAISContext->SetTransparency( obj, trans, false );
1232 myAISContext->Redisplay( obj, Standard_False, Standard_True );
1234 myV3dViewer->Update();
1237 bool OCCViewer_Viewer::isColorScaleVisible() const
1239 return !myColorScale.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myColorScale );
1242 void OCCViewer_Viewer::setColorScaleShown( const bool on )
1244 if ( myColorScale.IsNull() )
1248 if ( !myAISContext->IsDisplayed( myColorScale ) )
1249 myAISContext->Display( myColorScale, Standard_True );
1250 myAISContext->Redisplay( myColorScale, Standard_True, Standard_True );
1254 if ( myAISContext->IsDisplayed( myColorScale ) )
1255 myAISContext->Erase( myColorScale, Standard_True );
1260 Changes visibility of trihedron to opposite
1262 void OCCViewer_Viewer::toggleTrihedron()
1264 setTrihedronShown( !isTrihedronVisible() );
1268 \return true if trihedron is visible
1270 bool OCCViewer_Viewer::isTrihedronVisible() const
1272 return !myTrihedron.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myTrihedron );
1276 Sets visibility state of trihedron
1277 \param on - new state
1280 void OCCViewer_Viewer::setTrihedronShown( const bool on )
1282 if ( myTrihedron.IsNull() )
1286 myAISContext->Display( myTrihedron,
1288 -1 /* selection mode */,
1289 Standard_True /* update viewer*/,
1290 Standard_False /* allow decomposition */,
1291 AIS_DS_Displayed /* display status */);
1292 myAISContext->Deactivate( myTrihedron );
1295 myAISContext->Erase( myTrihedron , Standard_True );
1300 \return trihedron size
1302 double OCCViewer_Viewer::trihedronSize() const
1305 if ( !myTrihedron.IsNull() )
1306 sz = myTrihedron->Size();
1311 Changes trihedron size
1312 \param sz - new size
1314 void OCCViewer_Viewer::setTrihedronSize( const double sz, bool isRelative )
1316 if ( myTrihedronSize != sz || isRelative != myIsRelative) {
1317 myTrihedronSize = sz;
1318 myIsRelative = isRelative;
1324 Set number of isolines
1325 \param u - u-isolines (first parametric co-ordinate)
1326 \param v - v-isolines (second parametric co-ordinate)
1328 void OCCViewer_Viewer::setIsos( const int u, const int v )
1330 Handle(AIS_InteractiveContext) ic = getAISContext();
1334 ic->SetIsoNumber( u, AIS_TOI_IsoU );
1335 ic->SetIsoNumber( v, AIS_TOI_IsoV );
1339 \return number of isolines
1340 \param u - to return u-isolines (first parametric co-ordinate)
1341 \param v - to return v-isolines (second parametric co-ordinate)
1343 void OCCViewer_Viewer::isos( int& u, int& v ) const
1345 Handle(AIS_InteractiveContext) ic = getAISContext();
1348 u = ic->IsoNumber( AIS_TOI_IsoU );
1349 v = ic->IsoNumber( AIS_TOI_IsoV );
1354 * Returns a new OCCViewer_ViewWindow instance which will be placed as a sub window in ViewFrame
1356 OCCViewer_ViewWindow* OCCViewer_Viewer::createSubWindow()
1358 return new OCCViewer_ViewWindow(0, this);
1362 Sets using local selection state
1363 \param theIsUseLocalSelection - state
1365 void OCCViewer_Viewer::setUseLocalSelection(bool theIsUseLocalSelection)
1367 myIsUseLocalSelection = theIsUseLocalSelection;
1371 * Returns true if local context is opened or view model local state is set
1373 bool OCCViewer_Viewer::useLocalSelection() const
1375 if (myIsUseLocalSelection)
1378 Handle(AIS_InteractiveContext) ic = getAISContext();
1379 return !ic.IsNull() && ic->HasOpenedContext();
1383 QColor OCCViewer_Viewer::backgroundColor( int theViewId ) const
1385 return background( theViewId ).color();
1388 Qtx::BackgroundData OCCViewer_Viewer::background( int theViewId ) const
1390 return ( theViewId >= 0 && theViewId < myBackgrounds.count() ) ? myBackgrounds[theViewId] : Qtx::BackgroundData();
1394 void OCCViewer_Viewer::setBackgroundColor( int theViewId, const QColor& theColor )
1396 if ( theColor.isValid() ) {
1397 Qtx::BackgroundData bg = background( theViewId );
1398 bg.setColor( theColor );
1399 setBackground( theViewId, bg );
1403 void OCCViewer_Viewer::setBackground( int theViewId, const Qtx::BackgroundData& theBackground )
1405 if ( theBackground.isValid() && theViewId >= 0 && theViewId < myBackgrounds.count() )
1406 myBackgrounds[theViewId] = theBackground;
1411 Set the show static trihedron flag
1413 void OCCViewer_Viewer::setStaticTrihedronDisplayed(const bool on)
1415 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1416 if ( aView ) aView->showStaticTrihedron( on );
1420 Get new and current trihedron size corresponding to the current model size
1422 bool OCCViewer_Viewer::computeTrihedronSize( double& theNewSize, double& theSize )
1427 //SRN: BUG IPAL8996, a usage of method ActiveView without an initialization
1428 Handle(V3d_Viewer) viewer = getViewer3d();
1429 viewer->InitActiveViews();
1430 if(!viewer->MoreActiveViews()) return false;
1432 Handle(V3d_View) view3d = viewer->ActiveView();
1435 if ( view3d.IsNull() )
1438 double aMaxSide = computeSceneSize( view3d );
1441 // The boundary box of the view may be initialized but nullified
1442 // (case of infinite objects)
1443 if ( aMaxSide < Precision::Confusion() )
1446 float aSizeInPercents = SUIT_Session::session()->resourceMgr()->doubleValue("3DViewer","trihedron_size", 100.);
1448 static float EPS = 5.0E-3;
1449 theSize = getTrihedron()->Size();
1450 theNewSize = aMaxSide*aSizeInPercents / 100.0;
1452 return fabs( theNewSize - theSize ) > theSize * EPS ||
1453 fabs( theNewSize - theSize ) > theNewSize * EPS;
1457 * Compute scene size
1459 double OCCViewer_Viewer::computeSceneSize(const Handle(V3d_View)& view3d) const
1461 double aMaxSide = 0;
1462 double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
1464 Bnd_Box aBox = view3d->View()->MinMaxValues();
1465 Xmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().X();
1466 Ymin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Y();
1467 Zmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Z();
1468 Xmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().X();
1469 Ymax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Y();
1470 Zmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Z();
1472 if ( Xmin != RealFirst() && Ymin != RealFirst() && Zmin != RealFirst() &&
1473 Xmax != RealLast() && Ymax != RealLast() && Zmax != RealLast() )
1475 aMaxSide = Xmax - Xmin;
1476 if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin;
1477 if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin;
1484 * Update the size of the trihedron
1486 void OCCViewer_Viewer::updateTrihedron() {
1487 if ( myTrihedron.IsNull() )
1491 double newSz, oldSz;
1493 if(computeTrihedronSize(newSz, oldSz))
1494 myTrihedron->SetSize(newSz);
1496 } else if(myTrihedron->Size() != myTrihedronSize) {
1497 myTrihedron->SetSize(myTrihedronSize);
1502 Set number of isolines
1503 \param u - u-isolines (first parametric co-ordinate)
1504 \param v - v-isolines (second parametric co-ordinate)
1506 void OCCViewer_Viewer::setSelectionOptions( bool isPreselectionEnabled, bool isSelectionEnabled )
1508 myPreselectionEnabled = isPreselectionEnabled;
1509 mySelectionEnabled = isSelectionEnabled;
1510 //clear current selection in the viewer
1512 if(!mySelectionEnabled) {
1513 myAISContext->ClearSelected( Standard_True );
1518 Creates clipping plane based on the incoming plane
1520 Handle(Graphic3d_ClipPlane) OCCViewer_Viewer::createClipPlane(const gp_Pln& thePlane, const Standard_Boolean theIsOn)
1522 Handle(Graphic3d_ClipPlane) aGraphic3dPlane = new Graphic3d_ClipPlane( thePlane );
1523 aGraphic3dPlane->SetOn( theIsOn );
1524 aGraphic3dPlane->SetCapping( Standard_True );
1526 // set capping color
1527 Graphic3d_MaterialAspect aMaterialAspect = Graphic3d_MaterialAspect();
1528 aMaterialAspect.SetColor( Quantity_Color( myClippingColor.redF(), myClippingColor.greenF(),
1529 myClippingColor.blueF(), Quantity_TOC_RGB ) );
1530 aGraphic3dPlane->SetCappingMaterial( aMaterialAspect );
1532 // set capping texture
1533 aGraphic3dPlane->SetCappingTexture( initClippingTexture( myDefaultTextureUsed, myClippingTexture,
1534 myTextureModulated, myClippingTextureScale ) );
1536 return aGraphic3dPlane;
1539 Applies clipping planes to clippable objects
1541 void OCCViewer_Viewer::setClipPlanes(ClipPlanesList theList)
1543 // 1. Remove existing clipping planes
1544 myClipPlanes.clear();
1545 myInternalClipPlanes.Clear();
1547 // 2. Create new clipping planes
1548 ClipPlanesList::iterator inIt = theList.begin();
1549 for (;inIt != theList.end(); inIt++ )
1551 OCCViewer_ClipPlane aPlane = *inIt;
1553 double aDx = 0.0, aDy = 0.0, aDz = 0.0;
1554 aPlane.OrientationToXYZ( aDx, aDy, aDz );
1556 gp_Pnt anOrigin( aPlane.X, aPlane.Y, aPlane.Z );
1557 gp_Dir aDirection( aDx, aDy, aDz );
1559 myInternalClipPlanes.Append( createClipPlane( gp_Pln( anOrigin, aDirection ), aPlane.IsOn ) );
1560 myClipPlanes.push_back( aPlane );
1563 // 3. Apply clipping planes
1564 AIS_ListOfInteractive aList;
1565 myAISContext->DisplayedObjects (aList);
1566 for ( AIS_ListIteratorOfListOfInteractive anIter (aList); anIter.More(); anIter.Next() ) {
1567 Handle(AIS_InteractiveObject) anObj = anIter.Value();
1568 Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (anObj);
1569 if (!aShape.IsNull() && aShape->IsClippable()) {
1570 aShape->SetClipPlanes(myInternalClipPlanes);
1576 Returns the clipping planes applied to the displayed objects.
1578 ClipPlanesList OCCViewer_Viewer::getClipPlanes() const {
1579 return myClipPlanes;
1582 Applies clipping planes to given object objects
1584 void OCCViewer_Viewer::applyExistingClipPlanesToObject (const Handle(AIS_InteractiveObject)& theObject)
1586 Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (theObject);
1587 if (!aShape.IsNull() && aShape->IsClippable())
1589 aShape->SetClipPlanes (myInternalClipPlanes);
1594 Returns the pointer to the clipping dialog box.
1596 OCCViewer_ClippingDlg* OCCViewer_Viewer::getClippingDlg() const{
1597 return myClippingDlg;
1602 Stores pointer to the clipping dialog box.
1604 void OCCViewer_Viewer::setClippingDlg(OCCViewer_ClippingDlg* theDlg) {
1605 if(myClippingDlg != theDlg) {
1606 myClippingDlg = theDlg;
1611 bool OCCViewer_Viewer::enableDrawMode( bool on )
1613 //!! To be done for view windows
1614 if ( !myViewManager )
1618 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
1619 for ( int i = 0; i < (int)wins.count(); i++ )
1621 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
1623 prev = prev || win->enableDrawMode( on );