]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
To separate SVT_View class hierarchy from SVTK_MainWindow
authorapo <apo@opencascade.com>
Mon, 26 Sep 2005 14:17:47 +0000 (14:17 +0000)
committerapo <apo@opencascade.com>
Mon, 26 Sep 2005 14:17:47 +0000 (14:17 +0000)
src/SVTK/Makefile.in
src/SVTK/SVTK.cxx
src/SVTK/SVTK_MainWindow.cxx [new file with mode: 0644]
src/SVTK/SVTK_MainWindow.h [new file with mode: 0644]
src/SVTK/SVTK_RenderWindowInteractor.cxx
src/SVTK/SVTK_RenderWindowInteractor.h
src/SVTK/SVTK_View.cxx
src/SVTK/SVTK_View.h
src/SVTK/SVTK_ViewModel.cxx
src/SVTK/SVTK_ViewWindow.cxx

index 9e81cb01d0032e5e14f83de7e2aeb3789d6e3e5e..bf8c8e599a303ff25c290ed3a1efd7022eba1ba5 100755 (executable)
@@ -12,65 +12,85 @@ VPATH=.:@srcdir@
 @COMMENCE@
 
 # header files
-EXPORT_HEADERS= SVTK.h \
-               SVTK_Prs.h \
-               SVTK_Actor.h \
-               SALOME_Actor.h \
-               SVTK_CubeAxesActor2D.h \
-               SVTK_Functor.h \
-               SVTK_View.h \
-               SVTK_ViewManager.h \
-               SVTK_ViewModel.h \
-               SVTK_ViewWindow.h \
-               SVTK_Renderer.h \
-               SVTK_InteractorStyle.h \
-               SVTK_RenderWindowInteractor.h \
-               SVTK_GenericRenderWindowInteractor.h \
-               SVTK_Selector.h \
-               SVTK_Selection.h \
-               SVTK_SelectionEvent.h \
-               SVTK_SpaceMouse.h \
-               SVTK_Event.h \
-               SVTK_ViewModelBase.h
+EXPORT_HEADERS= \
+       SVTK.h \
+       SVTK_Prs.h \
+       SVTK_Actor.h \
+       SALOME_Actor.h \
+       SVTK_CubeAxesActor2D.h \
+       SVTK_NonIsometricDlg.h \
+       SVTK_Functor.h \
+       SVTK_MainWindow.h \
+       SVTK_View.h \
+       SVTK_ViewManager.h \
+       SVTK_ViewModel.h \
+       SVTK_ViewWindow.h \
+       SVTK_Renderer.h \
+       SVTK_InteractorStyle.h \
+       SVTK_RenderWindowInteractor.h \
+       SVTK_GenericRenderWindowInteractor.h \
+       SVTK_Selector.h \
+       SVTK_Selection.h \
+       SVTK_SelectionEvent.h \
+       SVTK_SpaceMouse.h \
+       SVTK_Event.h \
+       SVTK_ViewModelBase.h
 
 # Libraries targets
 LIB = libSVTK.la
 
-LIB_SRC=       SVTK_Prs.cxx \
-               SVTK_Actor.cxx \
-               SALOME_Actor.cxx \
-               SVTK_CubeAxesActor2D.cxx \
-               SVTK_Trihedron.cxx \
-               SVTK_View.cxx \
-               SVTK_ViewManager.cxx \
-               SVTK_ViewModel.cxx \
-               SVTK_Renderer.cxx \
-               SVTK_ViewWindow.cxx \
-               SVTK_InteractorStyle.cxx \
-               SVTK_RenderWindowInteractor.cxx \
-               SVTK_GenericRenderWindowInteractor.cxx \
-               SVTK_SpaceMouse.cxx \
-               SVTK_Selector.cxx
+LIB_SRC= \
+       SVTK_Prs.cxx \
+       SVTK_Actor.cxx \
+       SALOME_Actor.cxx \
+       SVTK_CubeAxesActor2D.cxx \
+       SVTK_NonIsometricDlg.cxx \
+       SVTK_Trihedron.cxx \
+       SVTK_MainWindow.cxx \
+       SVTK_View.cxx \
+       SVTK_ViewManager.cxx \
+       SVTK_ViewModel.cxx \
+       SVTK_Renderer.cxx \
+       SVTK_ViewWindow.cxx \
+       SVTK_InteractorStyle.cxx \
+       SVTK_RenderWindowInteractor.cxx \
+       SVTK_GenericRenderWindowInteractor.cxx \
+       SVTK_SpaceMouse.cxx \
+       SVTK_Selector.cxx
 
-LIB_MOC =      SVTK_GenericRenderWindowInteractor.h \
-               SVTK_RenderWindowInteractor.h \
-               SVTK_ViewModelBase.h \
-               SVTK_ViewManager.h \
-               SVTK_ViewWindow.h \
-               SVTK_ViewModel.h \
-               SVTK_View.h
+LIB_MOC = \
+       SVTK_GenericRenderWindowInteractor.h \
+       SVTK_RenderWindowInteractor.h \
+       SVTK_NonIsometricDlg.h \
+       SVTK_ViewModelBase.h \
+       SVTK_ViewManager.h \
+       SVTK_ViewWindow.h \
+       SVTK_MainWindow.h \
+       SVTK_ViewModel.h \
+       SVTK_View.h
 
-LIB_CLIENT_IDL = SALOMEDS.idl \
-                SALOMEDS_Attributes.idl \
-                SALOME_Exception.idl \
-                SALOME_ModuleCatalog.idl \
-                SALOME_GenericObj.idl
+LIB_CLIENT_IDL = \
+       SALOMEDS.idl \
+       SALOMEDS_Attributes.idl \
+       SALOME_Exception.idl \
+       SALOME_ModuleCatalog.idl \
+       SALOME_GenericObj.idl
 
 BIN = SVTK
 
-CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) -I$(KERNEL_ROOT_DIR)/include/salome
+CPPFLAGS+= \
+       $(QT_INCLUDES) \
+       $(OCC_INCLUDES) \
+       $(VTK_INCLUDES) \
+       $(BOOST_CPPFLAGS) \
+       -I$(KERNEL_ROOT_DIR)/include/salome
+
+LDFLAGS+= \
+       $(QT_MT_LIBS) \
+       $(OCC_LIBS) \
+       $(VTK_LIBS) \
+       -L$(KERNEL_ROOT_DIR)/lib/salome
 
-LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) -L$(KERNEL_ROOT_DIR)/lib/salome
 LIBS+= -lsuit -lCAM -lSalomeObject -lSalomePrs -lVTKViewer -lOpUtil -lToolsGUI -lSalomeDS
 
 @CONCLUDE@
index d1b3ec18461a48cf74614e208c4aadffdd228133..20b3ae94ce019f3ab56487a18c48eb9aaa51a48a 100644 (file)
@@ -33,7 +33,9 @@
 #include "SVTK_CubeAxesActor2D.h"
 #include "SVTK_Functor.h"
 #include "SVTK_View.h"
-#include "SVTK_ViewManager.h"
+#include "SVTK_MainWindow.h"
+#include "SVTK_MainWindow.h"
+#include "SVTK_NonIsometricDlg.h"
 #include "SVTK_ViewModel.h"
 #include "SVTK_ViewWindow.h"
 #include "SVTK_Renderer.h"
diff --git a/src/SVTK/SVTK_MainWindow.cxx b/src/SVTK/SVTK_MainWindow.cxx
new file mode 100644 (file)
index 0000000..e0a7fa3
--- /dev/null
@@ -0,0 +1,684 @@
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+//  Copyright (C) 2003  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 
+//  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 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   : 
+//  Author : 
+//  Module : SALOME
+//  $Header$
+
+#include "SALOME_Actor.h"
+
+#include <vtkGenericRenderWindowInteractor.h>
+#include <vtkRenderer.h>
+
+#include "QtxAction.h"
+
+#include "SUIT_ToolButton.h"
+#include "SUIT_MessageBox.h"
+
+#include "SUIT_Tools.h"
+#include "SUIT_ResourceMgr.h"
+#include "SVTK_NonIsometricDlg.h"
+
+#include "SVTK_MainWindow.h"
+#include "SVTK_Event.h"
+#include "SVTK_Renderer.h"
+#include "SVTK_RenderWindowInteractor.h"
+
+#include "SVTK_Selector.h"
+
+#include <qimage.h>
+
+#include "utilities.h"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+//----------------------------------------------------------------------------
+SVTK_MainWindow
+::SVTK_MainWindow(QWidget* theParent, 
+                 const char* theName,
+                 SUIT_ResourceMgr* theResourceMgr) :
+  QMainWindow(theParent,theName,0)
+{
+  if(MYDEBUG) INFOS("SVTK_MainWindow() - "<<this);
+
+  myToolBar = new QToolBar(this);
+  myToolBar->setCloseMode(QDockWindow::Undocked);
+  myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
+
+  createActions(theResourceMgr);
+  createToolBar();
+}
+
+void
+SVTK_MainWindow
+::Initialize(SVTK_RenderWindowInteractor* theInteractor)
+{
+  myInteractor = theInteractor;
+  SetEventDispatcher(myInteractor->GetDevice());
+
+  setCentralWidget(myInteractor);
+
+  myInteractor->setFocusPolicy(StrongFocus);
+  myInteractor->setFocus();
+  setFocusProxy(myInteractor);
+}
+
+
+//----------------------------------------------------------------------------
+SVTK_MainWindow
+::~SVTK_MainWindow()
+{
+  if(MYDEBUG) INFOS("~SVTK_MainWindow() - "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+SVTK_RenderWindowInteractor*
+SVTK_MainWindow
+::GetInteractor()
+{
+  return myInteractor;
+}
+
+vtkRenderWindowInteractor*
+SVTK_MainWindow
+::getInteractor()
+{
+  return GetInteractor()->GetDevice();
+}
+
+vtkRenderWindow*
+SVTK_MainWindow
+::getRenderWindow()
+{
+  return GetInteractor()->getRenderWindow();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::Repaint() 
+{ 
+  Repaint( true ); 
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::Repaint(bool theUpdateTrihedron)
+{
+  if(theUpdateTrihedron) 
+    GetRenderer()->OnAdjustTrihedron();
+
+  GetInteractor()->update();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::InvokeEvent(unsigned long theEvent, void* theCallData)
+{
+  GetInteractor()->InvokeEvent(theEvent,theCallData);
+}
+
+//----------------------------------------------------------------------------
+vtkInteractorStyle*
+SVTK_MainWindow
+::GetInteractorStyle()
+{
+  return GetInteractor()->GetInteractorStyle();
+}
+
+void
+SVTK_MainWindow
+::PushInteractorStyle(vtkInteractorStyle* theStyle)
+{
+  GetInteractor()->PushInteractorStyle(theStyle);
+}
+
+void
+SVTK_MainWindow
+::PopInteractorStyle()
+{
+  GetInteractor()->PopInteractorStyle();
+}
+
+//----------------------------------------------------------------------------
+SVTK_Selector*
+SVTK_MainWindow
+::GetSelector()
+{
+  return GetInteractor()->GetSelector();
+}
+
+Selection_Mode
+SVTK_MainWindow
+::SelectionMode()
+{
+  return GetSelector()->SelectionMode();
+}
+
+void
+SVTK_MainWindow
+::SetSelectionMode(Selection_Mode theMode)
+{
+  GetSelector()->SetSelectionMode(theMode);
+}
+
+
+//----------------------------------------------------------------------------
+SVTK_Renderer* 
+SVTK_MainWindow
+::GetRenderer()
+{
+  return GetInteractor()->GetRenderer();
+}
+
+vtkRenderer* 
+SVTK_MainWindow
+::getRenderer()
+{
+  return GetInteractor()->getRenderer();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::SetBackgroundColor(const QColor& theColor)
+{
+  getRenderer()->SetBackground(theColor.red()/255.0, 
+                              theColor.green()/255.0,
+                              theColor.blue()/255.0);
+}
+
+QColor
+SVTK_MainWindow
+::BackgroundColor()
+{
+  float aBackgroundColor[3];
+  getRenderer()->GetBackground(aBackgroundColor);
+  return QColor(int(aBackgroundColor[0]*255), 
+               int(aBackgroundColor[1]*255), 
+               int(aBackgroundColor[2]*255));
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::GetScale( double theScale[3] ) 
+{
+  GetRenderer()->GetScale( theScale );
+}
+
+void
+SVTK_MainWindow
+::SetScale( double theScale[3] ) 
+{
+  GetRenderer()->SetScale( theScale );
+  Repaint();
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::AddActor(VTKViewer_Actor* theActor, 
+          bool theIsUpdate)
+{
+  GetRenderer()->AddActor(theActor);
+  if(theIsUpdate) 
+    Repaint();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::RemoveActor(VTKViewer_Actor* theActor, 
+             bool theIsUpdate)
+{
+  GetRenderer()->RemoveActor(theActor);
+  if(theIsUpdate) 
+    Repaint();
+}
+
+
+//----------------------------------------------------------------------------
+int
+SVTK_MainWindow
+::GetTrihedronSize()
+{
+  return GetRenderer()->GetTrihedronSize();
+}
+
+//----------------------------------------------------------------------------
+void 
+SVTK_MainWindow
+::SetTrihedronSize( const int theSize )
+{
+  GetRenderer()->SetTrihedronSize(theSize);
+  Repaint();
+}
+
+
+//----------------------------------------------------------------------------
+/*! If parameter theIsForcedUpdate is true, recalculate parameters for
+ *  trihedron and cube axes, even if trihedron and cube axes is invisible.
+ */
+void
+SVTK_MainWindow
+::AdjustActors()
+{
+  GetRenderer()->AdjustActors();
+  Repaint();
+}
+
+//----------------------------------------------------------------------------
+bool
+SVTK_MainWindow
+::IsTrihedronDisplayed()
+{
+  return GetRenderer()->IsTrihedronDisplayed();
+}
+
+//----------------------------------------------------------------------------
+bool
+SVTK_MainWindow
+::IsCubeAxesDisplayed()
+{
+  return GetRenderer()->IsCubeAxesDisplayed();
+}
+
+//----------------------------------------------------------------------------
+VTKViewer_Trihedron*  
+SVTK_MainWindow
+::GetTrihedron() 
+{ 
+  return GetRenderer()->GetTrihedron(); 
+}
+
+//----------------------------------------------------------------------------
+SVTK_CubeAxesActor2D* 
+SVTK_MainWindow
+::GetCubeAxes() 
+{ 
+  return GetRenderer()->GetCubeAxes(); 
+}
+
+
+//----------------------------------------------------------------------------
+QToolBar* 
+SVTK_MainWindow
+::getToolBar()
+{
+  return myToolBar;
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::SetEventDispatcher(vtkObject* theDispatcher)
+{
+  myEventDispatcher = theDispatcher;
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::createActions(SUIT_ResourceMgr* theResourceMgr)
+{
+  if(!myActionsMap.isEmpty()) 
+    return;
+  
+  QtxAction* anAction;
+
+  // Dump view
+  anAction = new QtxAction(tr("MNU_DUMP_VIEW"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
+                          tr( "MNU_DUMP_VIEW" ), 0, this);
+  anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(onDumpView()));
+  myActionsMap[ DumpId ] = anAction;
+
+  // FitAll
+  anAction = new QtxAction(tr("MNU_FITALL"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
+                          tr( "MNU_FITALL" ), 0, this);
+  anAction->setStatusTip(tr("DSC_FITALL"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(onFitAll()));
+  myActionsMap[ FitAllId ] = anAction;
+
+  // FitRect
+  anAction = new QtxAction(tr("MNU_FITRECT"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
+                          tr( "MNU_FITRECT" ), 0, this);
+  anAction->setStatusTip(tr("DSC_FITRECT"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
+  myActionsMap[ FitRectId ] = anAction;
+
+  // Zoom
+  anAction = new QtxAction(tr("MNU_ZOOM_VIEW"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
+                          tr( "MNU_ZOOM_VIEW" ), 0, this);
+  anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(activateZoom()));
+  myActionsMap[ ZoomId ] = anAction;
+
+  // Panning
+  anAction = new QtxAction(tr("MNU_PAN_VIEW"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
+                          tr( "MNU_PAN_VIEW" ), 0, this);
+  anAction->setStatusTip(tr("DSC_PAN_VIEW"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(activatePanning()));
+  myActionsMap[ PanId ] = anAction;
+
+  // Global Panning
+  anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
+                          tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
+  anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
+  myActionsMap[ GlobalPanId ] = anAction;
+
+  // Rotation
+  anAction = new QtxAction(tr("MNU_ROTATE_VIEW"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
+                          tr( "MNU_ROTATE_VIEW" ), 0, this);
+  anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(activateRotation()));
+  myActionsMap[ RotationId ] = anAction;
+
+  // Projections
+  anAction = new QtxAction(tr("MNU_FRONT_VIEW"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
+                          tr( "MNU_FRONT_VIEW" ), 0, this);
+  anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(onFrontView()));
+  myActionsMap[ FrontId ] = anAction;
+
+  anAction = new QtxAction(tr("MNU_BACK_VIEW"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
+                          tr( "MNU_BACK_VIEW" ), 0, this);
+  anAction->setStatusTip(tr("DSC_BACK_VIEW"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(onBackView()));
+  myActionsMap[ BackId ] = anAction;
+
+  anAction = new QtxAction(tr("MNU_TOP_VIEW"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
+                          tr( "MNU_TOP_VIEW" ), 0, this);
+  anAction->setStatusTip(tr("DSC_TOP_VIEW"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(onTopView()));
+  myActionsMap[ TopId ] = anAction;
+
+  anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
+                          tr( "MNU_BOTTOM_VIEW" ), 0, this);
+  anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(onBottomView()));
+  myActionsMap[ BottomId ] = anAction;
+
+  anAction = new QtxAction(tr("MNU_LEFT_VIEW"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
+                          tr( "MNU_LEFT_VIEW" ), 0, this);
+  anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(onLeftView()));
+  myActionsMap[ LeftId ] = anAction;
+
+  anAction = new QtxAction(tr("MNU_RIGHT_VIEW"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
+                          tr( "MNU_RIGHT_VIEW" ), 0, this);
+  anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(onRightView()));
+  myActionsMap[ RightId ] = anAction;
+
+  // Reset
+  anAction = new QtxAction(tr("MNU_RESET_VIEW"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
+                          tr( "MNU_RESET_VIEW" ), 0, this);
+  anAction->setStatusTip(tr("DSC_RESET_VIEW"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(onResetView()));
+  myActionsMap[ ResetId ] = anAction;
+
+  // onViewTrihedron: Shows - Hides Trihedron
+  anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
+                          tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
+  anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
+  connect(anAction, SIGNAL(activated()), this, SLOT(onViewTrihedron()));
+  myActionsMap[ ViewTrihedronId ] = anAction;
+
+  // onNonIsometric: Manage non-isometric params
+  anAction = new QtxAction(tr("MNU_SVTK_SCALING"), 
+                          theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SCALING" ) ),
+                          tr( "MNU_SVTK_SCALING" ), 0, this);
+  anAction->setStatusTip(tr("DSC_SVTK_SCALING"));
+  anAction->setToggleAction(true);
+  connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onNonIsometric(bool)));
+  myActionsMap[ NonIsometric ] = anAction;
+
+  myNonIsometricDlg = new SVTK_NonIsometricDlg(this,"SVTK_NonIsometricDlg",anAction);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::createToolBar()
+{
+  myActionsMap[DumpId]->addTo(myToolBar);
+  myActionsMap[ViewTrihedronId]->addTo(myToolBar);
+
+  SUIT_ToolButton* aScaleBtn = new SUIT_ToolButton(myToolBar);
+  aScaleBtn->AddAction(myActionsMap[FitAllId]);
+  aScaleBtn->AddAction(myActionsMap[FitRectId]);
+  aScaleBtn->AddAction(myActionsMap[ZoomId]);
+
+  SUIT_ToolButton* aPanningBtn = new SUIT_ToolButton(myToolBar);
+  aPanningBtn->AddAction(myActionsMap[PanId]);
+  aPanningBtn->AddAction(myActionsMap[GlobalPanId]);
+
+  myActionsMap[RotationId]->addTo(myToolBar);
+
+  SUIT_ToolButton* aViewsBtn = new SUIT_ToolButton(myToolBar);
+  aViewsBtn->AddAction(myActionsMap[FrontId]);
+  aViewsBtn->AddAction(myActionsMap[BackId]);
+  aViewsBtn->AddAction(myActionsMap[TopId]);
+  aViewsBtn->AddAction(myActionsMap[BottomId]);
+  aViewsBtn->AddAction(myActionsMap[LeftId]);
+  aViewsBtn->AddAction(myActionsMap[RightId]);
+
+  myActionsMap[ResetId]->addTo(myToolBar);
+
+  myActionsMap[NonIsometric]->addTo(myToolBar);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::activateZoom()
+{
+  myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::activatePanning()
+{
+  myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::activateRotation()
+{
+  myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::activateGlobalPanning()
+{
+  myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::activateWindowFit()
+{
+  myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onFrontView()
+{
+  GetRenderer()->OnFrontView();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onBackView()
+{
+  GetRenderer()->OnBackView();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onTopView()
+{
+  GetRenderer()->OnTopView();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onBottomView()
+{
+  GetRenderer()->OnBottomView();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onLeftView()
+{
+  GetRenderer()->OnLeftView();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onRightView()
+{
+  GetRenderer()->OnRightView();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onResetView()
+{
+  GetRenderer()->OnResetView();
+  Repaint();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onFitAll()
+{
+  GetRenderer()->OnFitAll();
+  Repaint();
+}
+
+//----------------------------------------------------------------------------
+void 
+SVTK_MainWindow
+::onViewTrihedron()
+{
+  GetRenderer()->OnViewTrihedron();
+  Repaint();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onViewCubeAxes()
+{
+  GetRenderer()->OnViewCubeAxes();
+  Repaint();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onNonIsometric(bool theIsActivate)
+{
+  if(theIsActivate){
+    myNonIsometricDlg->Update();
+    myNonIsometricDlg->show();
+  }else
+    myNonIsometricDlg->hide();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onAdjustTrihedron()
+{   
+  GetRenderer()->OnAdjustTrihedron();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onAdjustCubeAxes()
+{   
+  GetRenderer()->OnAdjustCubeAxes();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onDumpView()
+{}
+
+//----------------------------------------------------------------------------
+QImage
+SVTK_MainWindow
+::dumpView()
+{
+  QPixmap px = QPixmap::grabWindow( GetInteractor()->winId() );
+  return px.convertToImage();
+}
diff --git a/src/SVTK/SVTK_MainWindow.h b/src/SVTK/SVTK_MainWindow.h
new file mode 100644 (file)
index 0000000..8dc24a4
--- /dev/null
@@ -0,0 +1,204 @@
+#ifndef SVTK_MAINWINDOW_H
+#define SVTK_MAINWINDOW_H
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+#include "SVTK.h"
+#include "SVTK_Selection.h"
+
+#include <vtkSmartPointer.h>
+
+#include <qmainwindow.h>
+
+class QtxAction;
+
+class vtkObject;
+class vtkRenderer;
+class vtkRenderWindow;
+class vtkInteractorStyle;
+class vtkRenderWindowInteractor;
+
+class SUIT_ResourceMgr;
+
+class SVTK_RenderWindowInteractor;
+class SVTK_NonIsometricDlg;
+class SVTK_CubeAxesActor2D;
+
+class VTKViewer_Trihedron;
+class VTKViewer_Transform;
+class VTKViewer_Actor;
+
+class SVTK_Renderer;
+class SVTK_Selector;
+
+
+//----------------------------------------------------------------------------
+class SVTK_EXPORT SVTK_MainWindow: public QMainWindow
+{
+  Q_OBJECT;
+
+public:
+  SVTK_MainWindow(QWidget* theParent, 
+                 const char* theName,
+                 SUIT_ResourceMgr* theResourceMgr);
+
+  virtual
+  void
+  Initialize(SVTK_RenderWindowInteractor* theInteractor);
+
+  virtual
+  ~SVTK_MainWindow();
+
+  //----------------------------------------------------------------------------
+  void
+  SetInteractor(SVTK_RenderWindowInteractor* theInteractor);
+
+  SVTK_RenderWindowInteractor*
+  GetInteractor();
+
+  vtkRenderWindowInteractor*
+  getInteractor();
+
+  vtkRenderWindow*
+  getRenderWindow();
+
+  void
+  Repaint();
+
+  void
+  Repaint(bool theUpdateTrihedron);
+
+  void
+  InvokeEvent(unsigned long theEvent, void* theCallData);
+
+  //----------------------------------------------------------------------------
+  vtkInteractorStyle* 
+  GetInteractorStyle();
+
+  void
+  PushInteractorStyle(vtkInteractorStyle* theStyle);
+
+  void
+  PopInteractorStyle();
+
+  //----------------------------------------------------------------------------
+  SVTK_Selector* 
+  GetSelector();
+
+  Selection_Mode
+  SelectionMode();
+
+  void 
+  SetSelectionMode(Selection_Mode theMode);
+
+  //----------------------------------------------------------------------------
+  SVTK_Renderer* 
+  GetRenderer();
+
+  vtkRenderer* 
+  getRenderer();
+
+  void
+  SetBackgroundColor(const QColor& theColor);
+
+  QColor 
+  BackgroundColor();
+
+  void
+  SetScale(double theScale[3]);
+
+  void
+  GetScale(double theScale[3]);
+
+  void 
+  AddActor(VTKViewer_Actor* theActor, 
+          bool theIsUpdate = false);
+
+  void 
+  RemoveActor(VTKViewer_Actor* theActor, 
+             bool theIsUpdate = false);
+
+  int  
+  GetTrihedronSize();
+
+  void
+  SetTrihedronSize(const int theSize);
+
+  void 
+  AdjustActors();
+
+  bool
+  IsTrihedronDisplayed();
+  bool
+  IsCubeAxesDisplayed();
+
+  VTKViewer_Trihedron* 
+  GetTrihedron();
+
+  SVTK_CubeAxesActor2D*
+  GetCubeAxes();
+
+  //----------------------------------------------------------------------------
+  QToolBar* getToolBar();
+
+ public slots:
+  void activateZoom();
+  void activateWindowFit();
+  void activateRotation();
+  void activatePanning(); 
+  void activateGlobalPanning(); 
+
+  void onFrontView(); 
+  void onBackView(); 
+  void onTopView();
+  void onBottomView();
+  void onRightView(); 
+  void onLeftView();     
+
+  void onResetView();     
+  void onFitAll();
+
+  void onViewTrihedron(); 
+  void onViewCubeAxes();
+
+  void onNonIsometric(bool theIsActivate);
+
+  void onAdjustTrihedron();
+  void onAdjustCubeAxes();
+
+  void onDumpView();
+
+ public:
+  QImage dumpView();
+
+ protected:  
+  void
+  createActions(SUIT_ResourceMgr* theResourceMgr);
+
+  void
+  createToolBar();
+
+  void
+  SetEventDispatcher(vtkObject* theDispatcher);
+
+  enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
+         FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, 
+        ViewTrihedronId, NonIsometric};
+  typedef QMap<int, QtxAction*> TActionsMap;
+
+  SVTK_NonIsometricDlg* myNonIsometricDlg;
+  vtkSmartPointer<vtkObject> myEventDispatcher;
+  TActionsMap myActionsMap;  
+  QToolBar* myToolBar;
+
+  SVTK_RenderWindowInteractor* myInteractor;
+};
+
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
+#endif
index f3e42388f42ec5b2959b5a9fa8a917bbec77e4f1..0a151acdff8499dd04e17e875bbb5490de67a31a 100644 (file)
 
 #include "VTKViewer_Algorithm.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
 // VTK Includes
 #include <vtkObjectFactory.h>
 #include <vtkRendererCollection.h>
@@ -56,6 +51,7 @@
 
 // QT Includes
 #include <qtimer.h>
+#include <qapplication.h>
 #include <qcolordialog.h>
 #include <qpaintdevice.h>
 
@@ -226,6 +222,9 @@ void
 QVTK_RenderWindowInteractor
 ::mouseMoveEvent( QMouseEvent* event ) 
 {
+  if(qApp->focusWidget() != this)
+    setFocus();
+
   GetDevice()->SetEventInformationFlipY(event->x(), 
                                        event->y(),
                                        event->state() & ControlButton,
@@ -312,7 +311,7 @@ QVTK_RenderWindowInteractor
 //----------------------------------------------------------------------------
 void  
 QVTK_RenderWindowInteractor
-::focusInEvent ( QFocusEvent* event )
+::focusInEvent( QFocusEvent* event )
 {
   QWidget::focusInEvent( event );
 
@@ -333,7 +332,7 @@ void
 QVTK_RenderWindowInteractor
 ::focusOutEvent ( QFocusEvent* event )
 {
-  QWidget::focusInEvent( event );
+  QWidget::focusOutEvent( event );
 
   // unregister set space mouse events receiver
   if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance()){
index 4655bdadd9d58f7f7ea66416fad734e106cfddc9..717c81a0d5d609b4b78082759e324649ed1ebb8d 100644 (file)
@@ -183,6 +183,7 @@ class SVTK_EXPORT SVTK_RenderWindowInteractor: public QVTK_RenderWindowInteracto
   void
   InitInteractorStyle(vtkInteractorStyle* theStyle);
 
+  //----------------------------------------------------------------
   // Main process VTK event method
   static
   void
@@ -197,6 +198,7 @@ class SVTK_EXPORT SVTK_RenderWindowInteractor: public QVTK_RenderWindowInteracto
   // Priority at which events are processed
   float myPriority;
 
+  //----------------------------------------------------------------
   vtkSmartPointer<SVTK_Selector> mySelector;
 
   vtkSmartPointer<SVTK_Renderer> myRenderer;
index d45739326ac48dd778da1fb75ae73113bf5cb2c7..f20f1c0ef0ee1cbe414572603a47853e7359a821 100644 (file)
 
 #include "SALOME_Actor.h"
 
-#include <qapplication.h>
-#include <qpushbutton.h>
-
-#include <vtkGenericRenderWindowInteractor.h>
-#include <vtkCallbackCommand.h>
-#include <vtkTextProperty.h>
-#include <vtkActorCollection.h>
-#include <vtkRenderer.h>
-#include <vtkCamera.h>
-#include <vtkCellPicker.h>
-#include <vtkPointPicker.h>
-#include <vtkRenderWindow.h>
-
-#include "QtxAction.h"
-
-#include "SUIT_Session.h"
-#include "SUIT_ToolButton.h"
-#include "SUIT_MessageBox.h"
-
-#include "SUIT_Tools.h"
-#include "SUIT_ResourceMgr.h"
-
-#include "VTKViewer_Utilities.h"
-#include "VTKViewer_CellRectPicker.h"
-
 #include "SVTK_View.h"
-#include "SVTK_Event.h"
 #include "SVTK_Renderer.h"
-#include "SVTK_ViewModel.h"
-#include "SVTK_InteractorStyle.h"
+#include "SVTK_MainWindow.h"
 #include "SVTK_RenderWindowInteractor.h"
-
 #include "SALOME_ListIteratorOfListIO.hxx"
 
-#include "SVTK_SelectorDef.h"
-
 #include "VTKViewer_Algorithm.h"
 #include "SVTK_Functor.h"
 
+#include <vtkActorCollection.h>
+#include <vtkRenderer.h>
+
 #include "utilities.h"
 
 #ifdef _DEBUG_
@@ -76,607 +49,6 @@ static int MYDEBUG = 0;
 #endif
 
 
-//----------------------------------------------------------------------------
-SVTK_MainWindow
-::SVTK_MainWindow(QWidget* theParent, 
-                 const char* theName,
-                 SUIT_ResourceMgr* theResourceMgr) :
-  QMainWindow(theParent,theName,0)
-{
-  if(MYDEBUG) INFOS("SVTK_MainWindow() - "<<this);
-
-  myToolBar = new QToolBar(this);
-  myToolBar->setCloseMode(QDockWindow::Undocked);
-  myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
-
-  createActions(theResourceMgr);
-  createToolBar();
-}
-
-void
-SVTK_MainWindow
-::Initialize(SVTK_RenderWindowInteractor* theInteractor)
-{
-  myInteractor = theInteractor;
-  SetEventDispatcher(myInteractor->GetDevice());
-
-  setCentralWidget(myInteractor);
-
-  myInteractor->setFocusPolicy(StrongFocus);
-  myInteractor->setFocus();
-  setFocusProxy(myInteractor);
-}
-
-
-//----------------------------------------------------------------------------
-SVTK_MainWindow
-::~SVTK_MainWindow()
-{
-  if(MYDEBUG) INFOS("~SVTK_MainWindow() - "<<this);
-}
-
-
-//----------------------------------------------------------------------------
-SVTK_RenderWindowInteractor*
-SVTK_MainWindow
-::GetInteractor()
-{
-  return myInteractor;
-}
-
-vtkRenderWindowInteractor*
-SVTK_MainWindow
-::getInteractor()
-{
-  return GetInteractor()->GetDevice();
-}
-
-vtkRenderWindow*
-SVTK_MainWindow
-::getRenderWindow()
-{
-  return GetInteractor()->getRenderWindow();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::Repaint() 
-{ 
-  Repaint( true ); 
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::Repaint(bool theUpdateTrihedron)
-{
-  if(theUpdateTrihedron) 
-    GetRenderer()->OnAdjustTrihedron();
-
-  GetInteractor()->update();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::InvokeEvent(unsigned long theEvent, void* theCallData)
-{
-  GetInteractor()->InvokeEvent(theEvent,theCallData);
-}
-
-//----------------------------------------------------------------------------
-vtkInteractorStyle*
-SVTK_MainWindow
-::GetInteractorStyle()
-{
-  return GetInteractor()->GetInteractorStyle();
-}
-
-void
-SVTK_MainWindow
-::PushInteractorStyle(vtkInteractorStyle* theStyle)
-{
-  GetInteractor()->PushInteractorStyle(theStyle);
-}
-
-void
-SVTK_MainWindow
-::PopInteractorStyle()
-{
-  GetInteractor()->PopInteractorStyle();
-}
-
-//----------------------------------------------------------------------------
-SVTK_Selector*
-SVTK_MainWindow
-::GetSelector()
-{
-  return GetInteractor()->GetSelector();
-}
-
-Selection_Mode
-SVTK_MainWindow
-::SelectionMode()
-{
-  return GetSelector()->SelectionMode();
-}
-
-void
-SVTK_MainWindow
-::SetSelectionMode(Selection_Mode theMode)
-{
-  GetSelector()->SetSelectionMode(theMode);
-}
-
-
-//----------------------------------------------------------------------------
-SVTK_Renderer* 
-SVTK_MainWindow
-::GetRenderer()
-{
-  return GetInteractor()->GetRenderer();
-}
-
-vtkRenderer* 
-SVTK_MainWindow
-::getRenderer()
-{
-  return GetInteractor()->getRenderer();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::SetBackgroundColor(const QColor& theColor)
-{
-  getRenderer()->SetBackground(theColor.red()/255.0, 
-                              theColor.green()/255.0,
-                              theColor.blue()/255.0);
-}
-
-QColor
-SVTK_MainWindow
-::BackgroundColor()
-{
-  float aBackgroundColor[3];
-  getRenderer()->GetBackground(aBackgroundColor);
-  return QColor(int(aBackgroundColor[0]*255), 
-               int(aBackgroundColor[1]*255), 
-               int(aBackgroundColor[2]*255));
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::GetScale( double theScale[3] ) 
-{
-  GetRenderer()->GetScale( theScale );
-}
-
-void
-SVTK_MainWindow
-::SetScale( double theScale[3] ) 
-{
-  GetRenderer()->SetScale( theScale );
-  Repaint();
-}
-
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::AddActor(VTKViewer_Actor* theActor, 
-          bool theIsUpdate)
-{
-  GetRenderer()->AddActor(theActor);
-  if(theIsUpdate) 
-    Repaint();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::RemoveActor(VTKViewer_Actor* theActor, 
-             bool theIsUpdate)
-{
-  GetRenderer()->RemoveActor(theActor);
-  if(theIsUpdate) 
-    Repaint();
-}
-
-
-//----------------------------------------------------------------------------
-int
-SVTK_MainWindow
-::GetTrihedronSize()
-{
-  return GetRenderer()->GetTrihedronSize();
-}
-
-//----------------------------------------------------------------------------
-void 
-SVTK_MainWindow
-::SetTrihedronSize( const int theSize )
-{
-  GetRenderer()->SetTrihedronSize(theSize);
-  Repaint();
-}
-
-
-//----------------------------------------------------------------------------
-/*! If parameter theIsForcedUpdate is true, recalculate parameters for
- *  trihedron and cube axes, even if trihedron and cube axes is invisible.
- */
-void
-SVTK_MainWindow
-::AdjustActors()
-{
-  GetRenderer()->AdjustActors();
-  Repaint();
-}
-
-//----------------------------------------------------------------------------
-bool
-SVTK_MainWindow
-::IsTrihedronDisplayed()
-{
-  return GetRenderer()->IsTrihedronDisplayed();
-}
-
-//----------------------------------------------------------------------------
-bool
-SVTK_MainWindow
-::IsCubeAxesDisplayed()
-{
-  return GetRenderer()->IsCubeAxesDisplayed();
-}
-
-//----------------------------------------------------------------------------
-VTKViewer_Trihedron*  
-SVTK_MainWindow
-::GetTrihedron() 
-{ 
-  return GetRenderer()->GetTrihedron(); 
-}
-
-//----------------------------------------------------------------------------
-SVTK_CubeAxesActor2D* 
-SVTK_MainWindow
-::GetCubeAxes() 
-{ 
-  return GetRenderer()->GetCubeAxes(); 
-}
-
-
-//----------------------------------------------------------------------------
-QToolBar* 
-SVTK_MainWindow
-::getToolBar()
-{
-  return myToolBar;
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::SetEventDispatcher(vtkObject* theDispatcher)
-{
-  myEventDispatcher = theDispatcher;
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::createActions(SUIT_ResourceMgr* theResourceMgr)
-{
-  if(!myActionsMap.isEmpty()) 
-    return;
-  
-  QtxAction* aAction;
-
-  // Dump view
-  aAction = new QtxAction(tr("MNU_DUMP_VIEW"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
-                         tr( "MNU_DUMP_VIEW" ), 0, this);
-  aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView()));
-  myActionsMap[ DumpId ] = aAction;
-
-  // FitAll
-  aAction = new QtxAction(tr("MNU_FITALL"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
-                         tr( "MNU_FITALL" ), 0, this);
-  aAction->setStatusTip(tr("DSC_FITALL"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onFitAll()));
-  myActionsMap[ FitAllId ] = aAction;
-
-  // FitRect
-  aAction = new QtxAction(tr("MNU_FITRECT"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
-                         tr( "MNU_FITRECT" ), 0, this);
-  aAction->setStatusTip(tr("DSC_FITRECT"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
-  myActionsMap[ FitRectId ] = aAction;
-
-  // Zoom
-  aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
-                         tr( "MNU_ZOOM_VIEW" ), 0, this);
-  aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(activateZoom()));
-  myActionsMap[ ZoomId ] = aAction;
-
-  // Panning
-  aAction = new QtxAction(tr("MNU_PAN_VIEW"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
-                         tr( "MNU_PAN_VIEW" ), 0, this);
-  aAction->setStatusTip(tr("DSC_PAN_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(activatePanning()));
-  myActionsMap[ PanId ] = aAction;
-
-  // Global Panning
-  aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
-                         tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
-  aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
-  myActionsMap[ GlobalPanId ] = aAction;
-
-  // Rotation
-  aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
-                         tr( "MNU_ROTATE_VIEW" ), 0, this);
-  aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(activateRotation()));
-  myActionsMap[ RotationId ] = aAction;
-
-  // Projections
-  aAction = new QtxAction(tr("MNU_FRONT_VIEW"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
-                         tr( "MNU_FRONT_VIEW" ), 0, this);
-  aAction->setStatusTip(tr("DSC_FRONT_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onFrontView()));
-  myActionsMap[ FrontId ] = aAction;
-
-  aAction = new QtxAction(tr("MNU_BACK_VIEW"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
-                         tr( "MNU_BACK_VIEW" ), 0, this);
-  aAction->setStatusTip(tr("DSC_BACK_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onBackView()));
-  myActionsMap[ BackId ] = aAction;
-
-  aAction = new QtxAction(tr("MNU_TOP_VIEW"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
-                         tr( "MNU_TOP_VIEW" ), 0, this);
-  aAction->setStatusTip(tr("DSC_TOP_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onTopView()));
-  myActionsMap[ TopId ] = aAction;
-
-  aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
-                         tr( "MNU_BOTTOM_VIEW" ), 0, this);
-  aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onBottomView()));
-  myActionsMap[ BottomId ] = aAction;
-
-  aAction = new QtxAction(tr("MNU_LEFT_VIEW"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
-                         tr( "MNU_LEFT_VIEW" ), 0, this);
-  aAction->setStatusTip(tr("DSC_LEFT_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onLeftView()));
-  myActionsMap[ LeftId ] = aAction;
-
-  aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
-                         tr( "MNU_RIGHT_VIEW" ), 0, this);
-  aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onRightView()));
-  myActionsMap[ RightId ] = aAction;
-
-  // Reset
-  aAction = new QtxAction(tr("MNU_RESET_VIEW"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
-                         tr( "MNU_RESET_VIEW" ), 0, this);
-  aAction->setStatusTip(tr("DSC_RESET_VIEW"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onResetView()));
-  myActionsMap[ ResetId ] = aAction;
-
-  // onViewTrihedron: Shows - Hides Trihedron
-  aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), 
-                         theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
-                         tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
-  aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
-  connect(aAction, SIGNAL(activated()), this, SLOT(onViewTrihedron()));
-  myActionsMap[ ViewTrihedronId ] = aAction;
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::createToolBar()
-{
-  myActionsMap[DumpId]->addTo(myToolBar);
-  myActionsMap[ViewTrihedronId]->addTo(myToolBar);
-
-  SUIT_ToolButton* aScaleBtn = new SUIT_ToolButton(myToolBar);
-  aScaleBtn->AddAction(myActionsMap[FitAllId]);
-  aScaleBtn->AddAction(myActionsMap[FitRectId]);
-  aScaleBtn->AddAction(myActionsMap[ZoomId]);
-
-  SUIT_ToolButton* aPanningBtn = new SUIT_ToolButton(myToolBar);
-  aPanningBtn->AddAction(myActionsMap[PanId]);
-  aPanningBtn->AddAction(myActionsMap[GlobalPanId]);
-
-  myActionsMap[RotationId]->addTo(myToolBar);
-
-  SUIT_ToolButton* aViewsBtn = new SUIT_ToolButton(myToolBar);
-  aViewsBtn->AddAction(myActionsMap[FrontId]);
-  aViewsBtn->AddAction(myActionsMap[BackId]);
-  aViewsBtn->AddAction(myActionsMap[TopId]);
-  aViewsBtn->AddAction(myActionsMap[BottomId]);
-  aViewsBtn->AddAction(myActionsMap[LeftId]);
-  aViewsBtn->AddAction(myActionsMap[RightId]);
-
-  myActionsMap[ResetId]->addTo(myToolBar);
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::activateZoom()
-{
-  myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::activatePanning()
-{
-  myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::activateRotation()
-{
-  myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::activateGlobalPanning()
-{
-  myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::activateWindowFit()
-{
-  myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::onFrontView()
-{
-  GetRenderer()->OnFrontView();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::onBackView()
-{
-  GetRenderer()->OnBackView();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::onTopView()
-{
-  GetRenderer()->OnTopView();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::onBottomView()
-{
-  GetRenderer()->OnBottomView();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::onLeftView()
-{
-  GetRenderer()->OnLeftView();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::onRightView()
-{
-  GetRenderer()->OnRightView();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::onResetView()
-{
-  GetRenderer()->OnResetView();
-  Repaint();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::onFitAll()
-{
-  GetRenderer()->OnFitAll();
-  Repaint();
-}
-
-//----------------------------------------------------------------------------
-void 
-SVTK_MainWindow
-::onViewTrihedron()
-{
-  GetRenderer()->OnViewTrihedron();
-  Repaint();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::onViewCubeAxes()
-{
-  GetRenderer()->OnViewCubeAxes();
-  Repaint();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::onAdjustTrihedron()
-{   
-  GetRenderer()->OnAdjustTrihedron();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::onAdjustCubeAxes()
-{   
-  GetRenderer()->OnAdjustCubeAxes();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_MainWindow
-::onDumpView()
-{}
-
-//----------------------------------------------------------------------------
-QImage
-SVTK_MainWindow
-::dumpView()
-{
-  QPixmap px = QPixmap::grabWindow( GetInteractor()->winId() );
-  return px.convertToImage();
-}
-
-
 //----------------------------------------------------------------------------
 SVTK_SignalHandler
 ::SVTK_SignalHandler(SVTK_MainWindow* theMainWindow):
@@ -812,11 +184,13 @@ void
 SVTK_View
 ::unHighlightAll() 
 {
-  using namespace VTK;
-  ForEach<SALOME_Actor>(getRenderer()->GetActors(),
-                       THighlightAction( false ));
-
-  Repaint();
+  if(SVTK_Selector* aSelector = myMainWindow->GetSelector()){
+    using namespace VTK;
+    ForEach<SALOME_Actor>(getRenderer()->GetActors(),
+                         THighlightAction( false ));
+    aSelector->EndPickCallback();
+    Repaint();
+  }
 }
 
 //----------------------------------------------------------------
@@ -826,13 +200,14 @@ SVTK_View
             bool theIsHighlight, 
             bool theIsUpdate ) 
 {
-  using namespace VTK;
-  SVTK_Selector* aSelector = myMainWindow->GetSelector();
-  ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
-                         TIsSameIObject<SALOME_Actor>( theIO ),
-                         THighlightAction( theIsHighlight, aSelector->SelectionMode() ));
-  
-  Repaint();
+  if(SVTK_Selector* aSelector = myMainWindow->GetSelector()){
+    using namespace VTK;
+    ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+                           TIsSameIObject<SALOME_Actor>( theIO ),
+                           THighlightAction( theIsHighlight, aSelector->SelectionMode() ));
+    aSelector->EndPickCallback();
+    Repaint();
+  }
 }
 
 //----------------------------------------------------------------------------
index 0365e2a073155bde483e46fbd02e2c74a0c612fa..f0d32bacf573e1dde6d9dbebba42d22676928553 100644 (file)
 #endif
 
 #include "SVTK.h"
-#include "SVTK_Selection.h"
 #include "SALOME_InteractiveObject.hxx"
 
-#include <vtkSmartPointer.h>
+#include <qobject.h>
 
-#include <qmainwindow.h>
-
-class QtxAction;
-
-class vtkRenderer;
-class vtkRenderWindow;
-class vtkInteractorStyle;
-class vtkRenderWindowInteractor;
-
-class vtkObject;
-class vtkCallbackCommand;
 class vtkActorCollection;
+class vtkRenderer;
 
-class SUIT_ResourceMgr;
-class VTKViewer_Actor;
-
-class SVTK_Viewer;
-class SVTK_Selector;
-
-class SVTK_CubeAxesActor2D;
-class VTKViewer_Trihedron;
-class VTKViewer_Transform;
-class VTKViewer_Actor;
+class SVTK_MainWindow;
 class SVTK_Renderer;
 
-class SVTK_RenderWindow;
-class SVTK_RenderWindowInteractor;
-
 class SALOME_Actor;
 
-//----------------------------------------------------------------------------
-class SVTK_EXPORT SVTK_MainWindow: public QMainWindow
-{
-  Q_OBJECT;
-
-public:
-  SVTK_MainWindow(QWidget* theParent, 
-                 const char* theName,
-                 SUIT_ResourceMgr* theResourceMgr);
-
-  virtual
-  void
-  Initialize(SVTK_RenderWindowInteractor* theInteractor);
-
-  virtual
-  ~SVTK_MainWindow();
-
-  //----------------------------------------------------------------------------
-  void
-  SetInteractor(SVTK_RenderWindowInteractor* theInteractor);
-
-  SVTK_RenderWindowInteractor*
-  GetInteractor();
-
-  vtkRenderWindowInteractor*
-  getInteractor();
-
-  vtkRenderWindow*
-  getRenderWindow();
-
-  void
-  Repaint();
-
-  void
-  Repaint(bool theUpdateTrihedron);
-
-  void
-  InvokeEvent(unsigned long theEvent, void* theCallData);
-
-  //----------------------------------------------------------------------------
-  vtkInteractorStyle* 
-  GetInteractorStyle();
-
-  void
-  PushInteractorStyle(vtkInteractorStyle* theStyle);
-
-  void
-  PopInteractorStyle();
-
-  //----------------------------------------------------------------------------
-  SVTK_Selector* 
-  GetSelector();
-
-  Selection_Mode
-  SelectionMode();
-
-  void 
-  SetSelectionMode(Selection_Mode theMode);
-
-  //----------------------------------------------------------------------------
-  SVTK_Renderer* 
-  GetRenderer();
-
-  vtkRenderer* 
-  getRenderer();
-
-  void
-  SetBackgroundColor(const QColor& theColor);
-
-  QColor 
-  BackgroundColor();
-
-  void
-  SetScale(double theScale[3]);
-
-  void
-  GetScale(double theScale[3]);
-
-  void 
-  AddActor(VTKViewer_Actor* theActor, 
-          bool theIsUpdate = false);
-
-  void 
-  RemoveActor(VTKViewer_Actor* theActor, 
-             bool theIsUpdate = false);
-
-  int  
-  GetTrihedronSize();
-
-  void
-  SetTrihedronSize(const int theSize);
-
-  void 
-  AdjustActors();
-
-  bool
-  IsTrihedronDisplayed();
-  bool
-  IsCubeAxesDisplayed();
-
-  VTKViewer_Trihedron* 
-  GetTrihedron();
-
-  SVTK_CubeAxesActor2D*
-  GetCubeAxes();
-
-  //----------------------------------------------------------------------------
-  QToolBar* getToolBar();
-
- public slots:
-  void activateZoom();
-  void activateWindowFit();
-  void activateRotation();
-  void activatePanning(); 
-  void activateGlobalPanning(); 
-
-  void onFrontView(); 
-  void onBackView(); 
-  void onTopView();
-  void onBottomView();
-  void onRightView(); 
-  void onLeftView();     
-
-  void onResetView();     
-  void onFitAll();
-
-  void onViewTrihedron(); 
-  void onViewCubeAxes();
-
-  void onAdjustTrihedron();
-  void onAdjustCubeAxes();
-
-  void onDumpView();
-
- public:
-  QImage dumpView();
-
- protected:  
-  void
-  createActions(SUIT_ResourceMgr* theResourceMgr);
-
-  void
-  createToolBar();
-
-  void
-  SetEventDispatcher(vtkObject* theDispatcher);
-
-  enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
-         FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, ViewTrihedronId };
-  typedef QMap<int, QtxAction*> TActionsMap;
-
-  vtkSmartPointer<vtkObject> myEventDispatcher;
-  TActionsMap myActionsMap;  
-  QToolBar* myToolBar;
-
-  SVTK_RenderWindowInteractor* myInteractor;
-};
-
-
 //----------------------------------------------------------------------------
 class SVTK_EXPORT SVTK_SignalHandler : public QObject
 {
index 7fb8feb099af2f0d29354b12e97efb0beab87465..e569f82b60c2778d887b621cfaec8e4c1f9ffdce 100644 (file)
@@ -11,6 +11,7 @@
 #include "SVTK_ViewModel.h"
 #include "SVTK_ViewWindow.h"
 #include "SVTK_View.h"
+#include "SVTK_MainWindow.h"
 #include "SVTK_Prs.h"
 
 #include "VTKViewer_ViewModel.h"
index d37277477e82ab8e2ae8f661c2a5a14453ef5379..ffcde4b02e7760a3daafc567d9ded0a2d8cc1432 100755 (executable)
 #include "VTKViewer_Utilities.h"
 #include "VTKViewer_CellRectPicker.h"
 
+#include "SVTK_View.h"
+#include "SVTK_MainWindow.h"
+#include "SVTK_Selector.h"
+
 #include "SVTK_Event.h"
 #include "SVTK_Renderer.h"
 #include "SVTK_ViewWindow.h"
@@ -36,9 +40,6 @@
 
 #include "SALOME_ListIteratorOfListIO.hxx"
 
-#include "SVTK_Selector.h"
-#include "SVTK_View.h"
-
 #include "VTKViewer_Algorithm.h"
 #include "SVTK_Functor.h"