____
+.. image:: ../../../../src/OCCViewer/resources/occ_view_viewcube.png
+ :align: center
+
+**Show/Hide view cube** - shows or hides navigation cube.
+
+____
+
.. image:: ../../../../src/OCCViewer/resources/occ_view_preselection.png
:align: center
- **Color** - allows to change the color of light source.
- **Dx, Dy, Dz** - sets direction coordinates.
+- **Navigation Cube** - allows to manage parameters of navigation cube.
+
+ - **Show navigation cube on start** - if checked, navigation cube will appear in a new occ viewer.
+ - **Animation duration (sec)** - duration of animation of camera rotation.
+ - **Customize navigation cube appearance** - if checked, below defined parameters will be used instead of default ones.
+ - **Cube color** - color of the navigation cube.
+ - **Text color** - color of text on the navigation cube faces.
+ - **Cube size** - size of the navigation cube.
+ - **Show navigation cube axes** - show navigation cube own axes.
+
.. _vtk_preferences:
VTK 3D Viewer Preferences
pref->setItemProperty( "step", 0.1, light_dz );
// ... "Light source" group <<end>>
+ // ... "View cube" group <<start>>
+ int occViewCubeGroup = pref->addPreference( tr( "PREF_GROUP_VIEWCUBE" ), occGroup );
+ pref->setItemProperty( "columns", 2, occViewCubeGroup );
+ // .... -> show view cube on viewer start
+ pref->addPreference( tr( "PREF_VIEWCUBE_SHOW" ), occViewCubeGroup,
+ LightApp_Preferences::Bool, "OCCViewer", "viewcube_show" );
+ // .... -> view cube duration of animation (sec)
+ int viewcube_dur = pref->addPreference( tr( "PREF_VIEWCUBE_DURATION" ), occViewCubeGroup,
+ LightApp_Preferences::DblSpin, "OCCViewer", "viewcube_duration" );
+ pref->setItemProperty( "min", 0.1, viewcube_dur );
+ pref->setItemProperty( "max", 10.0, viewcube_dur );
+ pref->setItemProperty( "step", 0.1, viewcube_dur );
+ // ... "View cube" group <<end>>
+
+ // ... "View cube default (OCCT) attributes" group <<start>>
+ int occViewCubeAttrsGroup = pref->addPreference( tr( "PREF_VIEWCUBE_CUSTOM" ), occGroup,
+ LightApp_Preferences::Auto, "OCCViewer", "viewcube_custom" );
+ pref->setItemProperty( "columns", 2, occViewCubeAttrsGroup );
+ // .... -> box color
+ pref->addPreference( tr( "PREF_VIEWCUBE_COLOR" ), occViewCubeAttrsGroup,
+ LightApp_Preferences::Color, "OCCViewer", "viewcube_color" );
+ // .... -> view cube size
+ int viewcube_size = pref->addPreference( tr( "PREF_VIEWCUBE_SIZE" ), occViewCubeAttrsGroup,
+ LightApp_Preferences::DblSpin, "OCCViewer", "viewcube_size" );
+ pref->setItemProperty( "min", 30.0, viewcube_size );
+ pref->setItemProperty( "max", 100.0, viewcube_size );
+ pref->setItemProperty( "step", 10.0, viewcube_size );
+ // .... -> text color
+ pref->addPreference( tr( "PREF_VIEWCUBE_TEXTCOLOR" ), occViewCubeAttrsGroup,
+ LightApp_Preferences::Color, "OCCViewer", "viewcube_text_color" );
+ // .... -> show view cube axes
+ pref->addPreference( tr( "PREF_VIEWCUBE_AXES" ), occViewCubeAttrsGroup,
+ LightApp_Preferences::Bool, "OCCViewer", "viewcube_axes" );
+ // ... "View cube" group <<end>>
+
// ... -> empty frame (for layout) <<start>>
int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
pref->setItemProperty( "margin", 0, occGen );
}
#endif
+#ifndef DISABLE_OCCVIEWER
+ //if ( sec == QString( "OCCViewer" ) && param == QString( "viewcube_color" ) )
+ if ( sec == QString( "OCCViewer" ) && param.contains( "viewcube" ) )
+ {
+ QList<SUIT_ViewManager*> lst;
+ viewManagers( OCCViewer_Viewer::Type(), lst );
+ QListIterator<SUIT_ViewManager*> it( lst );
+ while ( it.hasNext() )
+ {
+ SUIT_ViewModel* vm = it.next()->getViewModel();
+ if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
+ continue;
+
+ OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
+ occVM->setViewCubeParamsFromPreferences();
+ }
+ }
+#endif
+
if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
{
int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
<parameter name="xz_background" value="bt=2;fn=;tm=0;ts=false;c1=#cddbff;c2=#698fff;gt=1;gr=" />
<parameter name="yz_background" value="bt=2;fn=;tm=0;ts=false;c1=#cddbff;c2=#698fff;gt=1;gr=" />
<parameter name="xy_background" value="bt=2;fn=;tm=0;ts=false;c1=#cddbff;c2=#698fff;gt=1;gr=" />
+ <parameter name="viewcube_show" value="true"/>
+ <parameter name="viewcube_axes" value="true"/>
+ <parameter name="viewcube_custom" value="false"/>
+ <parameter name="viewcube_color" value="255, 255, 255"/>
+ <parameter name="viewcube_size" value="70.0"/>
+ <parameter name="viewcube_text_color" value="0, 0, 0"/>
+ <parameter name="viewcube_duration" value="0.5"/>
</section>
<section name="VTKViewer" >
<!-- VTK viewer preferences -->
<source>PREF_LIGHT_COLOR</source>
<translation>Color</translation>
</message>
+
+ <message>
+ <source>PREF_GROUP_VIEWCUBE</source>
+ <translation>Navigation Cube</translation>
+ </message>
+ <message>
+ <source>PREF_VIEWCUBE_SHOW</source>
+ <translation>Show navigation cube on start</translation>
+ </message>
+ <message>
+ <source>PREF_VIEWCUBE_AXES</source>
+ <translation>Show navigation cube axes</translation>
+ </message>
+ <message>
+ <source>PREF_VIEWCUBE_CUSTOM</source>
+ <translation>Customize navigation cube appearance</translation>
+ </message>
+ <message>
+ <source>PREF_VIEWCUBE_COLOR</source>
+ <translation>Cube color</translation>
+ </message>
+ <message>
+ <source>PREF_VIEWCUBE_SIZE</source>
+ <translation>Cube size</translation>
+ </message>
+ <message>
+ <source>PREF_VIEWCUBE_TEXTCOLOR</source>
+ <translation>Text color</translation>
+ </message>
+ <message>
+ <source>PREF_VIEWCUBE_DURATION</source>
+ <translation>Animation duration (sec)</translation>
+ </message>
+
<message>
<source>TOT_CLOSE</source>
<translation>Close</translation>
resources/occ_view_style_switch.png
resources/occ_view_top.png
resources/occ_view_triedre.png
+ resources/occ_view_viewcube.png
resources/occ_view_zoom.png
resources/occ_view_zooming_style_switch.png
resources/occ_view_ray_tracing.png
}
}
+ /* create view cube */
+ myViewCube = new AIS_ViewCube();
+ setViewCubeParamsFromPreferences();
+
// set interaction style to standard
myInteractionStyle = 0;
void OCCViewer_Viewer::onViewMapped(OCCViewer_ViewPort3d* viewPort)
{
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+
setTrihedronShown( true );
+
+ bool showViewCube = true;
+ if ( resMgr ) showViewCube = resMgr->booleanValue( "OCCViewer", "viewcube_show", true );
+ setViewCubeShown( showViewCube );
+
bool showStaticTrihedron = true;
- SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
if ( resMgr ) showStaticTrihedron = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
viewPort->showStaticTrihedron( showStaticTrihedron );
}
}
/*!
- Changes visibility of trihedron to opposite
+ \return true if trihedron is visible
*/
-void OCCViewer_Viewer::toggleTrihedron()
+bool OCCViewer_Viewer::isTrihedronVisible() const
{
- setTrihedronShown( !isTrihedronVisible() );
+ return !myTrihedron.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myTrihedron );
}
/*!
- \return true if trihedron is visible
+ \return true if view cube is visible
*/
-bool OCCViewer_Viewer::isTrihedronVisible() const
+bool OCCViewer_Viewer::isViewCubeVisible() const
{
- return !myTrihedron.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myTrihedron );
+ return !myViewCube.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myViewCube );
}
/*!
}
}
+/*!
+ Sets visibility state of trihedron
+ \param on - new state
+*/
+
+void OCCViewer_Viewer::setViewCubeShown( const bool on )
+{
+ if ( myViewCube.IsNull() )
+ return;
+
+ if ( on ) {
+ myAISContext->Display( myViewCube,
+ 0 /*wireframe*/,
+ //-1 /* selection mode */,
+ 0 /* selection mode */,
+ Standard_True /* update viewer*/,
+ AIS_DS_Displayed /* display status */);
+ }
+ else {
+ myAISContext->Erase( myViewCube, Standard_True );
+ }
+}
+
+/*!
+ Set View Cube parameters from preferences
+*/
+void OCCViewer_Viewer::setViewCubeParamsFromPreferences()
+{
+ // Resource manager
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ if (!resMgr || myViewCube.IsNull())
+ return;
+
+ bool isVisibleVC = isVisible(myViewCube);
+
+ if (resMgr->booleanValue("OCCViewer", "viewcube_custom", false)) {
+ // Use custom settings from preferences
+ QColor aColor;
+
+ // Box color
+ aColor = resMgr->colorValue("OCCViewer", "viewcube_color", QColor(255, 255, 255));
+ myViewCube->SetBoxColor(OCCViewer::color(aColor));
+
+ // Size
+ myViewCube->SetSize(resMgr->doubleValue("OCCViewer", "viewcube_size", 70.0));
+
+ // Text color
+ aColor = resMgr->colorValue("OCCViewer", "viewcube_text_color", QColor(0, 0, 0));
+ myViewCube->SetTextColor(OCCViewer::color(aColor));
+
+ // Axes
+ myViewCube->SetDrawAxes(resMgr->booleanValue("OCCViewer", "viewcube_axes", true));
+ }
+ else {
+ myViewCube->ResetStyles();
+ }
+
+ // Animation duration (sec)
+ myViewCube->SetDuration(resMgr->doubleValue("OCCViewer", "viewcube_duration", 0.5));
+
+ // Update the viewer
+ if (isVisibleVC)
+ myAISContext->Redisplay( myViewCube, Standard_True);
+}
+
/*!
\return trihedron size
*/
#include <V3d_View.hxx>
#include <AIS_ColorScale.hxx>
#include <AIS_Trihedron.hxx>
+#include <AIS_ViewCube.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
//! returns true if 3d Trihedron in viewer was created
bool trihedronActivated() const { return !myTrihedron.IsNull(); }
- void toggleTrihedron();
bool isTrihedronVisible() const;
virtual void setTrihedronShown( const bool );
void updateTrihedron();
+ // View Cube methods
+ bool viewCubeActivated() const { return !myViewCube.IsNull(); }
+ bool isViewCubeVisible() const;
+ virtual void setViewCubeShown( const bool );
+ void setViewCubeParamsFromPreferences();
virtual OCCViewer_ViewWindow* createSubWindow();
Handle(AIS_InteractiveContext) getAISContext() const { return myAISContext; }
Handle(AIS_ColorScale) getColorScale() const { return myColorScale; }
Handle(AIS_Trihedron) getTrihedron() const { return myTrihedron; }
+ Handle(AIS_ViewCube) getViewCube() const { return myViewCube; }
int getTopLayerId();
Handle(V3d_Viewer) myV3dViewer;
Handle(AIS_ColorScale) myColorScale;
Handle(AIS_Trihedron) myTrihedron;
+ Handle(AIS_ViewCube) myViewCube;
Handle(AIS_InteractiveContext) myAISContext;
int myInteractionStyle;
toolMgr()->registerAction( aAction, TrihedronShowId );
}
+ if (myModel->viewCubeActivated()) {
+ aAction = new QtxAction(tr("MNU_SHOW_VIEWCUBE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_VIEWCUBE" ) ),
+ tr( "MNU_SHOW_VIEWCUBE" ), 0, this);
+ aAction->setCheckable( true );
+ aAction->setChecked( aResMgr->booleanValue( "OCCViewer", "viewcube_show", true ) );
+ aAction->setStatusTip(tr("DSC_SHOW_VIEWCUBE"));
+ connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onViewCubeShow(bool)));
+ toolMgr()->registerAction( aAction, ViewCubeShowId );
+ }
+
// Scale
aAction = new QtxAction(tr("MNU_SCALING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SCALING" ) ),
tr( "MNU_SCALING" ), 0, this);
if( myModel->trihedronActivated() )
toolMgr()->append( TrihedronShowId, tid );
+ if( myModel->viewCubeActivated() )
+ toolMgr()->append( ViewCubeShowId, tid );
+
QtxMultiAction* aScaleAction = new QtxMultiAction( this );
aScaleAction->insertAction( toolMgr()->action( FitAllId ) );
aScaleAction->insertAction( toolMgr()->action( FitRectId ) );
myModel->setTrihedronShown( anItem.isVisible );
myModel->setTrihedronSize( anItem.size );
+ myModel->setViewCubeShown( anItem.vcIsVisible );
+
// graduated trihedron
bool anIsVisible = anItem.gtIsVisible;
OCCViewer_AxisWidget::AxisData anAxisData[3];
myModel->setTrihedronShown(show);
}
+/*!
+ \brief Called when action "show/hide view cube" is activated.
+*/
+void OCCViewer_ViewWindow::onViewCubeShow(bool show)
+{
+ myModel->setViewCubeShown(show);
+}
+
/*!
\brief Toggles preselection (highlighting) on/off
*/
bool isShown = myModel->isTrihedronVisible();
double size = myModel->trihedronSize();
+ bool isVCShown = myModel->isViewCubeVisible();
+
QString aName = QTime::currentTime().toString() + QString::fromLatin1( " h:m:s" );
viewAspect params;
params.scaleY = aScaleY;
params.scaleZ = aScaleZ;
params.name = aName;
+
+ // trihedron
params.isVisible= isShown;
params.size = size;
+ // view cube
+ params.vcIsVisible= isVCShown;
+
// graduated trihedron
bool anIsVisible = false;
OCCViewer_AxisWidget::AxisData anAxisData[3];
double scaleY;
double scaleZ;
QString name;
+ // trihedron
bool isVisible;
double size;
+ // view cube
+ bool vcIsVisible;
// graduated trihedron
bool gtIsVisible;
bool gtDrawNameX;
name(),
isVisible( false ),
size( 0.0 ),
+ vcIsVisible( false ),
gtIsVisible( false ),
gtDrawNameX( false ), gtDrawNameY( false ), gtDrawNameZ( false ),
gtNameX(), gtNameY(), gtNameZ(),
public:
enum ActionId { DumpId, FitAllId, FitRectId, FitSelectionId, ZoomId, PanId, GlobalPanId,
- ChangeRotationPointId, RotationId,
- FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId,
- ResetId, CloneId, ClippingId, MemId, RestoreId,
- TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId,
- SwitchInteractionStyleId, SwitchZoomingStyleId,
- SwitchPreselectionId, SwitchSelectionId,
- MaximizedId, SynchronizeId, ReturnTo3dViewId,
- OrthographicId, PerspectiveId, StereoId, RayTracingId, EnvTextureId, LightSourceId,
- RectangleSelectionStyleId, PolygonSelectionStyleId, CircleSelectionStyleId,
- UserId };
+ ChangeRotationPointId, RotationId,
+ FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId,
+ ResetId, CloneId, ClippingId, MemId, RestoreId,
+ TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId,
+ SwitchInteractionStyleId, SwitchZoomingStyleId,
+ SwitchPreselectionId, SwitchSelectionId,
+ MaximizedId, SynchronizeId, ReturnTo3dViewId,
+ OrthographicId, PerspectiveId, StereoId, RayTracingId, EnvTextureId, LightSourceId,
+ RectangleSelectionStyleId, PolygonSelectionStyleId, CircleSelectionStyleId,
+ ViewCubeShowId,
+ UserId };
enum OperationType{ NOVIEWOP, PANVIEW, ZOOMVIEW, ROTATE,
PANGLOBAL, WINDOWFIT, FITALLVIEW, FITSELECTION, RESETVIEW,
virtual void onMemorizeView();
virtual void onRestoreView();
virtual void onTrihedronShow(bool);
+ virtual void onViewCubeShow(bool);
virtual void setRestoreFlag();
virtual void onSwitchInteractionStyle( bool on );
virtual void onSwitchZoomingStyle( bool on );
<source>ICON_OCCVIEWER_VIEW_TRIHEDRON</source>
<translation>occ_view_triedre.png</translation>
</message>
+ <message>
+ <source>ICON_OCCVIEWER_VIEW_VIEWCUBE</source>
+ <translation>occ_view_viewcube.png</translation>
+ </message>
<message>
<source>ICON_OCCVIEWER_SCALING</source>
<translation>occ_view_scaling.png</translation>
<source>DSC_SHOW_TRIHEDRE</source>
<translation>Show/Hide trihedron in the current view</translation>
</message>
+ <message>
+ <source>MNU_SHOW_VIEWCUBE</source>
+ <translation>Show/Hide navigation cube</translation>
+ </message>
+ <message>
+ <source>DSC_SHOW_VIEWCUBE</source>
+ <translation>Show/Hide navigation cube in the current view</translation>
+ </message>
<message>
<source>MNU_ROTATE_VIEW</source>
<translation>Rotation</translation>
Handle(AIS_InteractiveContext) ic = getAISContext();
// check if trihedron is displayed
- Standard_Boolean isTrihedronDisplayed = ic->IsDisplayed( getTrihedron() );
+ Standard_Boolean isTrihedronDisplayed = isTrihedronVisible();
+ Standard_Boolean isViewCubeDisplayed = isViewCubeVisible();
// get objects to be erased (all currently displayed objects)
AIS_ListOfInteractive aList;
ic->DisplayedObjects( aList );
AIS_ListIteratorOfListOfInteractive anIter( aList );
for ( ; anIter.More(); anIter.Next() ) {
- if ( (isTrihedronDisplayed && anIter.Value()->DynamicType() == STANDARD_TYPE( AIS_Trihedron ) ) )
+ if ( isTrihedronDisplayed && anIter.Value()->DynamicType() == STANDARD_TYPE( AIS_Trihedron ) )
+ continue;
+ if ( isViewCubeDisplayed && anIter.Value()->DynamicType() == STANDARD_TYPE( AIS_ViewCube ) )
continue;
// erase an object
for( it = sel_modes.begin(); it != sel_modes.end(); ++it )
ic->Activate( anAIS, AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)*it ) );
}
+ else if ( anAIS->DynamicType() == STANDARD_TYPE(AIS_ViewCube) )
+ {
+ ic->Activate( anAIS, 0 );
+ }
else if ( anAIS->DynamicType() != STANDARD_TYPE(AIS_Trihedron) )
{
ic->Load( anAIS, -1 );