the contents of a frame drawn with pressed left mouse button.
<hr>
+\image html occ_view_fitselection.png
+
+<b>Fit selection</b> - fits view contents to the current selection.
+<hr>
+
\image html occ_view_zoom.png
<b>Zoom</b> - allows to zoom in and out.
the contents of a frame drawn with pressed left mouse button.
<hr>
+\image html vtk_view_fitselection.png
+
+<b>Fit selection</b> - fits view contents to the current selection.
+<hr>
+
\image html vtk_view_zoom.png
<b>Zoom</b> - allows to zoom in and out.
\image html vtk_view_anticlockwise.png
-<b>Rotate counter-clockwise</b> - rotates view 90° counter-clockwise.
+<b>Rotate counter-clockwise</b> - rotates view 90� counter-clockwise.
<hr>
\image html vtk_view_clockwise.png
-<b>Rotate clockwise</b> - rotates view 90° clockwise.
+<b>Rotate clockwise</b> - rotates view 90� clockwise.
<hr>
\image html vtk_view_reset.png
resources/occ_view_clone.png
resources/occ_view_fitall.png
resources/occ_view_fitarea.png
+ resources/occ_view_fitselection.png
resources/occ_view_front.png
resources/occ_view_glpan.png
resources/occ_view_graduated_axes.png
connect(aAction, SIGNAL(triggered()), this, SLOT(activateWindowFit()));
toolMgr()->registerAction( aAction, FitRectId );
+ // FitSelection
+ aAction = new QtxAction(tr("MNU_FITSELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITSELECTION" ) ),
+ tr( "MNU_FITSELECTION" ), 0, this);
+ aAction->setStatusTip(tr("DSC_FITSELECTION"));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onFitSelection()));
+ toolMgr()->registerAction( aAction, FitSelectionId );
+
// Zoom
aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ZOOM" ) ),
tr( "MNU_ZOOM_VIEW" ), 0, this);
QtxMultiAction* aScaleAction = new QtxMultiAction( this );
aScaleAction->insertAction( toolMgr()->action( FitAllId ) );
aScaleAction->insertAction( toolMgr()->action( FitRectId ) );
+#if OCC_VERSION_LARGE > 0x06090000
+ aScaleAction->insertAction( toolMgr()->action( FitSelectionId ) );
+#endif
aScaleAction->insertAction( toolMgr()->action( ZoomId ) );
toolMgr()->append( aScaleAction, tid );
emit vpTransformationFinished( FITALLVIEW );
}
+/*!
+ \brief Perform "fit selection" transformation.
+*/
+void OCCViewer_ViewWindow::onFitSelection()
+{
+ emit vpTransformationStarted( FITSELECTION );
+#if OCC_VERSION_LARGE > 0x06090000
+ myModel->getAISContext()->FitSelected( getViewPort()->getView() );
+#endif
+ emit vpTransformationFinished( FITSELECTION );
+}
+
/*!
\brief Called if 'change rotation point' operation is activated.
\param on action state
Q_OBJECT
public:
- enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId,
+ enum { DumpId, FitAllId, FitRectId, FitSelectionId, ZoomId, PanId, GlobalPanId,
ChangeRotationPointId, RotationId,
FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId,
ResetId, CloneId, ClippingId, MemId, RestoreId,
UserId };
enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE,
- PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
+ PANGLOBAL, WINDOWFIT, FITALLVIEW, FITSELECTION, RESETVIEW,
FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW,
CLOCKWISEVIEW, ANTICLOCKWISEVIEW };
virtual void onAntiClockWiseView();
virtual void onResetView();
virtual void onFitAll();
+ virtual void onFitSelection();
virtual void activateZoom();
virtual void activateWindowFit();
virtual void activateRotation();
<source>ICON_OCCVIEWER_VIEW_FITAREA</source>
<translation>occ_view_fitarea.png</translation>
</message>
+ <message>
+ <source>ICON_OCCVIEWER_VIEW_FITSELECTION</source>
+ <translation>occ_view_fitselection.png</translation>
+ </message>
<message>
<source>ICON_OCCVIEWER_CLONE_VIEW</source>
<translation>occ_view_clone.png</translation>
<source>DSC_FITRECT</source>
<translation>Fit area within the view frame</translation>
</message>
+ <message>
+ <source>MNU_FITSELECTION</source>
+ <translation>Fit Selection</translation>
+ </message>
+ <message>
+ <source>DSC_FITSELECTION</source>
+ <translation>Fit all selected objects inside the view frame</translation>
+ </message>
<message>
<source>MNU_PRESETS_VIEW</source>
<translation>Restore View</translation>
<source>DSC_FITRECT</source>
<translation>Redimensionner la scène pour ne montrer que sa partie choisie par l'encadré</translation>
</message>
+ <message>
+ <source>MNU_FITSELECTION</source>
+ <translation type="unfinished">Fit Selection</translation>
+ </message>
+ <message>
+ <source>DSC_FITSELECTION</source>
+ <translation type="unfinished">Fit all selected objects inside the view frame</translation>
+ </message>
<message>
<source>MNU_PRESETS_VIEW</source>
<translation>Restaurer la vue</translation>
<source>DSC_FITRECT</source>
<translation>彼の党をボックスで選択を表示するには、ステージのサイズを変更します。</translation>
</message>
+ <message>
+ <source>MNU_FITSELECTION</source>
+ <translation type="unfinished">Fit Selection</translation>
+ </message>
+ <message>
+ <source>DSC_FITSELECTION</source>
+ <translation type="unfinished">Fit all selected objects inside the view frame</translation>
+ </message>
<message>
<source>MNU_PRESETS_VIEW</source>
<translation>ビューの読み込み</translation>
::ResetCameraClippingRange(GetDevice());
}
+/*!
+ Fit all selected presentation in the scene
+*/
+void SVTK_Renderer::onFitSelection()
+{
+ vtkActorCollection* aSelectedCollection = vtkActorCollection::New();
+
+ VTK::ActorCollectionCopy aCopy( GetDevice()->GetActors() );
+ vtkActorCollection* aCollection = aCopy.GetActors();
+ aCollection->InitTraversal();
+ while ( vtkActor* aProp = aCollection->GetNextActor() )
+ if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( aProp ) )
+ if ( mySelector->IsSelected( anActor ) )
+ aSelectedCollection->AddItem( aProp );
+
+ double bounds[6];
+ ::ComputeBounds( aSelectedCollection, bounds );
+
+ if ( aSelectedCollection->GetNumberOfItems() && ::isBoundValid( bounds ) ) {
+ GetDevice()->ResetCamera( bounds );
+ GetDevice()->ResetCameraClippingRange( bounds );
+ }
+}
+
/*!
Reset camera clipping range to adjust the range to the bounding box of the scene
*/
//----------------------------------------------------------------------------
//! Fit all presentation in the scene into the window
void OnFitAll();
-
+
+ //----------------------------------------------------------------------------
+ //! Fit all selected presentation in the scene
+ void onFitSelection();
+
//! Set camera into predefined state
void OnResetView();
emit transformed( this );
}
+/*!
+ Processes transformation "fit selection"
+*/
+void SVTK_ViewWindow::onFitSelection()
+{
+ GetRenderer()->onFitSelection();
+ Repaint();
+ emit transformed( this );
+}
+
/*!
SLOT: called if selection is changed
*/
connect(anAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
mgr->registerAction( anAction, FitRectId );
+ // FitSelection
+ anAction = new QtxAction(tr("MNU_FITSELECTION"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITSELECTION" ) ),
+ tr( "MNU_FITSELECTION" ), 0, this);
+ anAction->setStatusTip(tr("DSC_FITSELECTION"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onFitSelection()));
+ mgr->registerAction( anAction, FitSelectionId );
+
// Zoom
anAction = new QtxAction(tr("MNU_ZOOM_VIEW"),
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
QtxMultiAction* aScaleAction = new QtxMultiAction( this );
aScaleAction->insertAction( getAction( FitAllId ) );
aScaleAction->insertAction( getAction( FitRectId ) );
+ aScaleAction->insertAction( getAction( FitSelectionId ) );
aScaleAction->insertAction( getAction( ZoomId ) );
mgr->append( aScaleAction, myToolBar );
//! Redirect the request to #SVTK_Renderer::OnFitAll
virtual void onFitAll();
+ //! Redirect the request to #SVTK_Renderer::OnFitSelection
+ virtual void onFitSelection();
+
//! Redirect the request to #SVTK_Renderer::OnViewTrihedron
virtual void onViewTrihedron(bool);
void createToolBar();
void createActions(SUIT_ResourceMgr* theResourceMgr);
- enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId,
+ enum { DumpId, FitAllId, FitRectId, FitSelectionId, ZoomId, PanId, GlobalPanId,
ChangeRotationPointId, RotationId,
FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId, ResetId,
ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate,
<source>MNU_FITRECT</source>
<translation>Fit Area</translation>
</message>
+ <message>
+ <source>MNU_FITSELECTION</source>
+ <translation>Fit Selection</translation>
+ </message>
+ <message>
+ <source>DSC_FITSELECTION</source>
+ <translation>Fit all selected objects inside the view frame</translation>
+ </message>
<message>
<source>DSC_BOTTOM_VIEW</source>
<translation>+OZ View</translation>
<source>MNU_FITRECT</source>
<translation>Afficher la zone</translation>
</message>
+ <message>
+ <source>MNU_FITSELECTION</source>
+ <translation type="unfinished">Fit Selection</translation>
+ </message>
+ <message>
+ <source>DSC_FITSELECTION</source>
+ <translation type="unfinished">Fit all selected objects inside the view frame</translation>
+ </message>
<message>
<source>DSC_BOTTOM_VIEW</source>
<translation>Vue +OZ</translation>
<source>MNU_FITRECT</source>
<translation>選択領域の表示</translation>
</message>
+ <message>
+ <source>MNU_FITSELECTION</source>
+ <translation type="unfinished">Fit Selection</translation>
+ </message>
+ <message>
+ <source>DSC_FITSELECTION</source>
+ <translation type="unfinished">Fit all selected objects inside the view frame</translation>
+ </message>
<message>
<source>DSC_BOTTOM_VIEW</source>
<translation>+OZ View</translation>
resources/vtk_view_camera_dump.png
resources/vtk_view_fitall.png
resources/vtk_view_fitarea.png
+ resources/vtk_view_fitselection.png
resources/vtk_view_front.png
resources/vtk_view_glpan.png
resources/vtk_view_left.png
::ResetCameraClippingRange(CurrentRenderer);
}
+/*!View fit selection.*/
+void VTKViewer_InteractorStyle::ViewFitSelection() {
+
+ vtkActorCollection* aSelectedCollection = vtkActorCollection::New();
+
+ VTK::ActorCollectionCopy aCopy( CurrentRenderer->GetActors() );
+ vtkActorCollection* aCollection = aCopy.GetActors();
+ aCollection->InitTraversal();
+ while ( vtkActor* aProp = aCollection->GetNextActor() )
+ if ( VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast( aProp ) )
+ if ( anActor->isPreselected() )
+ aSelectedCollection->AddItem( aProp );
+
+ double bounds[6];
+ ::ComputeBounds( aSelectedCollection, bounds );
+
+ if ( aSelectedCollection->GetNumberOfItems() && ::isBoundValid( bounds ) ) {
+ CurrentRenderer->ResetCamera( bounds );
+ CurrentRenderer->ResetCameraClippingRange( bounds );
+ }
+}
+
/*! starts Global Panning operation (e.g. through menu command)*/
void VTKViewer_InteractorStyle::startGlobalPan()
void OnSelectionModeChanged();
- void ViewFitAll();
+ void ViewFitAll();
+ void ViewFitSelection();
void SetFilter( const Handle( VTKViewer_Filter)& );
Handle(VTKViewer_Filter) GetFilter( const int );
int
ComputeVisiblePropBounds(vtkRenderer* theRenderer,
double theBounds[6])
+{
+ VTK::ActorCollectionCopy aCopy(theRenderer->GetActors());
+ vtkActorCollection* aCollection = aCopy.GetActors();
+ return ComputeBounds( aCollection, theBounds );
+}
+
+/*! Compute the bounds of actors*/
+int
+ComputeBounds(vtkActorCollection* theCollection, double theBounds[6])
{
int aCount = 0;
-
+
theBounds[0] = theBounds[2] = theBounds[4] = VTK_LARGE_FLOAT;
theBounds[1] = theBounds[3] = theBounds[5] = -VTK_LARGE_FLOAT;
-
+
// loop through all props
- VTK::ActorCollectionCopy aCopy(theRenderer->GetActors());
- vtkActorCollection* aCollection = aCopy.GetActors();
- aCollection->InitTraversal();
- while (vtkActor* aProp = aCollection->GetNextActor()) {
- // if it's invisible, or has no geometry, we can skip the rest
+ theCollection->InitTraversal();
+ while (vtkActor* aProp = theCollection->GetNextActor()) {
+ // if it's invisible, or has no geometry, we can skip the rest
if(aProp->GetVisibility() && aProp->GetMapper() && vtkMath::AreBoundsInitialized(aProp->GetBounds())){
if(VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast(aProp))
if(anActor->IsInfinitive())
#include "VTKViewer.h"
class vtkRenderer;
+class vtkActorCollection;
VTKVIEWER_EXPORT
extern
ComputeVisiblePropBounds(vtkRenderer* theRenderer,
double theBounds[6]);
+VTKVIEWER_EXPORT
+extern
+int
+ComputeBounds(vtkActorCollection* theCollection,
+ double theBounds[6]);
+
VTKVIEWER_EXPORT
extern
void
connect(aAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
myActionsMap[ FitRectId ] = aAction;
+ //! \li FitSelection
+ aAction = new QtxAction(tr("MNU_FITSELECTION"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITSELECTION" ) ),
+ tr( "MNU_FITSELECTION" ), 0, this);
+ aAction->setStatusTip(tr("DSC_FITSELECTION"));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onFitSelection()));
+ myActionsMap[ FitSelectionId ] = aAction;
+
//! \li Zoom
aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
tr( "MNU_ZOOM_VIEW" ), 0, this);
QtxMultiAction* aScaleAction = new QtxMultiAction( this );
aScaleAction->insertAction( myActionsMap[FitAllId] );
aScaleAction->insertAction( myActionsMap[FitRectId] );
+ aScaleAction->insertAction( myActionsMap[FitSelectionId] );
aScaleAction->insertAction( myActionsMap[ZoomId] );
myToolBar->addAction( aScaleAction );
Repaint();
}
+/*!On fit selection slot.*/
+void VTKViewer_ViewWindow::onFitSelection()
+{
+ myRWInteractor->GetInteractorStyle()->ViewFitSelection();
+ Repaint();
+}
+
/*!Set background color of the viewport [obsolete]*/
void VTKViewer_ViewWindow::setBackgroundColor( const QColor& c )
{
void onAntiClockWiseView();
void onResetView();
void onFitAll();
+ void onFitSelection();
void activateZoom();
void activateWindowFit();
void activateRotation();
void MoveActor( VTKViewer_Actor* theActor );
private:
- enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
+ enum { DumpId, FitAllId, FitRectId, FitSelectionId, ZoomId, PanId, GlobalPanId, RotationId,
FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId,
ResetId, TrihedronShowId };
typedef QMap<int, QtxAction*> ActionsMap;
<source>ICON_VTKVIEWER_VIEW_FITAREA</source>
<translation>vtk_view_fitarea.png</translation>
</message>
+ <message>
+ <source>ICON_VTKVIEWER_VIEW_FITSELECTION</source>
+ <translation>vtk_view_fitselection.png</translation>
+ </message>
<message>
<source>ICON_VTKVIEWER_VIEW_FRONT</source>
<translation>vtk_view_front.png</translation>
<source>MNU_FITRECT</source>
<translation>Fit Area</translation>
</message>
+ <message>
+ <source>MNU_FITSELECTION</source>
+ <translation>Fit Selection</translation>
+ </message>
+ <message>
+ <source>DSC_FITSELECTION</source>
+ <translation>Fit all selected objects inside the view frame</translation>
+ </message>
<message>
<source>DSC_BOTTOM_VIEW</source>
<translation>Bottom View</translation>
<source>MNU_FITRECT</source>
<translation>Ajuster à la zone</translation>
</message>
+ <message>
+ <source>MNU_FITSELECTION</source>
+ <translation type="unfinished">Fit Selection</translation>
+ </message>
+ <message>
+ <source>DSC_FITSELECTION</source>
+ <translation type="unfinished">Fit all selected objects inside the view frame</translation>
+ </message>
<message>
<source>DSC_BOTTOM_VIEW</source>
<translation>Vue de dessous</translation>
<source>MNU_FITRECT</source>
<translation>選択範囲表示</translation>
</message>
+ <message>
+ <source>MNU_FITSELECTION</source>
+ <translation type="unfinished">Fit Selection</translation>
+ </message>
+ <message>
+ <source>DSC_FITSELECTION</source>
+ <translation type="unfinished">Fit all selected objects inside the view frame</translation>
+ </message>
<message>
<source>DSC_BOTTOM_VIEW</source>
<translation>下から表示します。</translation>