ProcessVoidEvent( new TEvent() );
}
+void SALOMEGUI_Swig::FitSelection()
+{
+ class TEvent: public SALOME_Event
+ {
+ public:
+ TEvent() {}
+ virtual void Execute()
+ {
+ if ( LightApp_Application* anApp = getApplication() ) {
+ SUIT_ViewManager* viewMgr = anApp->activeViewManager();
+ if (!viewMgr) return;
+ SUIT_ViewWindow* window = viewMgr->getActiveView();
+ if ( window ) {
+#if !defined(DISABLE_SALOMEOBJECT) && !defined(DISABLE_VTKVIEWER)
+ if ( dynamic_cast<SVTK_ViewWindow*>( window ) )
+ (dynamic_cast<SVTK_ViewWindow*>( window ))->onFitSelection();
+#endif
+#if !defined(DISABLE_OCCVIEWER)
+ if ( dynamic_cast<OCCViewer_ViewWindow*>( window ) )
+ (dynamic_cast<OCCViewer_ViewWindow*>( window ))->onFitSelection();
+#endif
+ }
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent() );
+}
+
+void SALOMEGUI_Swig::FitIObjects(const std::list<std::string>& entries)
+{
+ class TEvent: public SALOME_Event
+ {
+ const std::list<std::string>& myEntries;
+ public:
+ TEvent( const std::list<std::string>& objs ) : myEntries( objs ) {}
+ virtual void Execute()
+ {
+ if ( LightApp_Application* anApp = getApplication() ) {
+ SUIT_ViewManager* viewMgr = anApp->activeViewManager();
+ if (!viewMgr) return;
+ SUIT_ViewWindow* window = viewMgr->getActiveView();
+ if ( window ) {
+ SALOME_ListIO objects;
+ std::list<std::string>::const_iterator it;
+ for ( it = myEntries.begin(); it != myEntries.end(); ++it )
+ objects.Append( new SALOME_InteractiveObject( (*it).c_str(), "" ) );
+#if !defined(DISABLE_SALOMEOBJECT) && !defined(DISABLE_VTKVIEWER)
+ if ( dynamic_cast<SVTK_ViewWindow*>( window ) )
+ (dynamic_cast<SVTK_ViewWindow*>( window ))->onFitIObjects( objects );
+#endif
+ }
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent( entries ) );
+}
+
/*!
\brief Reset current view window to the default state.
*/
#ifndef SALOMEGUI_SWIG_HXX
#define SALOMEGUI_SWIG_HXX
+#include <string>
+#include <list>
+
class SALOMEGUI_Swig
{
public:
void UpdateView();
void FitAll();
+ void FitSelection();
+ void FitIObjects(const std::list<std::string>&);
void ResetView();
void ViewTop();
void ViewBottom();
%}
%include "cpointer.i"
+%include "std_string.i"
+%include "std_list.i"
+
+#if SWIG_VERSION >= 0x010329
+%template() std::list<std::string>;
+#endif
/* Exception handler for all functions */
%exception {
/* view operations */
void FitAll();
+ void FitSelection();
+ void FitIObjects(const std::list<std::string>&);
void ResetView();
void ViewTop();
void ViewBottom();
}
}
+void SVTK_Renderer::OnFitIObjects(const SALOME_ListIO& objects)
+{
+ 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 ) ) {
+ const Handle(SALOME_InteractiveObject)& io = anActor->getIO();
+ if ( anActor->GetVisibility() && !io.IsNull() ) {
+ SALOME_ListIteratorOfListIO iter( objects );
+ for ( ; iter.More(); iter.Next() ) {
+ if ( iter.Value().IsNull() )
+ continue;
+ if ( io->isSame( iter.Value() ) ) {
+ aSelectedCollection->AddItem( aProp );
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if( aSelectedCollection->GetNumberOfItems() == 0 )
+ return; // if collection is empty
+
+ 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
*/
#include "SVTK.h"
#include "VTKViewer.h"
+#include "SALOME_ListIO.hxx"
#include <vtkObject.h>
#include <vtkSmartPointer.h>
//! Fit all selected presentation in the scene
void onFitSelection();
+ //! Fit given presentations in the scene
+ void OnFitIObjects(const SALOME_ListIO& objects);
+
//! Set camera into predefined state
void OnResetView();
emit transformed( this );
}
+/*!
+ Processes transformation "fit given objects"
+*/
+void SVTK_ViewWindow::onFitIObjects(const SALOME_ListIO& objects)
+{
+ GetRenderer()->OnFitIObjects(objects);
+ Repaint();
+ emit transformed( this );
+}
+
/*!
SLOT: called if selection is changed
*/
#include "SUIT_ViewWindow.h"
#include "SALOME_InteractiveObject.hxx"
+#include "SALOME_ListIO.hxx"
#include <QImage>
#include <vtkSmartPointer.h>
//! Redirect the request to #SVTK_Renderer::OnFitSelection
virtual void onFitSelection();
+ //! Redirect the request to #SVTK_Renderer::OnFitIObjects
+ virtual void onFitIObjects(const SALOME_ListIO&);
+
//! Redirect the request to #SVTK_Renderer::OnViewTrihedron
virtual void onViewTrihedron(bool);