-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
#include "VTKViewer_RenderWindowInteractor.h"
#include "VTKViewer_RenderWindow.h"
#include "VTKViewer_InteractorStyle.h"
#include "SUIT_ViewModel.h"
#include "VTKViewer_ViewWindow.h"
-//#include "SUIT_Application.h"
-//#include "SUIT_Desktop.h"
-
-//#include "SALOME_Selection.h"
#include "VTKViewer_Actor.h"
#include "VTKViewer_Algorithm.h"
#include "VTKViewer_Functor.h"
-//#include <stdio.h>
-//#include <stdlib.h>
-//#include <string.h>
-//#include <math.h>
-
// VTK Includes
#include <vtkAssemblyNode.h>
#include <vtkActor.h>
#include <vtkVertex.h>
#include <vtkRendererCollection.h>
#include <vtkPolyDataWriter.h>
+#include <vtkProperty.h>
// QT Includes
-#include <qkeycode.h>
+#include <QTimer>
+#include <QMouseEvent>
+#include <QKeyEvent>
+#include <QContextMenuEvent>
/*! Create new instance of VTKViewer_RenderWindowInteractor*/
VTKViewer_RenderWindowInteractor* VTKViewer_RenderWindowInteractor::New()
myPointPicker->Delete();
}
+/*!
+ Print interactor to stream
+ \param os - stream
+ \param indent
+*/
void VTKViewer_RenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent)
{
vtkRenderWindowInteractor::PrintSelf(os, indent) ;
vtkRenderWindowInteractor::SetInteractorStyle(theInteractor);
}
-
-/*
-void VTKViewer_RenderWindowInteractor::SetSelectionMode(Selection_Mode theMode)
-{
- myCellActor->SetVisibility(false);
- myEdgeActor->SetVisibility(false);
- myPointActor->SetVisibility(false);
-
- switch(theMode){
- case ActorSelection:
- this->SetPicker(myBasicPicker);
- break;
- case NodeSelection:
- this->SetPicker(myPointPicker);
- break;
- case CellSelection:
- case EdgeSelection:
- case FaceSelection:
- case VolumeSelection:
- case EdgeOfCellSelection:
- this->SetPicker(myCellPicker);
- break;
- }
-
- myInteractorStyle->OnSelectionModeChanged();
-}
-*/
-
/*!Sets selection properties.
*\param theRed - red component of color
*\param theGreen - green component of color
///
/// Start a one-shot timer for 10ms.
///
- mTimer->start(10, TRUE) ;
+ mTimer->setSingleShot(true) ;
+ mTimer->start(10) ;
return 1 ;
}
-/**@see CreateTimer(int )
- *\retval 1
+/*!
+ \sa CreateTimer(int )
+ \retval 1
*/
int VTKViewer_RenderWindowInteractor::DestroyTimer(void)
{
return ;
}
- ((vtkInteractorStyle*)this->InteractorStyle)->OnTimer() ;
+ ((vtkInteractorStyle*)this->InteractorStyle.Get())->OnTimer() ;
emit RenderWindowModified() ;
}
if( ! this->Enabled ) {
return ;
}
- myInteractorStyle->OnLeftButtonDown((event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y());
+ myInteractorStyle->OnLeftButtonDown((event->modifiers() & Qt::ControlModifier),
+ (event->modifiers() & Qt::ShiftModifier),
+ event->x(), event->y());
}
/*!Reaction on left button releases.\n
if( ! this->Enabled ) {
return ;
}
- myInteractorStyle->OnLeftButtonUp( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+ myInteractorStyle->OnLeftButtonUp( (event->modifiers() & Qt::ControlModifier),
+ (event->modifiers() & Qt::ShiftModifier),
+ event->x(), event->y() ) ;
}
/*!Reaction on middle button pressed.\n
if( ! this->Enabled ) {
return ;
}
- myInteractorStyle->OnMiddleButtonDown((event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+ myInteractorStyle->OnMiddleButtonDown((event->modifiers() & Qt::ControlModifier),
+ (event->modifiers() & Qt::ShiftModifier),
+ event->x(), event->y() ) ;
}
/*!Reaction on middle button released.\n
if( ! this->Enabled ) {
return ;
}
- myInteractorStyle->OnMiddleButtonUp( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+ myInteractorStyle->OnMiddleButtonUp( (event->modifiers() & Qt::ControlModifier),
+ (event->modifiers() & Qt::ShiftModifier),
+ event->x(), event->y() ) ;
}
/*!Reaction on right button pressed.\n
if( ! this->Enabled ) {
return ;
}
- myInteractorStyle->OnRightButtonDown( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+ myInteractorStyle->OnRightButtonDown( (event->modifiers() & Qt::ControlModifier),
+ (event->modifiers() & Qt::ShiftModifier),
+ event->x(), event->y() ) ;
}
/*!Reaction on right button released.\n
return ;
}
bool isOperation = myInteractorStyle->CurrentState() != VTK_INTERACTOR_STYLE_CAMERA_NONE;
- myInteractorStyle->OnRightButtonUp( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() );
+ myInteractorStyle->OnRightButtonUp( (event->modifiers() & Qt::ControlModifier),
+ (event->modifiers() & Qt::ShiftModifier),
+ event->x(), event->y() );
if ( !isOperation )
{
QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
- event->pos(), event->globalPos(),
- event->state() );
+ event->pos(), event->globalPos() );
emit contextMenuRequested( &aEvent );
}
}
/*!Reaction on button pressed.
*\warning Do nothing.
*/
-void VTKViewer_RenderWindowInteractor::ButtonPressed(const QMouseEvent *event) {
+void VTKViewer_RenderWindowInteractor::ButtonPressed(const QMouseEvent* /*event*/) {
return ;
}
/*!Reaction on button released..
*\warning Do nothing.
*/
-void VTKViewer_RenderWindowInteractor::ButtonReleased(const QMouseEvent *event) {
+void VTKViewer_RenderWindowInteractor::ButtonReleased(const QMouseEvent* /*event*/) {
return ;
}
void VTKViewer_RenderWindowInteractor::SetDisplayMode(int theMode) {
if(theMode == 0)
ChangeRepresentationToWireframe();
- else
+ else if (theMode == 1)
ChangeRepresentationToSurface();
+ else if (theMode == 2) {
+ ChangeRepresentationToSurfaceWithEdges();
+ theMode++;
+ }
myDisplayMode = theMode;
}
/*!Change all actors to wireframe*/
void VTKViewer_RenderWindowInteractor::ChangeRepresentationToWireframe()
{
- ChangeRepresentationToWireframe(GetRenderer()->GetActors());
+ using namespace VTK;
+ ActorCollectionCopy aCopy(GetRenderer()->GetActors());
+ ChangeRepresentationToWireframe(aCopy.GetActors());
}
/*!Change all actors to surface*/
void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface()
{
- ChangeRepresentationToSurface(GetRenderer()->GetActors());
+ using namespace VTK;
+ ActorCollectionCopy aCopy(GetRenderer()->GetActors());
+ ChangeRepresentationToSurface(aCopy.GetActors());
+}
+
+/*!Change all actors to surface with edges*/
+void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurfaceWithEdges()
+{
+ using namespace VTK;
+ ActorCollectionCopy aCopy(GetRenderer()->GetActors());
+ ChangeRepresentationToSurfaceWithEdges(aCopy.GetActors());
}
/*!Change all actors from \a theCollection to wireframe and
{
using namespace VTK;
ForEach<VTKViewer_Actor>(theCollection,
- TSetFunction<VTKViewer_Actor,int>
- (&VTKViewer_Actor::setDisplayMode,0));
+ TSetFunction<VTKViewer_Actor,int>
+ (&VTKViewer_Actor::setDisplayMode,0));
emit RenderWindowModified();
}
{
using namespace VTK;
ForEach<VTKViewer_Actor>(theCollection,
- TSetFunction<VTKViewer_Actor,int>
- (&VTKViewer_Actor::setDisplayMode,1));
+ TSetFunction<VTKViewer_Actor,int>
+ (&VTKViewer_Actor::setDisplayMode,1));
+ emit RenderWindowModified();
+}
+
+/*!Change all actors from \a theCollection to surface with edges and
+ * emit render window modified.
+ */
+void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurfaceWithEdges(vtkActorCollection* theCollection)
+{
+ using namespace VTK;
+ ForEach<VTKViewer_Actor>(theCollection,
+ TSetFunction<VTKViewer_Actor,int>
+ (&VTKViewer_Actor::setDisplayMode,3));
emit RenderWindowModified();
}
void VTKViewer_RenderWindowInteractor::DisplayAll()
{
using namespace VTK;
- vtkActorCollection* aCollection = GetRenderer()->GetActors();
- ForEach<VTKViewer_Actor>(aCollection,TSetVisibility<VTKViewer_Actor>(true));
+ ActorCollectionCopy aCopy(GetRenderer()->GetActors());
+ ForEach<VTKViewer_Actor>(aCopy.GetActors(),TSetVisibility<VTKViewer_Actor>(true));
emit RenderWindowModified() ;
}
/*!Do nothing*/
-void VTKViewer_RenderWindowInteractor::Erase( VTKViewer_Actor* SActor, bool update)
+void VTKViewer_RenderWindowInteractor::Erase( VTKViewer_Actor* /*SActor*/, bool /*update*/)
{
}
{
if ( SActor != 0 )
{
- GetRenderer()->RemoveProp( SActor );
+ GetRenderer()->RemoveViewProp( SActor );
if ( updateViewer )
emit RenderWindowModified();
}
*/
void VTKViewer_RenderWindowInteractor::RemoveAll( const bool updateViewer )
{
+ using namespace VTK;
vtkRenderer* aRenderer = GetRenderer();
- vtkActorCollection* anActors = aRenderer->GetActors();
+ ActorCollectionCopy aCopy(aRenderer->GetActors());
+ vtkActorCollection* anActors = aCopy.GetActors();
if ( anActors )
{
anActors->InitTraversal();
emit RenderWindowModified();
}
-void VTKViewer_RenderWindowInteractor::KeyPressed(QKeyEvent *event)
+/*!
+ default key press event (empty implementation)
+*/
+void VTKViewer_RenderWindowInteractor::KeyPressed(QKeyEvent* /*event*/)
{
/// NOT_IMPLEMENTED
}
void VTKViewer_RenderWindowInteractor::Update() {
using namespace VTK;
vtkRenderer* aRen = GetRenderer();
- ForEach<vtkActor>(aRen->GetActors(),TUpdateAction());
+ ActorCollectionCopy aCopy(aRen->GetActors());
+ ForEach<vtkActor>(aCopy.GetActors(),TUpdateAction());
aRen->ResetCamera();
* else sets visibility to false.
* \li Emit render window modified, if flag \a update - true.
*/
-bool VTKViewer_RenderWindowInteractor::highlight(const TColStd_IndexedMapOfInteger& theMapIndex,
- VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor,
- TUpdateActor theFun, bool hilight, bool update)
+bool VTKViewer_RenderWindowInteractor::highlight(const TIndexedMapOfVtkId& theMapIndex,
+ VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor,
+ TUpdateActor theFun, bool hilight, bool update)
{
if(theMapIndex.Extent() == 0) return false;
}
/*!Sets actors data.*/
-void VTKViewer_RenderWindowInteractor::setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
- VTKViewer_Actor * theMapActor,
- VTKViewer_Actor * theActor,
- TUpdateActor theFun)
+void VTKViewer_RenderWindowInteractor::setActorData(const TIndexedMapOfVtkId& theMapIndex,
+ VTKViewer_Actor * theMapActor,
+ VTKViewer_Actor * theActor,
+ TUpdateActor theFun)
{
(*theFun)(theMapIndex,theMapActor,theActor);
- float aPos[3];
+ double aPos[3];
theMapActor->GetPosition(aPos);
theActor->SetPosition(aPos);
}