1 // Copyright (C) 2007-2022 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_ViewFrame.h"
25 #include "OCCViewer_VService.h"
26 #include "OCCViewer_ViewPort3d.h"
27 #include "OCCViewer_ClippingDlg.h"
28 #include "OCCViewer_Utilities.h"
30 #include "SUIT_ViewWindow.h"
31 #include "SUIT_ViewManager.h"
32 #include "SUIT_Desktop.h"
33 #include "SUIT_Session.h"
34 #include "SUIT_ResourceMgr.h"
36 #include "ViewerData_AISShape.hxx"
38 #include "QtxActionToolMgr.h"
39 #include "QtxBackgroundTool.h"
42 #include <QApplication>
43 #include <QColorDialog>
44 #include <QFileDialog>
48 #include <QMouseEvent>
50 #include <QDesktopWidget>
52 #include <AIS_Axis.hxx>
53 #include <Prs3d_Drawer.hxx>
54 #include <AIS_ListIteratorOfListOfInteractive.hxx>
55 #include <StdSelect_ViewerSelector3d.hxx>
57 #include <Graphic3d_Texture2Dmanual.hxx>
58 #include <Graphic3d_MaterialAspect.hxx>
59 #include <Graphic3d_TextureParams.hxx>
61 #include <Geom_Axis2Placement.hxx>
62 #include <Prs3d_Drawer.hxx>
63 #include <Prs3d_DatumAspect.hxx>
64 #include <Prs3d_LineAspect.hxx>
65 #include <Prs3d_TextAspect.hxx>
67 #include <V3d_DirectionalLight.hxx>
68 #include <V3d_AmbientLight.hxx>
70 #include <Basics_OCCTVersion.hxx>
74 void setCappingColor(const Handle(Graphic3d_ClipPlane)& plane, const QColor& color)
76 Quantity_Color qcolor( color.redF(), color.greenF(), color.blueF(), Quantity_TOC_RGB );
77 #if OCC_VERSION_LARGE < 0x07040000
78 Graphic3d_MaterialAspect aspect;
79 aspect.SetColor( qcolor );
80 plane->SetCappingMaterial( aspect );
82 plane->SetCappingColor( qcolor );
88 Get data for supported background modes: gradient types, identifiers and supported image formats
90 QString OCCViewer_Viewer::backgroundData( QStringList& gradList, QIntList& idList, QIntList& txtList )
92 gradList << tr("GT_HORIZONTALGRADIENT") << tr("GT_VERTICALGRADIENT") <<
93 tr("GT_FIRSTDIAGONALGRADIENT") << tr("GT_SECONDDIAGONALGRADIENT") <<
94 tr("GT_FIRSTCORNERGRADIENT") << tr("GT_SECONDCORNERGRADIENT") <<
95 tr("GT_THIRDCORNERGRADIENT") << tr("GT_FORTHCORNERGRADIENT");
96 idList << HorizontalGradient << VerticalGradient <<
97 Diagonal1Gradient << Diagonal2Gradient <<
98 Corner1Gradient << Corner2Gradient <<
99 Corner3Gradient << Corner4Gradient;
100 txtList << Qtx::CenterTexture << Qtx::TileTexture << Qtx::StretchTexture;
101 return tr("BG_IMAGE_FILES");
105 Get data for supported stereo pair modes: stereo types and identifiers
107 void OCCViewer_Viewer::stereoData( QStringList& typeList, QIntList& idList)
109 typeList << tr("ST_QUADBUFFER") << tr("ST_ANAGLYPH") <<
110 tr("ST_ROWINTERLACED") << tr("ST_COLUMNINTERLACED") <<
111 tr("ST_CHESSBOARD") << tr("ST_SIDEBYSIDE") <<
113 idList << QuadBufferType << AnaglyphType <<
114 RowInterlacedType << ColumnInterlacedType <<
115 ChessBoardType << SideBySideType <<
121 \param DisplayTrihedron - is trihedron displayed
123 OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
127 myTrihedronSize(100),
128 myBackgrounds(4, Qtx::BackgroundData(Qt::black)),
132 // init CasCade viewers
133 myV3dViewer = OCCViewer_VService::CreateViewer();
134 //myV3dViewer->Init(); // to avoid creation of the useless perspective view (see OCCT issue 0024267)
138 myAISContext = new AIS_InteractiveContext( myV3dViewer );
139 myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_LocalSelected)->SetColor( Quantity_NOC_WHITE );
140 myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_Selected)->SetColor( Quantity_NOC_WHITE );
142 // display isoline on planar faces (box for ex.)
143 myAISContext->IsoOnPlane( true );
145 // create color scale
146 myColorScale = new AIS_ColorScale();
147 myColorScale->SetZLayer( Graphic3d_ZLayerId_TopOSD );
148 #if OCC_VERSION_LARGE < 0x07070000
149 myColorScale->SetTransformPersistence( Graphic3d_TransformPers::FromDeprecatedParams( Graphic3d_TMF_2d, gp_Pnt(-1, -1, 0) ) );
151 myColorScale->SetTransformPersistence( new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER) );
154 /* create trihedron */
155 if ( DisplayTrihedron )
157 Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement(gp::XOY());
158 myTrihedron = new AIS_Trihedron(anAxis);
159 myTrihedron->SetInfiniteState( Standard_True );
161 Quantity_Color Col(193/255., 205/255., 193/255., Quantity_TOC_RGB);
162 //myTrihedron->SetColor( Col );
163 myTrihedron->SetArrowColor( Col.Name() );
164 myTrihedron->SetSize(100);
165 Handle(Prs3d_Drawer) drawer = myTrihedron->Attributes();
166 if (drawer->HasOwnDatumAspect()) {
167 Handle(Prs3d_DatumAspect) daspect = drawer->DatumAspect();
168 daspect->LineAspect(Prs3d_DP_XAxis)->SetColor(Quantity_Color(1.0, 0.0, 0.0, Quantity_TOC_RGB));
169 daspect->LineAspect(Prs3d_DP_YAxis)->SetColor(Quantity_Color(0.0, 1.0, 0.0, Quantity_TOC_RGB));
170 daspect->LineAspect(Prs3d_DP_ZAxis)->SetColor(Quantity_Color(0.0, 0.0, 1.0, Quantity_TOC_RGB));
174 // set interaction style to standard
175 myInteractionStyle = 0;
177 // set zooming style to standard
181 myPreselectionEnabled = true;
184 mySelectionEnabled = true;
185 myMultiSelectionEnabled = true;
187 // set projection type to orthographic
188 myProjectionType = 0;
189 mySelectionStyle = OCCViewer_ViewWindow::RectStyle;
190 // set stereo parameters
192 myAnaglyphFilter = 0;
193 myToReverseStereo = 0;
195 myQuadBufferSupport = 0;
196 myStereographicFocusType = 1;
197 myInterocularDistanceType = 1;
198 myStereographicFocusValue = 1.0;
199 myInterocularDistanceValue = 0.05;
200 //set clipping color and texture to standard
201 myClippingColor = QColor( 50, 50, 50 );
202 myDefaultTextureUsed = true;
203 myClippingTexture = QString();
204 myTextureModulated = true;
205 myClippingTextureScale = 1.0;
212 OCCViewer_Viewer::~OCCViewer_Viewer()
214 myAISContext.Nullify();
215 myV3dViewer.Nullify();
220 \return background color of viewer
222 QColor OCCViewer_Viewer::backgroundColor() const
224 return backgroundColor(0);
228 \return background data of viewer
230 Qtx::BackgroundData OCCViewer_Viewer::background() const
232 return background(0);
236 Sets background color [obsolete]
237 \param c - new background color
239 void OCCViewer_Viewer::setBackgroundColor( const QColor& c )
241 setBackgroundColor( 0, c );
246 \param d - new background data
248 void OCCViewer_Viewer::setBackground( const Qtx::BackgroundData& theBackground )
250 setBackground( 0, theBackground );
254 Start initialization of view window
255 \param view - view window to be initialized
257 void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view )
261 view->initSketchers();
262 view->setInteractionStyle( interactionStyle() );
263 view->setProjectionType( projectionType() );
264 view->setSelectionStyle( selectionStyle() );
265 view->setStereoType( stereoType() );
266 view->setAnaglyphFilter( anaglyphFilter() );
267 view->setStereographicFocus( stereographicFocusType(), stereographicFocusValue() );
268 view->setInterocularDistance( interocularDistanceType(), interocularDistanceValue() );
269 view->setReverseStereo( isReverseStereo() );
270 view->setVSync( isVSync() );
271 view->setQuadBufferSupport( isQuadBufferSupport() );
272 view->setZoomingStyle( zoomingStyle() );
273 view->enablePreselection( isPreselectionEnabled() );
274 view->enableSelection( isSelectionEnabled() );
276 OCCViewer_ViewPort3d* vp3d = view->getViewPort();
279 // connect signal from viewport
280 connect(vp3d, SIGNAL(vpClosed(OCCViewer_ViewPort3d*)), this, SLOT(onViewClosed(OCCViewer_ViewPort3d*)));
281 connect(vp3d, SIGNAL(vpMapped(OCCViewer_ViewPort3d*)), this, SLOT(onViewMapped(OCCViewer_ViewPort3d*)));
287 Creates new view window
288 \param theDesktop - main window of application
290 SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop )
293 OCCViewer_ViewFrame* view = new OCCViewer_ViewFrame(theDesktop, this);
294 // get main view window (created by view frame)
295 OCCViewer_ViewWindow* vw = view->getView(OCCViewer_ViewFrame::MAIN_VIEW);
296 // initialize main view window
298 // set default background for view window
299 vw->setBackground( background(0) ); // 0 means MAIN_VIEW (other views are not yet created here)
305 Sets new view manager
306 \param theViewManager - new view manager
308 void OCCViewer_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
310 SUIT_ViewModel::setViewManager(theViewManager);
311 if (theViewManager) {
312 connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
313 this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
315 connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)),
316 this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
318 connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
319 this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
321 connect(theViewManager, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)),
322 this, SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*)));
327 SLOT: called on mouse button press, stores current mouse position as start point for transformations
329 void OCCViewer_Viewer::onMousePress(SUIT_ViewWindow* /*theWindow*/, QMouseEvent* theEvent)
331 myStartPnt.setX(theEvent->x()); myStartPnt.setY(theEvent->y());
335 SLOT: called on mouse move, processes transformation or hilighting
337 void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
339 if (!mySelectionEnabled) return;
340 if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
342 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
344 myCurPnt.setX(theEvent->x()); myCurPnt.setY(theEvent->y());
346 if ( isSelectionEnabled() && isPreselectionEnabled() ) {
347 if (aView->getViewPort()->isBusy()) {
348 QCoreApplication::processEvents();
349 return; // Check that the ViewPort initialization completed
350 // To Prevent call move event if the View port is not initialized
353 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
354 if ( !aView3d.IsNull() ) {
355 myAISContext->MoveTo( theEvent->x(), theEvent->y(), aView3d, Standard_True );
362 SLOT: called on mouse button release, finishes transformation or selection
364 void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
366 if (!mySelectionEnabled) return;
367 if (theEvent->button() != Qt::LeftButton) return;
368 if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
370 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
374 myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y());
375 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
377 if (myStartPnt == myEndPnt)
380 myAISContext->ClearCurrents( false ); // todo: ClearCurrents is deprecated
383 if ( !isPreselectionEnabled() ) {
384 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
385 if ( !aView3d.IsNull() ) {
386 myAISContext->MoveTo( myEndPnt.x(), myEndPnt.y(), aView3d, Standard_True );
390 if (aHasShift && myMultiSelectionEnabled)
391 myAISContext->ShiftSelect( Standard_True );
393 myAISContext->Select( Standard_True );
394 emit selectionChanged();
399 // if (aHasShift && myMultiSelectionEnabled)
400 // myAISContext->ShiftSelect(myStartPnt.x(), myStartPnt.y(),
401 // myEndPnt.x(), myEndPnt.y(),
402 // aView->getViewPort()->getView(), Standard_False );
404 // myAISContext->Select(myStartPnt.x(), myStartPnt.y(),
405 // myEndPnt.x(), myEndPnt.y(),
406 // aView->getViewPort()->getView(), Standard_False );
408 // int Nb = myAISContext->NbSelected();
409 // if( Nb>1 && !myMultiSelectionEnabled )
411 // myAISContext->InitSelected();
412 // Handle( SelectMgr_EntityOwner ) anOwner = myAISContext->SelectedOwner();
413 // if( !anOwner.IsNull() )
415 // myAISContext->ClearSelected( Standard_False );
416 // myAISContext->AddOrRemoveSelected( anOwner, Standard_False );
420 // myAISContext->UpdateCurrentViewer();
425 SLOT: called on key press, processes selection in "key free" interaction style
427 void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEvent)
429 if (!mySelectionEnabled) return;
431 OCCViewer_ViewWindow* aView = qobject_cast<OCCViewer_ViewWindow*>( theWindow );
432 if ( !aView ) return;
434 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
436 switch ( theEvent->key() ) {
439 myAISContext->ClearCurrents( false ); // todo: ClearCurrents is deprecated
443 if ( !isPreselectionEnabled() ) {
444 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
445 if ( !aView3d.IsNull() ) {
446 myAISContext->MoveTo(myCurPnt.x(), myCurPnt.y(), aView3d, Standard_True );
450 if (aHasShift && myMultiSelectionEnabled)
451 myAISContext->ShiftSelect( Standard_True );
453 myAISContext->Select( Standard_True );
455 emit selectionChanged();
459 if ( isPreselectionEnabled() ) {
460 getAISContext()->HilightNextDetected( aView->getViewPort()->getView() );
464 if ( isPreselectionEnabled() ) {
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 );
561 OCCViewer_ViewWindow::SelectionStyle OCCViewer_Viewer::selectionStyle() const
563 return mySelectionStyle;
566 void OCCViewer_Viewer::setSelectionStyle(OCCViewer_ViewWindow::SelectionStyle theMode)
568 if (mySelectionStyle != theMode) {
569 mySelectionStyle = theMode;
573 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
574 for (int i = 0; i < (int)wins.count(); i++)
576 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>(wins.at(i));
578 win->setSelectionStyle(theMode);
588 int OCCViewer_Viewer::stereoType() const
595 \param theType - new stereo type
597 void OCCViewer_Viewer::setStereoType( const int theType )
599 myStereoType = theType;
601 if ( !myViewManager )
604 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
605 for ( int i = 0; i < (int)wins.count(); i++ )
607 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
609 win->setStereoType( (OCCViewer_ViewWindow::StereoType)theType );
614 \return stereographic focus type
616 int OCCViewer_Viewer::stereographicFocusType() const
618 return myStereographicFocusType;
622 \return stereographic focus value
624 double OCCViewer_Viewer::stereographicFocusValue() const
626 return myStereographicFocusValue;
630 Sets stereographic focus parameters
631 \param theType - new stereographic focus type
632 \param theValue - new stereographic focus value
634 void OCCViewer_Viewer::setStereographicFocus( const int theType, const double theValue )
636 myStereographicFocusType = theType;
637 myStereographicFocusValue = theValue;
639 if ( !myViewManager )
642 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
643 for ( int i = 0; i < (int)wins.count(); i++ )
645 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
647 win->setStereographicFocus( (OCCViewer_ViewWindow::FocusIODType)theType, theValue );
652 \return stereographic focus type
654 int OCCViewer_Viewer::interocularDistanceType() const
656 return myInterocularDistanceType;
660 \return stereographic focus value
662 double OCCViewer_Viewer::interocularDistanceValue() const
664 return myInterocularDistanceValue;
668 Sets interocular distance parameters
669 \param theType - new IOD type
670 \param theValue - new IOD value
672 void OCCViewer_Viewer::setInterocularDistance( const int theType, const double theValue )
674 myInterocularDistanceType = theType;
675 myInterocularDistanceValue = theValue;
677 if ( !myViewManager )
680 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
681 for ( int i = 0; i < (int)wins.count(); i++ )
683 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
685 win->setInterocularDistance( (OCCViewer_ViewWindow::FocusIODType)theType, theValue );
690 \return anaglyph filter
692 int OCCViewer_Viewer::anaglyphFilter() const
694 return myAnaglyphFilter;
699 \param theType - new anaglyph filter
701 void OCCViewer_Viewer::setAnaglyphFilter( const int theType )
703 myAnaglyphFilter = theType;
705 if ( !myViewManager )
708 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
709 for ( int i = 0; i < (int)wins.count(); i++ )
711 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
713 win->setAnaglyphFilter( (OCCViewer_ViewWindow::AnaglyphFilter)theType );
718 \return reverse stereo
720 bool OCCViewer_Viewer::isReverseStereo() const
722 return myToReverseStereo;
727 \param theReverse - enable/disable reverse mode
729 void OCCViewer_Viewer::setReverseStereo( const bool theReverse )
731 myToReverseStereo = theReverse;
733 if ( !myViewManager )
736 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
737 for ( int i = 0; i < (int)wins.count(); i++ )
739 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
741 win->setReverseStereo( theReverse );
748 bool OCCViewer_Viewer::isVSync() const
755 \param theEnable - enable/disable V-Sync mode
757 void OCCViewer_Viewer::setVSync( const bool theEnable )
759 myVSyncMode = theEnable;
761 if ( !myViewManager )
764 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
765 for ( int i = 0; i < (int)wins.count(); i++ )
767 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
769 win->setVSync( theEnable );
774 \return support quad-buffered stereo
776 bool OCCViewer_Viewer::isQuadBufferSupport() const
778 return myQuadBufferSupport;
782 Set support quad-buffered stereo
783 \param theEnable - enable/disable support quad-buffered stereo
785 void OCCViewer_Viewer::setQuadBufferSupport( const bool theEnable )
787 myQuadBufferSupport = theEnable;
789 if ( !myViewManager )
792 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
793 for ( int i = 0; i < (int)wins.count(); i++ )
795 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
797 win->setQuadBufferSupport( theEnable );
802 \return zooming style
804 int OCCViewer_Viewer::zoomingStyle() const
806 return myZoomingStyle;
810 Sets zooming style: 0 - standard, 1 - advanced (at cursor)
811 \param theStyle - new zooming style
813 void OCCViewer_Viewer::setZoomingStyle( const int theStyle )
815 myZoomingStyle = theStyle;
816 //!! To be done for view windows
817 if ( !myViewManager )
820 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
821 for ( int i = 0; i < (int)wins.count(); i++ )
823 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
825 win->setZoomingStyle( theStyle );
830 \return true if preselection is enabled
832 bool OCCViewer_Viewer::isPreselectionEnabled() const
834 return myPreselectionEnabled;
838 Enables/disables preselection
839 \param isEnabled - new status
841 void OCCViewer_Viewer::enablePreselection(bool isEnabled)
843 myPreselectionEnabled = isEnabled;
845 if ( !myViewManager )
848 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
849 for ( int i = 0; i < (int)wins.count(); i++ )
851 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
853 win->enablePreselection( isEnabled );
859 \return true if selection is enabled
861 bool OCCViewer_Viewer::isSelectionEnabled() const
863 return mySelectionEnabled;
867 Enables/disables selection
868 \param isEnabled - new status
870 void OCCViewer_Viewer::enableSelection(bool isEnabled)
872 mySelectionEnabled = isEnabled;
874 //!! To be done for view windows
875 if ( !myViewManager )
878 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
879 for ( int i = 0; i < (int)wins.count(); i++ )
881 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
883 win->updateEnabledDrawMode();
884 win->enableSelection( isEnabled );
889 //clear current selection in the viewer
891 myAISContext->ClearSelected( Standard_True );
897 Sets multiselection enabled status
898 \param isEnabled - new status
900 void OCCViewer_Viewer::enableMultiselection(bool isEnable)
902 myMultiSelectionEnabled = isEnable;
903 //!! To be done for view windows
904 if ( !myViewManager )
907 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
908 for ( int i = 0; i < (int)wins.count(); i++ )
910 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
912 win->updateEnabledDrawMode();
917 Sets a color of the clipped region
918 \param theColor - a new color of the clipped region
920 void OCCViewer_Viewer::setClippingColor( const QColor& theColor )
922 myClippingColor = theColor;
924 if( myInternalClipPlanes.IsEmpty() )
927 for ( Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt ( myInternalClipPlanes ); aPlaneIt.More(); aPlaneIt.Next() )
928 setCappingColor( aPlaneIt.Value(), theColor );
934 \return clipping color
936 QColor OCCViewer_Viewer::clippingColor() const
938 return myClippingColor;
941 // initialize a texture for clipped region
942 Handle(Graphic3d_Texture2Dmanual) initClippingTexture( const bool isDefault, const QString& theTexture,
943 const bool isModulate, const double theScale )
945 QString aTextureFile = isDefault ? ":images/hatch.png" : theTexture;
946 QPixmap px( aTextureFile );
947 const Handle(Image_PixMap) aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage() );
948 Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual( aPixmap );
949 if( aTexture->IsDone() ) {
950 aTexture->EnableRepeat();
951 isModulate ? aTexture->EnableModulate() : aTexture->DisableModulate();
952 aTexture->GetParams()->SetScale( Graphic3d_Vec2( 1/( theScale*100 ), -1 / ( theScale*100 ) ) );
958 Sets default texture parameters
959 \param isDefault - use/non-use default texture
960 \param theTexture - new texture of the clipped region
961 \param isModulate - enable/disable texture modulate mode
962 \param theScale - scale factor.
964 void OCCViewer_Viewer::setClippingTextureParams( const bool isDefault, const QString& theTexture,
965 const bool isModulate, const double theScale )
967 myDefaultTextureUsed = isDefault;
968 myClippingTexture = theTexture;
969 myTextureModulated = isModulate;
970 myClippingTextureScale = theScale;
972 if( myInternalClipPlanes.IsEmpty() )
975 Handle(Graphic3d_Texture2Dmanual) aTexture =
976 initClippingTexture( myDefaultTextureUsed, myClippingTexture,
977 myTextureModulated, myClippingTextureScale );
978 for ( Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt ( myInternalClipPlanes ); aPlaneIt.More(); aPlaneIt.Next() )
979 aPlaneIt.Value()->SetCappingTexture( aTexture );
985 \return true if default texture is used
987 bool OCCViewer_Viewer::isDefaultTextureUsed() const
989 return myDefaultTextureUsed;
993 \return clipping texture
995 QString OCCViewer_Viewer::clippingTexture() const
997 return myClippingTexture;
1001 \return true if texture is modulated
1003 bool OCCViewer_Viewer::isTextureModulated() const
1005 return myTextureModulated;
1009 \return scale factor of texture
1011 double OCCViewer_Viewer::clippingTextureScale() const
1013 return myClippingTextureScale;
1017 Builds popup for occ viewer
1019 void OCCViewer_Viewer::contextMenuPopup(QMenu* thePopup)
1021 thePopup->addAction( tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
1022 thePopup->addAction( tr( "MEN_CHANGE_BACKGROUND" ), this, SLOT( onChangeBackground() ) );
1024 thePopup->addSeparator();
1026 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1028 //Support of several toolbars in the popup menu
1029 QList<QToolBar*> lst = aView->findChildren<QToolBar*>();
1030 QList<QToolBar*>::const_iterator it = lst.begin(), last = lst.end();
1031 for ( ; it!=last; it++ ) {
1032 if ( (*it)->parentWidget()->isVisible() )
1033 thePopup->addAction( (*it)->toggleViewAction() );
1038 SLOT: called on dump view operation is activated, stores scene to raster file
1040 void OCCViewer_Viewer::onDumpView()
1042 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1044 aView->onDumpView();
1048 SLOT: called if background color is to be changed changed, passes new color to view port
1050 void OCCViewer_Viewer::onChangeBackground()
1052 OCCViewer_ViewWindow* aView = dynamic_cast<OCCViewer_ViewWindow*>(myViewManager->getActiveView());
1056 // get supported gradient types
1057 QStringList gradList;
1058 QIntList idList, txtList;
1059 QString formats = backgroundData( gradList, idList, txtList );
1061 // invoke dialog box
1062 Qtx::BackgroundData bgData = QtxBackgroundDialog::getBackground( aView->background(), // initial background
1063 aView, // parent for dialog box
1064 txtList, // allowed texture modes
1065 true, // enable solid color mode
1066 true, // enable gradient mode
1067 false, // disable custom gradient mode
1068 !txtList.isEmpty(), // enable/disable texture mode
1069 gradList, // gradient names
1070 idList, // gradient identifiers
1071 formats ); // image formats
1073 // set chosen background data to the viewer
1074 if ( bgData.isValid() )
1075 aView->setBackground( bgData );
1079 Updates OCC 3D viewer
1081 void OCCViewer_Viewer::update()
1083 if (!myV3dViewer.IsNull())
1084 myV3dViewer->Update();
1086 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1088 aView->updateGravityCoords();
1092 \return objects selected in 3D viewer
1093 \param theList - list to be filled with selected objects
1095 void OCCViewer_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList)
1098 for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected())
1099 theList.Append(myAISContext->SelectedInteractive());
1103 Selects objects in 3D viewer. Other selected objects are left as selected
1104 \param theList - list objects to be selected
1106 void OCCViewer_Viewer::setObjectsSelected(const AIS_ListOfInteractive& theList)
1108 AIS_ListIteratorOfListOfInteractive aIt;
1109 for (aIt.Initialize(theList); aIt.More(); aIt.Next())
1110 myAISContext->AddOrRemoveSelected(aIt.Value(), false);
1111 myAISContext->UpdateCurrentViewer();
1115 Auxiliary method to emit signal selectionChanged()
1117 void OCCViewer_Viewer::performSelectionChanged()
1119 emit selectionChanged();
1123 * Defines default lights
1125 void OCCViewer_Viewer::setDefaultLights()
1127 // clear all light sources
1128 myV3dViewer->InitDefinedLights();
1129 while ( myV3dViewer->MoreDefinedLights() )
1131 myV3dViewer->DelLight( myV3dViewer->DefinedLight() );
1132 myV3dViewer->InitDefinedLights();
1135 // get light source parameters from preferences
1136 QColor aColor = SUIT_Session::session()->resourceMgr()->colorValue( "OCCViewer", "light_color", QColor( 0, 0, 0 ) );
1137 double aDx = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dx", 0.0 );
1138 double aDy = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dy", 0.0 );
1139 double aDz = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dz", -1.0 );
1141 Handle(V3d_DirectionalLight) aLight =
1142 new V3d_DirectionalLight( V3d_Zneg, OCCViewer::color( aColor ).Name(), Standard_True );
1143 myV3dViewer->AddLight( aLight );
1144 if( !( aDx == 0 && aDy == 0 && aDz == 0 ) )
1145 aLight->SetDirection( aDx, aDy, aDz );
1146 myV3dViewer->SetLightOn( aLight );
1147 Handle(V3d_AmbientLight) ambLight = new V3d_AmbientLight();
1148 myV3dViewer->AddLight( ambLight );
1149 myV3dViewer->SetLightOn( ambLight );
1153 Hilights/unhilights object in viewer
1154 \param obj - object to be updated
1155 \param hilight - if it is true, object will be hilighted, otherwise it will be unhilighted
1156 \param update - update current viewer
1158 bool OCCViewer_Viewer::highlight( const Handle(AIS_InteractiveObject)& obj,
1159 bool hilight, bool update )
1161 if( !obj.IsNull() ) {
1162 if ( hilight && !myAISContext->IsSelected( obj ) )
1163 myAISContext->AddOrRemoveSelected( obj, false );
1164 else if ( !hilight && myAISContext->IsSelected( obj ) )
1165 myAISContext->AddOrRemoveSelected( obj, false );
1169 myV3dViewer->Redraw();
1175 Unhilights all objects in viewer
1176 \param updateviewer - update current viewer
1178 bool OCCViewer_Viewer::unHighlightAll( bool updateviewer, bool unselect )
1181 myAISContext->ClearSelected( updateviewer );
1183 myAISContext->UnhilightSelected( updateviewer );
1189 \return true if object is in viewer or in collector
1190 \param obj - object to be checked
1191 \param onlyInViewer - search object only in viewer (so object must be displayed)
1193 bool OCCViewer_Viewer::isInViewer( const Handle(AIS_InteractiveObject)& obj,
1194 bool /*onlyInViewer*/ )
1196 AIS_ListOfInteractive List;
1197 myAISContext->DisplayedObjects(List);
1199 AIS_ListIteratorOfListOfInteractive ite(List);
1200 for ( ; ite.More(); ite.Next() )
1201 if( ite.Value()==obj )
1208 \return true if object is displayed in viewer
1209 \param obj - object to be checked
1211 bool OCCViewer_Viewer::isVisible( const Handle(AIS_InteractiveObject)& obj )
1213 return myAISContext->IsDisplayed( obj );
1217 Sets color of object
1218 \param obj - object to be updated
1219 \param color - new color
1220 \param update - update current viewer
1222 void OCCViewer_Viewer::setColor( const Handle(AIS_InteractiveObject)& obj,
1223 const QColor& color,
1228 Quantity_Color CSFColor = Quantity_Color ( color.red() / 255.,
1229 color.green() / 255.,
1230 color.blue() / 255.,
1232 obj->SetColor( CSFColor );
1236 myV3dViewer->Update();
1240 Changes display mode of object
1241 \param obj - object to be processed
1242 \param mode - new display mode
1243 \param update - update current viewer
1245 void OCCViewer_Viewer::switchRepresentation( const Handle(AIS_InteractiveObject)& obj,
1246 int mode, bool update )
1248 myAISContext->SetDisplayMode( obj, (Standard_Integer)mode, update );
1250 myV3dViewer->Update();
1254 Changes transparency of object
1255 \param obj - object to be processed
1256 \param trans - new transparency
1257 \param update - update current viewer
1259 void OCCViewer_Viewer::setTransparency( const Handle(AIS_InteractiveObject)& obj,
1260 float trans, bool update )
1262 myAISContext->SetTransparency( obj, trans, false );
1263 myAISContext->Redisplay( obj, Standard_False, Standard_True );
1265 myV3dViewer->Update();
1268 bool OCCViewer_Viewer::isColorScaleVisible() const
1270 return !myColorScale.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myColorScale );
1273 void OCCViewer_Viewer::setColorScaleShown( const bool on )
1275 if ( myColorScale.IsNull() )
1279 if ( !myAISContext->IsDisplayed( myColorScale ) )
1280 myAISContext->Display( myColorScale, Standard_True );
1281 myAISContext->Redisplay( myColorScale, Standard_True, Standard_True );
1285 if ( myAISContext->IsDisplayed( myColorScale ) )
1286 myAISContext->Erase( myColorScale, Standard_True );
1291 Changes visibility of trihedron to opposite
1293 void OCCViewer_Viewer::toggleTrihedron()
1295 setTrihedronShown( !isTrihedronVisible() );
1299 \return true if trihedron is visible
1301 bool OCCViewer_Viewer::isTrihedronVisible() const
1303 return !myTrihedron.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myTrihedron );
1307 Sets visibility state of trihedron
1308 \param on - new state
1311 void OCCViewer_Viewer::setTrihedronShown( const bool on )
1313 if ( myTrihedron.IsNull() )
1317 myAISContext->Display( myTrihedron,
1319 -1 /* selection mode */,
1320 Standard_True /* update viewer*/,
1321 AIS_DS_Displayed /* display status */);
1322 myAISContext->Deactivate( myTrihedron );
1325 myAISContext->Erase( myTrihedron , Standard_True );
1330 \return trihedron size
1332 double OCCViewer_Viewer::trihedronSize() const
1335 if ( !myTrihedron.IsNull() )
1336 sz = myTrihedron->Size();
1341 Changes trihedron size
1342 \param sz - new size
1344 void OCCViewer_Viewer::setTrihedronSize( const double sz, bool isRelative )
1346 if ( myTrihedronSize != sz || isRelative != myIsRelative) {
1347 myTrihedronSize = sz;
1348 myIsRelative = isRelative;
1354 Set number of isolines
1355 \param u - u-isolines (first parametric co-ordinate)
1356 \param v - v-isolines (second parametric co-ordinate)
1358 void OCCViewer_Viewer::setIsos( const int u, const int v )
1360 Handle(AIS_InteractiveContext) ic = getAISContext();
1364 ic->SetIsoNumber( u, AIS_TOI_IsoU );
1365 ic->SetIsoNumber( v, AIS_TOI_IsoV );
1369 \return number of isolines
1370 \param u - to return u-isolines (first parametric co-ordinate)
1371 \param v - to return v-isolines (second parametric co-ordinate)
1373 void OCCViewer_Viewer::isos( int& u, int& v ) const
1375 Handle(AIS_InteractiveContext) ic = getAISContext();
1378 u = ic->IsoNumber( AIS_TOI_IsoU );
1379 v = ic->IsoNumber( AIS_TOI_IsoV );
1384 * Returns a new OCCViewer_ViewWindow instance which will be placed as a sub window in ViewFrame
1386 OCCViewer_ViewWindow* OCCViewer_Viewer::createSubWindow()
1388 return new OCCViewer_ViewWindow(0, this);
1392 QColor OCCViewer_Viewer::backgroundColor( int theViewId ) const
1394 return background( theViewId ).color();
1397 Qtx::BackgroundData OCCViewer_Viewer::background( int theViewId ) const
1399 return ( theViewId >= 0 && theViewId < myBackgrounds.count() ) ? myBackgrounds[theViewId] : Qtx::BackgroundData();
1403 void OCCViewer_Viewer::setBackgroundColor( int theViewId, const QColor& theColor )
1405 if ( theColor.isValid() ) {
1406 Qtx::BackgroundData bg = background( theViewId );
1407 bg.setColor( theColor );
1408 setBackground( theViewId, bg );
1412 void OCCViewer_Viewer::setBackground( int theViewId, const Qtx::BackgroundData& theBackground )
1414 if ( theBackground.isValid() && theViewId >= 0 && theViewId < myBackgrounds.count() )
1415 myBackgrounds[theViewId] = theBackground;
1420 Set the show static trihedron flag
1422 void OCCViewer_Viewer::setStaticTrihedronDisplayed(const bool on)
1424 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1425 if ( aView ) aView->showStaticTrihedron( on );
1429 Get new and current trihedron size corresponding to the current model size
1431 bool OCCViewer_Viewer::computeTrihedronSize( double& theNewSize, double& theSize )
1436 //SRN: BUG IPAL8996, a usage of method ActiveView without an initialization
1437 Handle(V3d_Viewer) viewer = getViewer3d();
1438 viewer->InitActiveViews();
1439 if(!viewer->MoreActiveViews()) return false;
1441 Handle(V3d_View) view3d = viewer->ActiveView();
1444 if ( view3d.IsNull() )
1447 double aMaxSide = computeSceneSize( view3d );
1450 // The boundary box of the view may be initialized but nullified
1451 // (case of infinite objects)
1452 if ( aMaxSide < Precision::Confusion() )
1455 float aSizeInPercents = SUIT_Session::session()->resourceMgr()->doubleValue("3DViewer","trihedron_size", 100.);
1457 static float EPS = 5.0E-3f;
1458 theSize = getTrihedron()->Size();
1459 theNewSize = aMaxSide*aSizeInPercents / 100.0;
1461 return fabs( theNewSize - theSize ) > theSize * EPS ||
1462 fabs( theNewSize - theSize ) > theNewSize * EPS;
1466 * Compute scene size
1468 double OCCViewer_Viewer::computeSceneSize(const Handle(V3d_View)& view3d) const
1470 double aMaxSide = 0;
1471 double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
1473 Bnd_Box aBox = view3d->View()->MinMaxValues();
1474 Xmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().X();
1475 Ymin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Y();
1476 Zmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Z();
1477 Xmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().X();
1478 Ymax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Y();
1479 Zmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Z();
1481 if ( Xmin != RealFirst() && Ymin != RealFirst() && Zmin != RealFirst() &&
1482 Xmax != RealLast() && Ymax != RealLast() && Zmax != RealLast() )
1484 aMaxSide = Xmax - Xmin;
1485 if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin;
1486 if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin;
1493 * Update the size of the trihedron
1495 void OCCViewer_Viewer::updateTrihedron() {
1496 if ( myTrihedron.IsNull() )
1500 double newSz, oldSz;
1502 if(computeTrihedronSize(newSz, oldSz))
1503 myTrihedron->SetSize(newSz);
1505 } else if(myTrihedron->Size() != myTrihedronSize) {
1506 myTrihedron->SetSize(myTrihedronSize);
1511 Set number of isolines
1512 \param u - u-isolines (first parametric co-ordinate)
1513 \param v - v-isolines (second parametric co-ordinate)
1515 void OCCViewer_Viewer::setSelectionOptions( bool isPreselectionEnabled, bool isSelectionEnabled )
1517 myPreselectionEnabled = isPreselectionEnabled;
1518 mySelectionEnabled = isSelectionEnabled;
1519 //clear current selection in the viewer
1521 if(!mySelectionEnabled) {
1522 myAISContext->ClearSelected( Standard_True );
1527 Creates clipping plane based on the incoming plane
1529 Handle(Graphic3d_ClipPlane) OCCViewer_Viewer::createClipPlane(const gp_Pln& thePlane, const Standard_Boolean theIsOn)
1531 Handle(Graphic3d_ClipPlane) aGraphic3dPlane = new Graphic3d_ClipPlane( thePlane );
1532 aGraphic3dPlane->SetOn( theIsOn );
1533 aGraphic3dPlane->SetCapping( Standard_True );
1535 // set capping color
1536 setCappingColor( aGraphic3dPlane, myClippingColor );
1538 // set capping texture
1539 aGraphic3dPlane->SetCappingTexture( initClippingTexture( myDefaultTextureUsed, myClippingTexture,
1540 myTextureModulated, myClippingTextureScale ) );
1542 return aGraphic3dPlane;
1545 Applies clipping planes to clippable objects
1547 void OCCViewer_Viewer::setClipPlanes(ClipPlanesList theList)
1549 // 1. Remove existing clipping planes
1550 myClipPlanes.clear();
1551 myInternalClipPlanes.Clear();
1553 // 2. Create new clipping planes
1554 ClipPlanesList::iterator inIt = theList.begin();
1555 for (;inIt != theList.end(); inIt++ )
1557 OCCViewer_ClipPlane aPlane = *inIt;
1559 double aDx = 0.0, aDy = 0.0, aDz = 0.0;
1560 aPlane.OrientationToXYZ( aDx, aDy, aDz );
1562 gp_Pnt anOrigin( aPlane.X, aPlane.Y, aPlane.Z );
1563 gp_Dir aDirection( aDx, aDy, aDz );
1565 myInternalClipPlanes.Append( createClipPlane( gp_Pln( anOrigin, aDirection ), aPlane.IsOn ) );
1566 myClipPlanes.push_back( aPlane );
1569 // 3. Apply clipping planes
1570 AIS_ListOfInteractive aList;
1571 myAISContext->DisplayedObjects (aList);
1572 for ( AIS_ListIteratorOfListOfInteractive anIter (aList); anIter.More(); anIter.Next() ) {
1573 Handle(AIS_InteractiveObject) anObj = anIter.Value();
1574 Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (anObj);
1575 if (!aShape.IsNull() && aShape->IsClippable()) {
1576 aShape->SetClipPlanes(new Graphic3d_SequenceOfHClipPlane(myInternalClipPlanes)); // todo: store clipping planes in a handle?
1582 Returns the clipping planes applied to the displayed objects.
1584 ClipPlanesList OCCViewer_Viewer::getClipPlanes() const {
1585 return myClipPlanes;
1588 Applies clipping planes to given object objects
1590 void OCCViewer_Viewer::applyExistingClipPlanesToObject (const Handle(AIS_InteractiveObject)& theObject)
1592 Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (theObject);
1593 if (!aShape.IsNull() && aShape->IsClippable())
1595 aShape->SetClipPlanes (new Graphic3d_SequenceOfHClipPlane(myInternalClipPlanes)); // todo: store clipping planes in a handle?
1600 Returns the pointer to the clipping dialog box.
1602 OCCViewer_ClippingDlg* OCCViewer_Viewer::getClippingDlg() const{
1603 return myClippingDlg;
1608 Stores pointer to the clipping dialog box.
1610 void OCCViewer_Viewer::setClippingDlg(OCCViewer_ClippingDlg* theDlg) {
1611 if(myClippingDlg != theDlg) {
1612 myClippingDlg = theDlg;
1617 bool OCCViewer_Viewer::enableDrawMode( bool on )
1619 //!! To be done for view windows
1620 if ( !myViewManager )
1624 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
1625 for ( int i = 0; i < (int)wins.count(); i++ )
1627 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
1629 prev = prev || win->enableDrawMode( on );