]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
SUIT improvement for CHARM project. The modifications are approved by Alexander Solovyov.
authornds <nds@opencascade.com>
Tue, 22 Jan 2013 12:09:25 +0000 (12:09 +0000)
committernds <nds@opencascade.com>
Tue, 22 Jan 2013 12:09:25 +0000 (12:09 +0000)
52 files changed:
SUIT.pro
src/OCCViewer/OCCViewer.h [new file with mode: 0755]
src/OCCViewer/OCCViewer.pro [new file with mode: 0644]
src/OCCViewer/OCCViewer_AISSelector.cxx [new file with mode: 0755]
src/OCCViewer/OCCViewer_AISSelector.h [new file with mode: 0755]
src/OCCViewer/OCCViewer_ClippingDlg.cxx [new file with mode: 0644]
src/OCCViewer/OCCViewer_ClippingDlg.h [new file with mode: 0644]
src/OCCViewer/OCCViewer_CreateRestoreViewDlg.cxx [new file with mode: 0755]
src/OCCViewer/OCCViewer_CreateRestoreViewDlg.h [new file with mode: 0755]
src/OCCViewer/OCCViewer_VService.cxx [new file with mode: 0755]
src/OCCViewer/OCCViewer_VService.h [new file with mode: 0755]
src/OCCViewer/OCCViewer_ViewManager.cxx [new file with mode: 0755]
src/OCCViewer/OCCViewer_ViewManager.h [new file with mode: 0755]
src/OCCViewer/OCCViewer_ViewModel.cxx [new file with mode: 0755]
src/OCCViewer/OCCViewer_ViewModel.h [new file with mode: 0755]
src/OCCViewer/OCCViewer_ViewPort.cxx [new file with mode: 0755]
src/OCCViewer/OCCViewer_ViewPort.h [new file with mode: 0755]
src/OCCViewer/OCCViewer_ViewPort3d.cxx [new file with mode: 0755]
src/OCCViewer/OCCViewer_ViewPort3d.h [new file with mode: 0755]
src/OCCViewer/OCCViewer_ViewWindow.cxx [new file with mode: 0755]
src/OCCViewer/OCCViewer_ViewWindow.h [new file with mode: 0755]
src/OCCViewer/resources/OCCViewer_images.po [new file with mode: 0755]
src/OCCViewer/resources/OCCViewer_images.ts [new file with mode: 0644]
src/OCCViewer/resources/OCCViewer_msg_en.po [new file with mode: 0755]
src/OCCViewer/resources/OCCViewer_msg_en.ts [new file with mode: 0644]
src/OCCViewer/resources/view_back.png [new file with mode: 0755]
src/OCCViewer/resources/view_bottom.png [new file with mode: 0755]
src/OCCViewer/resources/view_camera_dump.png [new file with mode: 0755]
src/OCCViewer/resources/view_clipping.png [new file with mode: 0644]
src/OCCViewer/resources/view_clipping_pressed.png [new file with mode: 0644]
src/OCCViewer/resources/view_clone.png [new file with mode: 0755]
src/OCCViewer/resources/view_fitall.png [new file with mode: 0755]
src/OCCViewer/resources/view_fitarea.png [new file with mode: 0755]
src/OCCViewer/resources/view_front.png [new file with mode: 0755]
src/OCCViewer/resources/view_glpan.png [new file with mode: 0755]
src/OCCViewer/resources/view_left.png [new file with mode: 0755]
src/OCCViewer/resources/view_pan.png [new file with mode: 0755]
src/OCCViewer/resources/view_presets.png [new file with mode: 0755]
src/OCCViewer/resources/view_reset.png [new file with mode: 0755]
src/OCCViewer/resources/view_right.png [new file with mode: 0755]
src/OCCViewer/resources/view_rotate.png [new file with mode: 0755]
src/OCCViewer/resources/view_shoot.png [new file with mode: 0755]
src/OCCViewer/resources/view_top.png [new file with mode: 0755]
src/OCCViewer/resources/view_triedre.png [new file with mode: 0755]
src/OCCViewer/resources/view_zoom.png [new file with mode: 0755]
src/Qtx/QtxDockWidget.cxx
src/Qtx/QtxDockWidget.h
src/Qtx/QtxTreeView.cxx
src/Qtx/QtxTreeView.h
src/SUIT/SUIT_Application.h
src/SUIT/SUIT_DataObject.h
src/SUIT/SUIT_TreeModel.cxx

index 4b55d8e1b794aa6dfb6467bd2c438f6a7023bb07..e98589372fab3a21dbc6aeb6d41b344be0617aec 100644 (file)
--- a/SUIT.pro
+++ b/SUIT.pro
@@ -31,7 +31,8 @@ SUBDIRS = src/Qtx \
          src/Prs \
          src/SVTK \
           src/STD \
-          src/CAM
+          src/CAM \
+          src/OCCViewer
 
 #--------------------------------------------------------------------------------------
 unix {
diff --git a/src/OCCViewer/OCCViewer.h b/src/OCCViewer/OCCViewer.h
new file mode 100755 (executable)
index 0000000..724486c
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifdef WNT
+#ifdef OCCVIEWER_EXPORTS
+#define OCCVIEWER_EXPORT __declspec(dllexport)
+#else
+#define OCCVIEWER_EXPORT __declspec(dllimport)
+#endif
+#else
+#define OCCVIEWER_EXPORT
+#endif
+
+#if defined WNT
+#pragma warning ( disable: 4251 )
+#endif
diff --git a/src/OCCViewer/OCCViewer.pro b/src/OCCViewer/OCCViewer.pro
new file mode 100644 (file)
index 0000000..750a693
--- /dev/null
@@ -0,0 +1,24 @@
+unix:TEMPLATE = lib
+win32:TEMPLATE = vclib
+
+include(../Common.pro)
+
+CAS_CPPFLAGS = $(CASINC)
+
+CAS_KERNEL = -L$(CASLIB) -lTKernel
+
+CAS_VIEWER = -L$(CASLIB) -lTKV3d -lTKService
+
+
+INCLUDEPATH += $${CAS_CPPFLAGS}
+LIBS += 
+LIBS += $${CAS_KERNEL} $${CAS_VIEWER}
+
+LIBS *= -lSUIT -lQtx -lTKMath -lTKG3d -lTKGeomBase
+
+win32:DEFINES += WNT WIN32
+DEFINES += OCCVIEWER_EXPORTS DISABLE_TESTRECORDER
+DEFINES += HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS
+
+include(../Translations.pro)
+include(../Resources.pro)
diff --git a/src/OCCViewer/OCCViewer_AISSelector.cxx b/src/OCCViewer/OCCViewer_AISSelector.cxx
new file mode 100755 (executable)
index 0000000..43dca45
--- /dev/null
@@ -0,0 +1,223 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "OCCViewer_AISSelector.h"
+
+/*!
+  Constructor
+*/
+OCCViewer_AISSelector::OCCViewer_AISSelector( QObject* parent, 
+                                             const Handle (AIS_InteractiveContext)& aisContext) :
+  QObject( parent ), 
+  myNumSelected( 0 ), 
+  myEnableSelection( true ),
+  myEnableMultipleSelection( true )
+{
+  myHilightColor = Quantity_NOC_CYAN1;
+  mySelectColor  = Quantity_NOC_GRAY80;
+
+  setAISContext( aisContext );
+}
+
+/*!
+  Destructor
+*/
+OCCViewer_AISSelector::~OCCViewer_AISSelector()
+{
+}
+
+/*!
+  Enables/disables selection
+*/
+void OCCViewer_AISSelector::enableSelection( bool bEnable )
+{
+  myEnableSelection = bEnable;
+}
+
+/*!
+  Enables/disables multiple selection i.e
+  selection of several objects at the same time.
+*/
+void OCCViewer_AISSelector::enableMultipleSelection( bool bEnable )
+{
+  myEnableMultipleSelection = bEnable;
+  if ( bEnable ) myEnableSelection = bEnable;
+}
+
+/*!
+  Sets the color to hilight the detected objects
+*/
+void OCCViewer_AISSelector::setHilightColor ( Quantity_NameOfColor color )
+{
+  myHilightColor = color;
+  if ( !myAISContext.IsNull() )
+    myAISContext->SetHilightColor( myHilightColor );
+}
+
+/*!
+  Sets the color to display the selected objects
+*/
+void OCCViewer_AISSelector::setSelectColor ( Quantity_NameOfColor color )
+{
+  mySelectColor = color;
+  if ( !myAISContext.IsNull() )
+    myAISContext->SelectionColor( mySelectColor );
+}
+
+/*!
+  Sets the interactive context for this selector
+*/
+void OCCViewer_AISSelector::setAISContext ( const Handle (AIS_InteractiveContext)& aisContext )
+{
+  myAISContext = aisContext;
+  if ( ! myAISContext.IsNull() ) { 
+    myAISContext->SetHilightColor( myHilightColor );
+    myAISContext->SelectionColor( mySelectColor );
+    myAISContext->SetSubIntensityColor( Quantity_NOC_CYAN1 );
+  }
+}
+
+/*!
+  Checks the status of pick and emits 'selSelectionDone' or
+  'selSelectionCancel'.
+  Returns 'true' if no error, 'false' otherwise.
+*/
+bool OCCViewer_AISSelector::checkSelection ( AIS_StatusOfPick status, 
+                                             bool hadSelection, 
+                                             bool addTo )
+{
+  if ( myAISContext.IsNull() )
+    return false;
+
+  myNumSelected = myAISContext->NbCurrents(); /* update after the last selection */
+  
+  if ( status == AIS_SOP_NothingSelected && !hadSelection ) {
+    emit selSelectionCancel( addTo );
+  }
+  else if ( status == AIS_SOP_NothingSelected && hadSelection ) {
+    emit selSelectionCancel( addTo ); /* unselected now */
+  }
+  else if ( status == AIS_SOP_OneSelected || status == AIS_SOP_SeveralSelected )
+  {
+    emit selSelectionDone( addTo ); /* selected ( the same object, may be ) */
+  }
+  return ( status != AIS_SOP_Error && status != AIS_SOP_NothingSelected );
+}
+
+/*!
+  Detects the interactive objects at position (x,y).
+  Returns 'true' if no error, 'false' otherwise.
+*/
+bool OCCViewer_AISSelector::moveTo ( int x, int y, const Handle (V3d_View)& view )
+{
+  if ( myAISContext.IsNull() )
+    return false;
+
+  if ( !myEnableSelection )
+    return false;
+  
+  AIS_StatusOfDetection status = AIS_SOD_Error;
+  status = myAISContext->MoveTo (x, y, view);
+  
+  return ( status != AIS_SOD_Error && status != AIS_SOD_AllBad );
+}
+
+/*!
+  Selects the detected interactive objects.
+  Calls checkSelection() for checking the status.
+*/
+bool OCCViewer_AISSelector::select ()
+{
+  if ( myAISContext.IsNull() )
+    return false;
+
+  if ( !myEnableSelection )
+    return false;
+  
+  bool hadSelection = ( myNumSelected > 0 );
+  
+  /* select and send notifications */
+  return checkSelection ( myAISContext->Select(), hadSelection, false );
+}
+
+/*!
+  Selects the objects covered by the rectangle.
+  Multiple selection must be enabled to get use of this function.
+  Calls checkSelection() for checking the status.
+*/
+bool OCCViewer_AISSelector::select ( int left, int top, int right, int bottom,
+                                     const Handle (V3d_View)& view )
+{
+  if ( myAISContext.IsNull() )
+    return false;
+
+  if ( !myEnableSelection || !myEnableMultipleSelection )
+    return false;  /* selection with rectangle is considered as multiple selection */
+  
+  bool hadSelection = ( myNumSelected > 0 );
+  
+  /* select and send notifications */
+  return checkSelection ( myAISContext->Select(left, top, right, bottom, view),
+                          hadSelection, false );
+}
+
+/*!
+  Adds new selected objects to the objects previously selected.
+  Multiple selection must be enabled to get use of this function.
+  Calls checkSelection() for checking the status.
+*/
+bool OCCViewer_AISSelector::shiftSelect ()
+{
+  if ( myAISContext.IsNull() )
+    return false;
+
+  if ( !myEnableSelection )
+    return false;
+  
+  bool hadSelection = ( myNumSelected > 0 ); /* something was selected */
+  if ( hadSelection && !myEnableMultipleSelection)
+    return false;
+  
+  /* select and send notifications */
+  return checkSelection ( myAISContext->ShiftSelect(), hadSelection, true );
+}
+
+/*!
+  Adds new selected objects covered by the rectangle to the objects
+  previously selected.
+  Multiple selection must be enabled to get use of this function.
+  Calls checkSelection() for checking the status.
+*/
+bool OCCViewer_AISSelector::shiftSelect ( int left, int top, int right, int bottom,
+                                         const Handle (V3d_View)& view )
+                                         
+{
+  if ( myAISContext.IsNull() )
+    return false;
+
+  if ( !myEnableSelection || !myEnableMultipleSelection )
+    return false;  /* selection with rectangle is considered as multiple selection */
+  
+  bool hadSelection = ( myNumSelected > 0 );      /* something was selected */
+  if ( hadSelection && !myEnableMultipleSelection)
+    return false;
+  
+  /* select and send notifications */
+  return checkSelection ( myAISContext->ShiftSelect(left,top,right,bottom, view),
+    hadSelection, true );
+}
diff --git a/src/OCCViewer/OCCViewer_AISSelector.h b/src/OCCViewer/OCCViewer_AISSelector.h
new file mode 100755 (executable)
index 0000000..740c8f0
--- /dev/null
@@ -0,0 +1,82 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#if !defined( OCCVIEWER_AISSELECTOR_H )
+#define OCCVIEWER_AISSELECTOR_H
+
+#include "OCCViewer.h"
+#include <qobject.h>
+
+#include <Quantity_NameOfColor.hxx>
+#include <AIS_InteractiveContext.hxx>
+
+class OCCVIEWER_EXPORT OCCViewer_AISSelector : public QObject
+{
+  Q_OBJECT
+    
+public:
+  // constructor
+  OCCViewer_AISSelector( QObject* parent, const Handle (AIS_InteractiveContext)& );
+  // destructor
+  ~OCCViewer_AISSelector();
+  
+  // enables/disables selection
+  void enableSelection( bool );
+  // enables/disables multiple selection
+  void enableMultipleSelection( bool );
+  
+  // detects the interactive objects at position (x,y).
+  bool moveTo ( int, int, const Handle (V3d_View)& );
+  // selects the objects covered by the rectangle.
+  bool select ( int, int, int, int, const Handle (V3d_View)& );
+  // adds new selected objects covered by the rectangle to the objects
+  // previously selected.
+  bool shiftSelect ( int, int, int, int, const Handle (V3d_View)& );
+  // selects the detected interactive objects.
+  bool select ();
+  // adds new selected objects to the objects previously selected.
+  bool shiftSelect ();
+  
+  // sets the interactive context for this selector
+  void setAISContext ( const Handle (AIS_InteractiveContext)& );
+  // sets the color to hilight the detected objects
+  void setHilightColor ( Quantity_NameOfColor color );
+  // sets the color to display the selected objects
+  void setSelectColor ( Quantity_NameOfColor color );
+  
+protected:
+  // checks the status of pick and emits 'selSelectionDone' or 'selSelectionCancel'.
+  bool checkSelection ( AIS_StatusOfPick status, bool hadSelection, bool addTo );
+  
+signals:
+  // 'selection done' signal
+  void selSelectionDone( bool bAdded );
+  // 'selection cancelled' signal
+  void selSelectionCancel( bool bAdded );
+  
+protected:
+  Handle (AIS_InteractiveContext) myAISContext;    // graphic context
+  Quantity_NameOfColor            myHilightColor;  // color for hilight object
+  Quantity_NameOfColor            mySelectColor;   // color for selected object
+  
+  int  myNumSelected;                              // nymber of selected objects
+  bool myEnableSelection;                          // enable selection flag
+  bool myEnableMultipleSelection;                  // enable multiple selection flag
+};
+
+#endif // OCCVIEWER_AISSELECTOR_H
diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.cxx b/src/OCCViewer/OCCViewer_ClippingDlg.cxx
new file mode 100644 (file)
index 0000000..35c9e1e
--- /dev/null
@@ -0,0 +1,563 @@
+// Copyright (C) 2005  CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "OCCViewer_ClippingDlg.h"
+
+#include <QtxDoubleSpinBox.h>
+#include <QtxAction.h>
+
+#include "SUIT_Session.h"
+#include "SUIT_ViewWindow.h"
+#include "SUIT_ViewManager.h"
+#include "OCCViewer_ViewWindow.h"
+#include "OCCViewer_ViewPort3d.h"
+
+#include <V3d_View.hxx>
+//#include <V3d.hxx>
+#include <Geom_Plane.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <IntAna_IntConicQuad.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pln.hxx>
+
+// QT Includes
+#include <Qt>
+#include <QApplication>
+#include <QGroupBox>
+#include <QLayout>
+#include <QLabel>
+#include <QPushButton>
+#include <QComboBox>
+#include <QCheckBox>
+
+/*!
+  Constructor
+  \param view - view window
+  \param parent - parent widget
+  \param name - dialog name
+  \param modal - is this dialog modal
+  \param fl - flags
+*/
+OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl )
+: QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
+  myView( view )
+{
+  setObjectName( "OCCViewer_ClippingDlg" );
+  setModal( modal );
+  setWindowTitle( tr( "Clipping" ) );
+  
+  QVBoxLayout* topLayout = new QVBoxLayout( this );
+  topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );
+  
+  /***************************************************************/
+  GroupPoint = new QGroupBox( "GroupPoint", this );
+  GroupPoint->setTitle( tr("Base point") );
+  GroupPoint->layout()->setSpacing( 0 );
+  GroupPoint->layout()->setMargin( 0 );
+  QGridLayout* GroupPointLayout = new QGridLayout( GroupPoint );
+  GroupPointLayout->setAlignment( Qt::AlignTop );
+  GroupPointLayout->setSpacing( 6 );
+  GroupPointLayout->setMargin( 11 );
+  
+  // Controls
+  const double min = -1e+16;
+  const double max =  1e+16;
+  const double step = 5;
+  const int precision = -6; // PAL12789. Minus is for using 'g' double->string conversion specifier,
+  //                          see QtxDoubleSpinBox::mapValueToText( double v )
+
+  TextLabelX = new QLabel( "TextLabelX", GroupPoint );
+  TextLabelX->setText( tr("X:") );
+  GroupPointLayout->addWidget( TextLabelX, 0, 0 );
+  
+  SpinBox_X = new QtxDoubleSpinBox( min, max, step, GroupPoint );
+  SpinBox_X->setPrecision( precision );
+  GroupPointLayout->addWidget( SpinBox_X, 0, 1 );
+
+  TextLabelY = new QLabel( "TextLabelY", GroupPoint );
+  TextLabelY->setText( tr("Y:") );
+  GroupPointLayout->addWidget( TextLabelY, 0, 2 );
+
+  SpinBox_Y = new QtxDoubleSpinBox( min, max, step, GroupPoint );
+  SpinBox_Y->setPrecision( precision );
+  GroupPointLayout->addWidget( SpinBox_Y, 0, 3 );
+
+  TextLabelZ = new QLabel( "TextLabelZ", GroupPoint );
+  TextLabelZ->setText( tr("Z:") );
+  GroupPointLayout->addWidget( TextLabelZ, 0, 4 );
+
+  SpinBox_Z = new QtxDoubleSpinBox( min, max, step, GroupPoint );
+  SpinBox_Z->setPrecision( precision );
+  GroupPointLayout->addWidget( SpinBox_Z, 0, 5 );
+
+  resetButton  = new QPushButton( "resetButton", GroupPoint );
+  resetButton->setText( tr( "Reset"  ) );
+  GroupPointLayout->addWidget( resetButton, 0, 6 );
+
+  /***************************************************************/
+  GroupDirection = new QGroupBox( "GroupDirection", this );
+  GroupDirection->setTitle( tr("Direction") );
+  GroupDirection->layout()->setSpacing( 0 );
+  GroupDirection->layout()->setMargin( 0 );
+  QGridLayout* GroupDirectionLayout = new QGridLayout( GroupDirection );
+  GroupDirectionLayout->setAlignment( Qt::AlignTop );
+  GroupDirectionLayout->setSpacing( 6 );
+  GroupDirectionLayout->setMargin( 11 );
+  
+  // Controls
+  TextLabelDx = new QLabel( "TextLabelDx", GroupDirection );
+  TextLabelDx->setText( tr("Dx:") );
+  GroupDirectionLayout->addWidget( TextLabelDx, 0, 0 );
+  
+  SpinBox_Dx = new QtxDoubleSpinBox( min, max, step, GroupDirection );
+  SpinBox_Dx->setPrecision( precision );
+  GroupDirectionLayout->addWidget( SpinBox_Dx, 0, 1 );
+
+  TextLabelDy = new QLabel( "TextLabelDy", GroupDirection );
+  TextLabelDy->setText( tr("Dy:") );
+  GroupDirectionLayout->addWidget( TextLabelDy, 0, 2 );
+  
+  SpinBox_Dy = new QtxDoubleSpinBox( min, max, step, GroupDirection );
+  SpinBox_Dy->setPrecision( precision );
+  GroupDirectionLayout->addWidget( SpinBox_Dy, 0, 3 );
+
+  TextLabelDz = new QLabel( "TextLabelDz", GroupDirection );
+  TextLabelDz->setText( tr("Dz:") );
+  GroupDirectionLayout->addWidget( TextLabelDz, 0, 4 );
+  
+  SpinBox_Dz = new QtxDoubleSpinBox( min, max, step, GroupDirection );
+  SpinBox_Dz->setPrecision( precision );
+  GroupDirectionLayout->addWidget( SpinBox_Dz, 0, 5 );
+
+  invertButton  = new QPushButton( "invertButton", GroupDirection );
+  invertButton->setText( tr( "Invert"  ) );
+  GroupDirectionLayout->addWidget( invertButton, 0, 6 );
+  DirectionCB = new QComboBox( GroupDirection );
+  DirectionCB->addItem(tr("CUSTOM"));
+  DirectionCB->addItem(tr("||X-Y"));
+  DirectionCB->addItem(tr("||Y-Z"));
+  DirectionCB->addItem(tr("||Z-X"));
+  GroupDirectionLayout->addWidget( DirectionCB, 1, 0, 1, 6 );
+  
+  /***************************************************************/
+  
+  PreviewChB = new QCheckBox( tr("Preview"), this );
+  PreviewChB->setChecked( true );
+  
+  /***************************************************************/
+  QGroupBox* GroupButtons = new QGroupBox( "GroupButtons", this );
+  GroupButtons->layout()->setMargin( 0 );
+  GroupButtons->layout()->setSpacing( 0 ); 
+  QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
+  GroupButtonsLayout->setAlignment( Qt::AlignTop );
+  GroupButtonsLayout->setMargin( 11 ); GroupButtonsLayout->setSpacing( 6 );
+  
+  buttonApply = new QPushButton( "buttonApply", GroupButtons );
+  buttonApply->setText( tr( "BUT_APPLY"  ) );
+  buttonApply->setAutoDefault( TRUE ); 
+  buttonApply->setDefault( TRUE );
+  GroupButtonsLayout->addWidget( buttonApply );
+  
+  GroupButtonsLayout->addStretch();
+  
+  buttonClose = new QPushButton( "buttonClose", GroupButtons );
+  buttonClose->setText( tr( "BUT_CLOSE"  ) );
+  buttonClose->setAutoDefault( TRUE );
+  GroupButtonsLayout->addWidget( buttonClose );
+  /***************************************************************/
+  
+  topLayout->addWidget( GroupPoint );
+  topLayout->addWidget( GroupDirection );
+  
+  topLayout->addWidget( PreviewChB );
+
+  topLayout->addWidget( GroupButtons );
+
+  /* initializations */
+
+  SpinBox_X->setValue( 0.0 );
+  SpinBox_Y->setValue( 0.0 );
+  SpinBox_Z->setValue( 0.0 );
+
+  SpinBox_Dx->setValue( 1.0 );
+  SpinBox_Dy->setValue( 1.0 );
+  SpinBox_Dz->setValue( 1.0 );
+
+  /* signals and slots connections */
+  connect( resetButton,  SIGNAL (clicked() ), this, SLOT( onReset() ) );
+  connect( invertButton, SIGNAL (clicked() ), this, SLOT( onInvert() ) ) ;
+
+  connect( SpinBox_X,  SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );
+  connect( SpinBox_Y,  SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );
+  connect( SpinBox_Z,  SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );
+  connect( SpinBox_Dx, SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );
+  connect( SpinBox_Dy, SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );
+  connect( SpinBox_Dz, SIGNAL ( valueChanged( double ) ),  this, SLOT( onValueChanged() ) );
+   
+  connect( DirectionCB, SIGNAL ( activated ( int ) ), this, SLOT( onModeChanged( int ) ) ) ;
+
+  connect( PreviewChB, SIGNAL ( toggled ( bool ) ), this, SLOT( onPreview( bool ) ) ) ;
+  
+  connect( buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnClose() ) ) ;
+  connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+  
+  myBusy = false;
+}
+
+/*!
+  Destructor
+  Destroys the object and frees any allocated resources
+*/
+OCCViewer_ClippingDlg::~ OCCViewer_ClippingDlg()
+{
+  // no need to delete child widgets, Qt does it all for us
+}
+
+
+/*!
+  Custom handling of close event: erases preview
+*/
+void OCCViewer_ClippingDlg::closeEvent( QCloseEvent* e )
+{
+  erasePreview();
+  
+  // Set the clipping plane back
+  Handle(V3d_View) aView3d = myView->getViewPort()->getView();
+  if ( !aView3d.IsNull() && !myClippingPlane.IsNull() )
+    aView3d->SetPlaneOn( myClippingPlane );
+  
+  if (!myView->isCuttingPlane())
+    myAction->setChecked( false );
+  
+  QDialog::closeEvent( e );
+}
+
+
+/*!
+  Custom handling of show event: displays preview
+*/
+void OCCViewer_ClippingDlg::showEvent( QShowEvent* e )
+{
+  ReserveClippingPlane();
+  
+  QDialog::showEvent( e );
+  onPreview( PreviewChB->isChecked() );
+}
+
+
+/*!
+  Custom handling of hide event: erases preview
+*/
+void OCCViewer_ClippingDlg::hideEvent( QHideEvent* e )
+{
+  erasePreview();
+  QDialog::hideEvent( e );
+}
+
+
+/*!
+  SLOT on close button click: erases preview and rejects dialog
+*/
+void OCCViewer_ClippingDlg::ClickOnClose()
+{
+  erasePreview();
+
+  // Set the clipping plane back
+  Handle(V3d_View) aView3d = myView->getViewPort()->getView();
+  if ( !aView3d.IsNull() && !myClippingPlane.IsNull() )
+    aView3d->SetPlaneOn( myClippingPlane );
+
+  if (!myView->isCuttingPlane())
+    myAction->setChecked( false );
+  
+  reject();
+}
+
+
+/*!
+  SLOT on apply button click: sets cutting plane
+*/
+void OCCViewer_ClippingDlg::ClickOnApply()
+{
+  qApp->processEvents();
+  QApplication::setOverrideCursor( Qt::WaitCursor );
+  qApp->processEvents();
+  
+  myView->setCuttingPlane( true, SpinBox_X->value() , SpinBox_Y->value() , SpinBox_Z->value(),
+                                SpinBox_Dx->value(), SpinBox_Dy->value(), SpinBox_Dz->value() );
+  
+  QApplication::restoreOverrideCursor(); 
+  
+  erasePreview();
+  
+  ReserveClippingPlane();
+}
+
+/*!
+  SLOT on reset button click: sets default values
+*/
+void OCCViewer_ClippingDlg::onReset()
+{
+  myBusy = true;
+  SpinBox_X->setValue(0);
+  SpinBox_Y->setValue(0);
+  SpinBox_Z->setValue(0);
+  myBusy = false;
+
+  if ( PreviewChB->isChecked() )
+    {
+      erasePreview();
+      displayPreview();
+    }
+}
+
+/*!
+  SLOT on invert button click: inverts normal of cutting plane
+*/
+void OCCViewer_ClippingDlg::onInvert()
+{
+  double Dx = SpinBox_Dx->value();
+  double Dy = SpinBox_Dy->value();
+  double Dz = SpinBox_Dz->value();
+  
+  myBusy = true;
+  SpinBox_Dx->setValue( -Dx );
+  SpinBox_Dy->setValue( -Dy );
+  SpinBox_Dz->setValue( -Dz );
+  myBusy = false;
+
+  if ( PreviewChB->isChecked() )
+    {
+      erasePreview();
+      displayPreview();
+    }
+}
+
+/*!
+  SLOT: called on mode changed
+*/
+void OCCViewer_ClippingDlg::onModeChanged( int mode )
+{
+  bool isUserMode = (mode==0);
+  
+  TextLabelX->setEnabled( isUserMode );
+  TextLabelY->setEnabled( isUserMode );
+  TextLabelZ->setEnabled( isUserMode );
+
+  SpinBox_X->setEnabled( isUserMode );
+  SpinBox_Y->setEnabled( isUserMode );
+  SpinBox_Z->setEnabled( isUserMode );
+
+  TextLabelDx->setEnabled( isUserMode );
+  TextLabelDy->setEnabled( isUserMode );
+  TextLabelDz->setEnabled( isUserMode );
+
+  SpinBox_Dx->setEnabled( isUserMode );
+  SpinBox_Dy->setEnabled( isUserMode );
+  SpinBox_Dz->setEnabled( isUserMode );
+  
+  if ( isUserMode )
+    return;
+
+  double aDx = 0, aDy = 0, aDz = 0;
+
+  if ( mode == 1 )
+    {
+      aDz = 1;
+      TextLabelZ->setEnabled( true );
+      SpinBox_Z->setEnabled( true );
+      SpinBox_Z->setFocus();
+    }
+  else if ( mode == 2 )
+    {
+      aDx = 1;
+      TextLabelX->setEnabled( true );
+      SpinBox_X->setEnabled( true );
+      SpinBox_X->setFocus();
+    }
+  else if ( mode == 3 )
+    {
+      aDy = 1;
+      TextLabelY->setEnabled( true );
+      SpinBox_Y->setEnabled( true );
+      SpinBox_Y->setFocus();
+    }
+  
+  myBusy = true;
+  SpinBox_Dx->setValue( aDx );
+  SpinBox_Dy->setValue( aDy );
+  SpinBox_Dz->setValue( aDz );
+  myBusy = false;
+
+  if ( PreviewChB->isChecked() )
+    {
+      erasePreview();
+      displayPreview();
+    }
+}
+
+
+/*!
+  Displays preview of clipping plane
+*/
+void OCCViewer_ClippingDlg::displayPreview()
+{
+  if ( myBusy || !isValid() )
+    return;
+
+  OCCViewer_Viewer* anOCCViewer = (OCCViewer_Viewer*)myView->getViewManager()->getViewModel();
+  if (!anOCCViewer)
+    return;
+  
+  Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext();
+
+  double aXMin, aYMin, aZMin, aXMax, aYMax, aZMax;
+  aXMin = aYMin = aZMin = DBL_MAX;
+  aXMax = aYMax = aZMax = -DBL_MAX;
+
+  bool isFound = false;
+  AIS_ListOfInteractive aList;
+  ic->DisplayedObjects( aList );
+  for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() )
+  {
+    Handle(AIS_InteractiveObject) anObj = it.Value();
+    if ( !anObj.IsNull() && anObj->HasPresentation() &&
+         !anObj->IsKind( STANDARD_TYPE(AIS_Plane) ) )
+    {
+      Handle(Prs3d_Presentation) aPrs = anObj->Presentation();
+      if ( !aPrs->IsEmpty() && !aPrs->IsInfinite() )
+      {
+        isFound = true;
+        double xmin, ymin, zmin, xmax, ymax, zmax;
+        aPrs->MinMaxValues( xmin, ymin, zmin, xmax, ymax, zmax );
+        aXMin = qMin( aXMin, xmin );  aXMax = qMax( aXMax, xmax );
+        aYMin = qMin( aYMin, ymin );  aYMax = qMax( aYMax, ymax );
+        aZMin = qMin( aZMin, zmin );  aZMax = qMax( aZMax, zmax );
+      }
+    }
+  }
+
+  double aSize = 50;
+  
+  gp_Pnt aBasePnt( SpinBox_X->value(),  SpinBox_Y->value(),  SpinBox_Z->value() );
+  gp_Dir aNormal( SpinBox_Dx->value(), SpinBox_Dy->value(), SpinBox_Dz->value() );
+  gp_Pnt aCenter = aBasePnt;
+  
+  if ( isFound )
+    {
+      // compute clipping plane size
+      aCenter = gp_Pnt( ( aXMin + aXMax ) / 2, ( aYMin + aYMax ) / 2, ( aZMin + aZMax ) / 2 );
+      double aDiag = aCenter.Distance(gp_Pnt(aXMax, aYMax, aZMax ))*2;
+      aSize = aDiag * 1.1;
+
+      // compute clipping plane center ( redefine the base point )
+      IntAna_IntConicQuad intersector = IntAna_IntConicQuad();
+      
+      intersector.Perform( gp_Lin( aCenter, aNormal), gp_Pln( aBasePnt, aNormal), Precision::Confusion() );
+      if ( intersector.IsDone() && intersector.NbPoints() == 1 )
+       aBasePnt = intersector.Point( 1 );
+    }
+  
+  myPreviewPlane = new AIS_Plane( new Geom_Plane( aBasePnt, aNormal ) );
+  myPreviewPlane->SetSize( aSize, aSize );
+  
+  // Deactivate clipping planes
+  myView->getViewPort()->getView()->SetPlaneOff();
+
+  ic->Display( myPreviewPlane, 1, -1, false );
+  ic->SetWidth( myPreviewPlane, 10, false );
+  ic->SetMaterial( myPreviewPlane, Graphic3d_NOM_PLASTIC, false );
+  ic->SetTransparency( myPreviewPlane, 0.5, false );
+  ic->SetColor( myPreviewPlane, Quantity_Color( 85 / 255., 85 / 255., 255 / 255., Quantity_TOC_RGB ), false );
+  
+  anOCCViewer->update();
+}
+
+
+/*!
+  Erases preview of clipping plane
+*/
+void OCCViewer_ClippingDlg::erasePreview ()
+{
+  OCCViewer_Viewer* anOCCViewer = (OCCViewer_Viewer*)myView->getViewManager()->getViewModel();
+  if (!anOCCViewer)
+    return;
+  
+  Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext();
+  
+  if ( !myPreviewPlane.IsNull() && ic->IsDisplayed( myPreviewPlane ) )
+    {
+      ic->Erase( myPreviewPlane, false, false );
+      ic->Remove( myPreviewPlane, false );
+      myPreviewPlane.Nullify();
+    }
+  
+  anOCCViewer->update();
+}
+
+
+/*!
+  SLOT: called on value changes (co-ordinates of point or normal)
+*/
+void OCCViewer_ClippingDlg::onValueChanged()
+{
+  if ( PreviewChB->isChecked() )
+    {
+      erasePreview();
+      displayPreview();
+    }
+}
+
+
+/*!
+  SLOT: called on preview check box toggled
+*/
+void OCCViewer_ClippingDlg::onPreview( bool on )
+{
+  erasePreview();
+
+  if ( on ) 
+    displayPreview();
+}
+
+/*!
+  \return true if plane parameters are valid
+*/
+bool OCCViewer_ClippingDlg::isValid()
+{
+  return ( SpinBox_Dx->value()!=0 || SpinBox_Dy->value()!=0 || SpinBox_Dz->value()!=0 );
+}
+
+/*!
+  Remember the current clipping plane
+*/
+void OCCViewer_ClippingDlg::ReserveClippingPlane()
+{
+  Handle(V3d_View) aView3d = myView->getViewPort()->getView();
+  if ( !aView3d.IsNull() )
+    {
+      aView3d->InitActivePlanes();
+      if ( aView3d->MoreActivePlanes() )
+       myClippingPlane = aView3d->ActivePlane();
+    }
+}
diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.h b/src/OCCViewer/OCCViewer_ClippingDlg.h
new file mode 100644 (file)
index 0000000..63b9845
--- /dev/null
@@ -0,0 +1,110 @@
+// Copyright (C) 2005  CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef OCCVIEWER_CLIPPINGDLG_H
+#define OCCVIEWER_CLIPPINGDLG_H
+
+#include "OCCViewer.h"
+
+#include <qdialog.h>
+
+#include <AIS_Plane.hxx>
+#include <V3d_Plane.hxx>
+
+class QGroupBox;
+class QLabel;
+class QPushButton;
+class QComboBox;
+class QCheckBox;
+class QtxDoubleSpinBox;
+class QtxAction;
+
+class OCCViewer_ViewWindow;
+
+
+/*!
+  \class OCCViewer_ClippingDlg
+  \brief Dialog allowing to assign parameters of clipping plane
+*/
+class OCCViewer_ClippingDlg : public QDialog
+{
+    Q_OBJECT
+    
+    public:
+    OCCViewer_ClippingDlg(OCCViewer_ViewWindow* , QWidget* parent = 0, const char* name = 0, bool modal = FALSE, Qt::WindowFlags fl = 0);
+    ~OCCViewer_ClippingDlg();
+
+    void SetAction( QtxAction* theAction ) { myAction = theAction; }
+    
+private :
+
+    virtual void closeEvent( QCloseEvent* e );
+    virtual void showEvent ( QShowEvent * );
+    virtual void hideEvent ( QHideEvent * );
+    void displayPreview();
+    void erasePreview();
+    void ReserveClippingPlane();
+
+    bool isValid();
+     
+    QGroupBox* GroupPoint;
+    QLabel* TextLabelX;
+    QLabel* TextLabelY;
+    QLabel* TextLabelZ;
+    QtxDoubleSpinBox* SpinBox_X;
+    QtxDoubleSpinBox* SpinBox_Y;
+    QtxDoubleSpinBox* SpinBox_Z;
+    QPushButton* resetButton;
+    
+    QGroupBox* GroupDirection;
+    QLabel* TextLabelDx;
+    QLabel* TextLabelDy;
+    QLabel* TextLabelDz;
+    QtxDoubleSpinBox* SpinBox_Dx;
+    QtxDoubleSpinBox* SpinBox_Dy;
+    QtxDoubleSpinBox* SpinBox_Dz;
+    QPushButton* invertButton;
+    
+    QComboBox* DirectionCB;
+
+    QCheckBox* PreviewChB;
+
+    QPushButton*    buttonApply;
+    QPushButton*    buttonClose;
+    
+    OCCViewer_ViewWindow* myView;
+
+    Handle(AIS_Plane) myPreviewPlane;
+    Handle(V3d_Plane) myClippingPlane;
+    
+    bool myBusy;
+
+    QtxAction* myAction;
+    
+private slots:
+  void ClickOnApply();
+  void ClickOnClose();
+
+  void onReset();
+  void onInvert();
+  void onModeChanged( int mode );
+  void onValueChanged();
+  void onPreview( bool on );
+};
+
+#endif // OCCVIEWER_CLIPPINGDLG_H
diff --git a/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.cxx b/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.cxx
new file mode 100755 (executable)
index 0000000..a9b38a5
--- /dev/null
@@ -0,0 +1,284 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "OCCViewer_CreateRestoreViewDlg.h"
+#include "OCCViewer_ViewModel.h"
+#include "OCCViewer_ViewPort3d.h"
+
+#include <QKeyEvent>
+#include <QPushButton>
+#include <QLayout>
+#include <QListWidget>
+
+/*!
+  Constructor
+*/
+OCCViewer_CreateRestoreViewDlg::OCCViewer_CreateRestoreViewDlg( QWidget* aWin, OCCViewer_Viewer* curModel )
+: QDialog( aWin )
+{
+  setWindowTitle( tr( "CAPTION" ) );
+
+  myParametersMap = curModel->getViewAspects();
+
+  myKeyFlag = 0;
+
+  int aQuantityOfItems = myParametersMap.count();
+       
+  setFixedSize( 400, 300 );
+
+  QGridLayout* aGrid = new QGridLayout( this ); 
+  aGrid->setMargin( 5 );
+  aGrid->setSpacing( 10 );
+
+  QWidget* aWidget1 = new QWidget( this );
+  QWidget* aWidget2 = new QWidget( this );
+       
+  QHBoxLayout* aLayout = new QHBoxLayout( aWidget1 );
+       
+  myListBox = new QListWidget( aWidget1 );
+  myListBox->installEventFilter( this );
+
+  myCurViewPort = new OCCViewer_ViewPort3d( aWidget1, curModel->getViewer3d(), V3d_ORTHOGRAPHIC );
+  myCurViewPort->getView()->SetBackgroundColor( Quantity_NOC_BLACK );
+
+  //myListBox->setEditEnabled( 1 );
+  myListBox->setEditTriggers( QListWidget::AllEditTriggers );
+       
+  if ( aQuantityOfItems )
+  {
+    myListBox->clear();
+    for( int i = 0; i < aQuantityOfItems; i++ )
+      myListBox->addItem( myParametersMap[ i ].name );
+    
+    changeImage( myListBox->item( 0 ) );
+  }
+  else
+  {
+    myListBox->clear();
+    myListBox->insertItem( 0, "No Items" );
+    //myListBox->setEditEnabled( 0 );
+    myListBox->setEditTriggers( QListWidget::NoEditTriggers );
+  }
+
+  connect( myListBox, SIGNAL( clicked( QListBoxItem* ) ), this, SLOT( changeImage( QListBoxItem* ) ) );
+  connect( myListBox, SIGNAL( itemEdited( QListBoxItem* ) ), this, SLOT( editItemText( QListBoxItem* ) ) );
+       
+  aLayout->addWidget( myListBox );
+  aLayout->addWidget( myCurViewPort, 30 );
+
+  QHBoxLayout* aButtonLayout = new QHBoxLayout( aWidget2 );
+  aButtonLayout->setMargin( 0 );
+  aButtonLayout->setSpacing( 5 );
+
+  QPushButton* theOk     = new QPushButton( tr( "Ok" ), aWidget2 );            theOk->setAutoDefault( false );
+  QPushButton* theCancel = new QPushButton( tr( "Cancel" ), aWidget2 );                 theCancel->setAutoDefault( false );
+  QPushButton* theDelete = new QPushButton( tr( "Delete" ), aWidget2 );                 theDelete->setAutoDefault( false );
+  QPushButton* theClearAll = new QPushButton( tr( "Clear List" ), aWidget2 );  theClearAll->setAutoDefault( false );
+
+  aButtonLayout->addWidget( theOk );
+  aButtonLayout->addWidget( theCancel );
+  aButtonLayout->addWidget( theDelete );
+  aButtonLayout->addWidget( theClearAll );
+
+  aGrid->addWidget( aWidget1, 0, 0 );
+  aGrid->addWidget( aWidget2, 1, 0 );
+       
+  connect( theOk, SIGNAL( clicked() ), this, SLOT( OKpressed() ) );
+  connect( theCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+  connect( theDelete, SIGNAL( clicked() ), this, SLOT( deleteSelectedItems() ) );
+  connect( theClearAll, SIGNAL( clicked() ), this, SLOT( clearList() ) );
+}
+
+/*!
+  Destructor
+*/
+OCCViewer_CreateRestoreViewDlg::~OCCViewer_CreateRestoreViewDlg()
+{
+}
+
+/*!
+  Changes image in accordance with item
+  \param curItem - item contains info about view parameters
+*/
+void OCCViewer_CreateRestoreViewDlg::changeImage( QListWidgetItem* curItem )
+{
+       if( curItem && myListBox->editTriggers()!=QListWidget::NoEditTriggers )
+       {
+               int lowLevel  = -1;
+               int highLevel = -1;
+               int index = curItem->listWidget()->row( curItem );
+    QList<QListWidgetItem*> aSelected = myListBox->selectedItems();
+               if( myKeyFlag == 2 )
+               {
+                       for( int i = 0; i < (int)myListBox->count(); i++ )
+                       {
+                               if( aSelected.contains( myListBox->item( i ) ) && i != index )
+                               {
+                                       myListBox->clearSelection();
+                                       if( i > index )
+                                       {
+                                               lowLevel  = index;
+                                               highLevel = i;
+                                       }
+                                       else
+                                       {
+                                               lowLevel  = i;
+                                               highLevel = index;
+                                       }
+                                       for( int j = lowLevel; j <= highLevel; j++ )
+            myListBox->item( j )->setSelected( true );
+                                       break;
+                               }
+                               if( aSelected.contains( myListBox->item( i ) ) && i == index )
+                                       myListBox->item( i )->setSelected( true );
+                       }
+               }
+
+               Handle(V3d_View) aView3d = myCurViewPort->getView();
+               myCurrentItem = myParametersMap[ index ];
+
+               Standard_Boolean prev = aView3d->SetImmediateUpdate( Standard_False );
+               aView3d->SetScale( myCurrentItem.scale );
+               aView3d->SetCenter( myCurrentItem.centerX, myCurrentItem.centerY );
+               aView3d->SetProj( myCurrentItem.projX, myCurrentItem.projY, myCurrentItem.projZ );
+               aView3d->SetTwist( myCurrentItem.twist );
+               aView3d->SetAt( myCurrentItem.atX, myCurrentItem.atY, myCurrentItem.atZ );
+               aView3d->SetImmediateUpdate( prev );
+               aView3d->SetEye( myCurrentItem.eyeX, myCurrentItem.eyeY, myCurrentItem.eyeZ );
+        }
+}
+
+/*!
+  \return current view parameters (corresponding to current item)
+*/
+viewAspect OCCViewer_CreateRestoreViewDlg::currentItem() const
+{
+       return myCurrentItem;
+}
+
+/*!
+  Deletes selected items from list view
+*/
+void OCCViewer_CreateRestoreViewDlg::deleteSelectedItems()
+{
+  if( myListBox->count() && myListBox->editTriggers()!=QListWidget::NoEditTriggers )
+       {
+               int curIndex = -1;
+    QList<QListWidgetItem*> aSelected = myListBox->selectedItems();
+               for( int i = 0; i < (int)myListBox->count(); i++ )
+      if( aSelected.contains( myListBox->item( i ) ) )
+                       {
+                               myListBox->takeItem( i );
+                               for( int j = i; j < (int)myParametersMap.count(); j++ )
+                                       if( j != myParametersMap.count() - 1 )
+                                               myParametersMap[ j ] = myParametersMap[ j + 1 ];
+                                       else
+            myParametersMap.removeAt( j );
+                               if( i != myListBox->count() )
+                                       curIndex = i;
+                               else
+                                       curIndex = i - 1;
+                               i--;
+                       }
+               if( curIndex >= 0 )
+               {
+                       myListBox->setCurrentItem( myListBox->item( curIndex ) );
+                       changeImage( myListBox->item( curIndex ) );
+               }
+       }
+       if( !myListBox->count() )
+       {
+               myListBox->clear();
+               myListBox->insertItem( 0, "No Items" );
+               //myListBox->setEditEnabled( 0 );
+    myListBox->setEditTriggers( QListWidget::NoEditTriggers );
+       }
+}
+
+/*!
+  Clears list of view aspects
+*/
+void OCCViewer_CreateRestoreViewDlg::clearList()
+{
+       myListBox->clear();
+       myListBox->insertItem( 0, "No Items" );
+       //myListBox->setEditEnabled( 0 );
+  myListBox->setEditTriggers( QListWidget::NoEditTriggers );
+
+       myParametersMap.clear();
+}
+
+/*!
+  \return const reference to all view aspects
+*/
+const viewAspectList& OCCViewer_CreateRestoreViewDlg::parameters() const
+{
+       return myParametersMap;
+}
+
+/*!
+  Renames key of view aspect map in accordance with item name
+  \param anItem - item
+*/
+void OCCViewer_CreateRestoreViewDlg::editItemText( QListWidgetItem* anItem )
+{
+       int index = anItem->listWidget()->row( anItem );
+       myParametersMap[ index ].name = anItem->text();
+}
+
+/*!
+  Custom event filter
+*/
+bool OCCViewer_CreateRestoreViewDlg::eventFilter( QObject* anObj, QEvent* anEv )
+{
+       if( anEv->type() == QEvent::KeyPress )
+       {
+               QKeyEvent* aKeyEv = ( QKeyEvent* )anEv;
+               if( aKeyEv->key() == Qt::Key_Control )
+               {
+                       myKeyFlag = 1;
+                       myListBox->setSelectionMode( QListWidget::MultiSelection );     
+               }
+               else if( aKeyEv->key() == Qt::Key_Shift )
+               {
+                       myKeyFlag = 2;
+                       myListBox->setSelectionMode( QListWidget::MultiSelection );     
+               }
+               else
+                       myListBox->setSelectionMode( QListWidget::SingleSelection );
+       }
+       if( anEv->type() == QEvent::KeyRelease )
+               myKeyFlag = 0;
+       
+       if( !myKeyFlag )
+       {
+               if( anEv->type() == QEvent::KeyPress || anEv->type() == QEvent::MouseButtonPress )
+                       myListBox->setSelectionMode( QListWidget::SingleSelection );
+       }
+       return QWidget::eventFilter( anObj, anEv );
+}
+
+/*!
+  SLOT: called on OK click, emits dlgOk() and closes dialog
+*/
+void OCCViewer_CreateRestoreViewDlg::OKpressed()
+{
+       emit dlgOk();
+       accept();
+}
+
diff --git a/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.h b/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.h
new file mode 100755 (executable)
index 0000000..4af4438
--- /dev/null
@@ -0,0 +1,72 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef OCCVIEWER_CREATERESTOREVIEWDLG_H
+#define OCCVIEWER_CREATERESTOREVIEWDLG_H
+
+#include "OCCViewer.h"
+
+#include "OCCViewer_ViewModel.h"
+#include "OCCViewer_ViewWindow.h"
+
+#include <QtxDialog.h>
+#include <SUIT_Application.h>
+
+class OCCViewer_ViewPort3d;
+class QListWidget;
+class QListWidgetItem;
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+class OCCVIEWER_EXPORT OCCViewer_CreateRestoreViewDlg : public QDialog
+{
+       Q_OBJECT
+
+public:
+       OCCViewer_CreateRestoreViewDlg( QWidget*, OCCViewer_Viewer* );
+       virtual ~OCCViewer_CreateRestoreViewDlg();
+
+       const viewAspectList&       parameters() const;
+       viewAspect                  currentItem() const;
+       virtual bool                                                eventFilter( QObject*, QEvent* );
+
+public slots:
+       void                          OKpressed();
+       void                          clearList();
+       void                        editItemText( QListWidgetItem* );
+       void                          changeImage( QListWidgetItem* );
+       void                          deleteSelectedItems();
+
+signals:
+       void                          dlgOk();
+
+private:
+       int                                                                       myKeyFlag;
+       QListWidget*                                    myListBox;
+       OCCViewer_ViewPort3d*         myCurViewPort;
+       viewAspect                  myCurrentItem;
+       viewAspectList              myParametersMap;
+};
+
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
+#endif
diff --git a/src/OCCViewer/OCCViewer_VService.cxx b/src/OCCViewer/OCCViewer_VService.cxx
new file mode 100755 (executable)
index 0000000..192c065
--- /dev/null
@@ -0,0 +1,322 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "OCCViewer_VService.h"
+#include <V3d_Viewer.hxx>
+#include <V3d_View.hxx>
+#include <Viewer_Viewer.hxx>
+
+#include <V2d_Viewer.hxx>
+#include <V2d_View.hxx>
+#include <Viewer_Viewer.hxx>
+
+#ifdef WNT
+#include <WNT_Window.hxx>
+#include <Graphic3d_WNTGraphicDevice.hxx>
+#include <WNT_GraphicDevice.hxx>
+#include <WNT_GraphicDevice.hxx>
+#include <WNT_WDriver.hxx>
+#else
+#include <Xw_Window.hxx>
+#include <Graphic3d_GraphicDevice.hxx>
+#include <Xw_Driver.hxx>
+//#include <Xdps_Driver.hxx>
+#include <Xw_TypeOfMapping.hxx>
+#endif
+
+// For 2d
+#define LOPTIM
+#ifdef WNT
+#ifndef LOPTIM
+static Handle(WNT_GraphicDevice) XServiceDefault2dDevice;
+static Handle(WNT_GraphicDevice) XServiceImageDevice;
+#else
+static Handle(WNT_GraphicDevice)& _XServiceDefault2dDevice() {
+static Handle(WNT_GraphicDevice) XServiceDefault2dDevice;
+return XServiceDefault2dDevice;
+}
+#define XServiceDefault2dDevice _XServiceDefault2dDevice()
+
+static Handle(WNT_GraphicDevice)& _XServiceImageDevice() {
+static Handle(WNT_GraphicDevice) XServiceImageDevice;
+return XServiceImageDevice;
+}
+#define XServiceImageDevice _XServiceImageDevice()
+#endif // LOPTIM
+#else
+#ifndef LOPTIM
+static Handle(Xw_GraphicDevice) XServiceDefault2dDevice;
+static Handle(Xw_GraphicDevice) XServiceImageDevice;
+#else
+static Handle(Xw_GraphicDevice)& _XServiceDefault2dDevice() {
+static Handle(Xw_GraphicDevice) XServiceDefault2dDevice;
+return XServiceDefault2dDevice;
+}
+#define XServiceDefault2dDevice _XServiceImageDevice()
+
+static Handle(Xw_GraphicDevice)& _XServiceImageDevice() {
+static Handle(Xw_GraphicDevice) XServiceImageDevice;
+return XServiceImageDevice;
+}
+#define XServiceImageDevice _XServiceImageDevice()
+#endif // LOPTIM
+#endif // WNT
+
+/*!
+    Create native view window for CasCade view [ static ]
+*/
+Handle(Aspect_Window) OCCViewer_VService::CreateWindow( const Handle(V3d_View)& view,
+                                                        const Standard_Integer hiwin,
+                                                        const Standard_Integer lowin,
+                                                        const Xw_WindowQuality quality )
+{
+#ifdef WNT
+  Handle(WNT_Window) viewWindow = new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin );
+  // Prevent flickering
+  viewWindow->SetFlags( WDF_NOERASEBKGRND );
+#else
+  Handle(Xw_Window) viewWindow = new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, quality );
+  viewWindow->SetDoubleBuffer( Standard_True );
+#endif
+  return viewWindow;
+}
+
+/*!
+    Maps CasCade view to the window [ static ]
+*/
+void OCCViewer_VService::SetWindow( const Handle(V3d_View)& view,
+                                 const Standard_Integer hiwin,
+                                 const Standard_Integer lowin,
+                                 const Xw_WindowQuality quality )
+{
+  view->SetWindow( OCCViewer_VService::CreateWindow( view, hiwin, lowin, quality ) );
+/*#ifdef WNT
+  Handle(WNT_Window) w =
+      new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin );
+#else
+  Handle(Xw_Window) w =
+      new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, quality );
+#endif
+  view->SetWindow( w );*/
+}
+
+/*!
+    Magnifies 'view' based on previous view [ static ]
+*/
+void OCCViewer_VService::SetMagnify( const Handle(V3d_View)& view,
+                                  const Standard_Integer hiwin,
+                                  const Standard_Integer lowin,
+                                  const Handle(V3d_View)& prevView,
+                                  const Standard_Integer x1,
+                                  const Standard_Integer y1,
+                                  const Standard_Integer x2,
+                                  const Standard_Integer y2,
+                               const Xw_WindowQuality aQuality )
+{
+#ifdef WNT
+  Handle(WNT_Window) w =
+      new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin );
+#else
+  Handle(Xw_Window) w =
+      new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, aQuality );
+#endif
+  view->SetMagnify( w, prevView, x1, y1, x2, y2 );
+}
+
+/*!
+    Creates viewer 3d [ static ]
+*/
+Handle(V3d_Viewer) OCCViewer_VService::Viewer3d( const Standard_CString aDisplay,
+                                           const Standard_ExtString aName,
+                                           const Standard_CString aDomain,
+                                           const Standard_Real ViewSize ,
+                                           const V3d_TypeOfOrientation ViewProj,
+                                           const Standard_Boolean ComputedMode,
+                                           const Standard_Boolean aDefaultComputedMode )
+{
+#ifndef WNT
+    static Handle(Graphic3d_GraphicDevice) defaultdevice;
+    if ( defaultdevice.IsNull() )
+        defaultdevice = new Graphic3d_GraphicDevice( aDisplay );
+    return new V3d_Viewer( defaultdevice, aName, aDomain, ViewSize, ViewProj,
+                           Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_ASAP,
+                           ComputedMode, aDefaultComputedMode, V3d_TEX_NONE );
+#else
+    static Handle(Graphic3d_WNTGraphicDevice) defaultdevice;
+    if ( defaultdevice.IsNull() )
+        defaultdevice = new Graphic3d_WNTGraphicDevice();
+    return new V3d_Viewer( defaultdevice, aName, aDomain, ViewSize, ViewProj,
+                           Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_ASAP,
+                           ComputedMode, aDefaultComputedMode, V3d_TEX_NONE);
+#endif  // WNT
+}
+
+/*!
+    Creates view 2D and maps it to the window [ static ]
+*/
+/*Handle(V2d_View) OCCViewer_VService::View2d( const Handle(V2d_Viewer)& aViewer,
+                                                          const Standard_Integer hiwin,
+                                                          const Standard_Integer lowin,
+                                                          const Xw_WindowQuality aQuality,
+                                                          const Standard_Boolean Update,
+                                                          const Quantity_NameOfColor BackColor )
+{
+#ifdef WNT
+    Handle(WNT_GraphicDevice) GD = Handle(WNT_GraphicDevice)::DownCast(aViewer->Device());
+    Handle(WNT_Window) W = new WNT_Window( GD, hiwin, lowin, BackColor );
+    Handle(WNT_WDriver) D = new WNT_WDriver( W );
+#else
+    Handle(Xw_GraphicDevice) GD = Handle(Xw_GraphicDevice)::DownCast(aViewer->Device());
+    Handle(Xw_Window) W = new Xw_Window( GD, hiwin, lowin, aQuality, BackColor );    
+    Handle(Xw_Driver) D = new Xw_Driver( W );
+#endif
+    Handle(V2d_View)  V = new V2d_View( D, aViewer );
+    if ( Update )
+        V->Update();
+    return V;
+}*/
+
+/*!
+    Creates view 2D and maps it to the window [ static ]
+*/
+/*Handle(V2d_View) OCCViewer_VService::dpsView2d( const Handle(V2d_Viewer)& aViewer,
+                                                             const Standard_Integer hiwin,
+                                                             const Standard_Integer lowin,
+                                                             const Xw_WindowQuality aQuality,
+                                                             const Standard_Boolean Update,
+                                                             const Quantity_NameOfColor BackColor )
+{
+#ifdef WNT
+    Handle(WNT_GraphicDevice) GD = Handle(WNT_GraphicDevice)::DownCast(aViewer->Device());
+    Handle(WNT_Window) W = new WNT_Window( GD, hiwin, lowin, BackColor );
+    W->SetBackground( BackColor );
+    Handle(WNT_WDriver) D = new WNT_WDriver( W );
+#else
+    Handle(Xw_GraphicDevice) GD = Handle(Xw_GraphicDevice)::DownCast(aViewer->Device());
+    Handle(Xw_Window) W = new Xw_Window( GD,  hiwin, lowin, aQuality, BackColor );
+    Handle(Xdps_Driver) D = new Xdps_Driver( W );
+#endif
+    Handle(V2d_View)  V = new V2d_View( D, aViewer );
+    if ( Update )
+        V->Update();
+    return V;
+}*/
+
+/*!
+    Creates viewer 2D [ static ]
+*/
+/*Handle(V2d_Viewer) OCCViewer_VService::Viewer2d( const Standard_CString aDisplay,
+                                                          const Standard_ExtString aName,
+                                                          const Standard_CString aDomain )
+{
+#ifdef WNT
+    if ( XServiceDefault2dDevice.IsNull() )
+        XServiceDefault2dDevice = new WNT_GraphicDevice();
+#else
+    if ( XServiceDefault2dDevice.IsNull() )
+        XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
+#endif
+    return new V2d_Viewer( XServiceDefault2dDevice, aName, aDomain );
+}*/
+
+/*!
+    Creates viewer 2D [ static ]
+*/
+/*Handle(V2d_Viewer) OCCViewer_VService::Viewer2d( const Standard_CString aDisplay,
+                                                          const Handle(Graphic2d_View)& aView,
+                                                          const Standard_ExtString aName,
+                                                          const Standard_CString aDomain )
+{
+#ifdef WNT
+    if ( XServiceDefault2dDevice.IsNull() )
+        XServiceDefault2dDevice = new WNT_GraphicDevice();
+#else
+    if ( XServiceDefault2dDevice.IsNull() )
+        XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
+#endif
+    return new V2d_Viewer( XServiceDefault2dDevice, aView, aName, aDomain );
+}*/
+
+/*!
+    Creates window driver [ static ]
+*/
+Handle(Aspect_WindowDriver) OCCViewer_VService::WindowDriver( const Standard_CString aDisplay,
+                                                        const Standard_Integer ahiwin,
+                                                        const Standard_Integer alowin,
+                                                        const Quantity_NameOfColor aColor )
+{
+#ifdef WNT
+    if ( XServiceDefault2dDevice.IsNull() )
+        XServiceDefault2dDevice = new WNT_GraphicDevice();
+    Handle(WNT_Window) W = new WNT_Window( XServiceDefault2dDevice, ahiwin, alowin, aColor );
+    return new WNT_WDriver( W );
+#else
+    if ( XServiceDefault2dDevice.IsNull() )
+        XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
+    Handle(Xw_Window) W = new Xw_Window( XServiceDefault2dDevice, ahiwin, alowin, Xw_WQ_DRAWINGQUALITY , aColor );
+    return new Xw_Driver( W );
+#endif
+}
+
+/*!
+    Creates Xdps window driver [ static ]
+    On Win32 the same as OCCViewer_VService::WindowDriver()
+*/
+/*
+Handle(Aspect_WindowDriver) OCCViewer_VService::XdpsDriver( const Standard_CString aDisplay,
+                                                      const Standard_Integer ahiwin,
+                                                      const Standard_Integer alowin,
+                                                      const Quantity_NameOfColor aColor )
+{
+#ifdef WNT
+    if ( XServiceDefault2dDevice.IsNull() )
+        XServiceDefault2dDevice = new WNT_GraphicDevice();
+    Handle(WNT_Window) W = new WNT_Window( XServiceDefault2dDevice, ahiwin, alowin, aColor );
+    return new WNT_WDriver( W );
+#else
+    if ( XServiceDefault2dDevice.IsNull() )
+        XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
+    Handle(Xw_Window) W = new Xw_Window( XServiceDefault2dDevice, ahiwin, alowin,
+                                         Xw_WQ_DRAWINGQUALITY, aColor );
+    return new Xdps_Driver( W );
+#endif
+}
+*/
+/*!
+    Creates Xw window driver [ static ]
+    On Win32 the same as OCCViewer_VService::WindowDriver()
+*/
+Handle(Aspect_WindowDriver) OCCViewer_VService::ImageDriver( const Standard_CString aDisplay,
+                                                       const Standard_Integer ahiwin,
+                                                       const Standard_Integer alowin,
+                                                       const Quantity_NameOfColor aColor )
+{
+#ifdef WNT
+    if ( XServiceImageDevice.IsNull() )
+        XServiceImageDevice = new WNT_GraphicDevice();
+    Handle(WNT_Window) W = new WNT_Window( XServiceImageDevice, ahiwin, alowin, aColor );
+    return new WNT_WDriver( W );
+#else
+    if ( XServiceImageDevice.IsNull() )
+        XServiceImageDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
+    Handle(Xw_Window) W = new Xw_Window( XServiceImageDevice, ahiwin, alowin,
+                                         Xw_WQ_PICTUREQUALITY, aColor );
+    return new Xw_Driver( W );
+#endif
+}
diff --git a/src/OCCViewer/OCCViewer_VService.h b/src/OCCViewer/OCCViewer_VService.h
new file mode 100755 (executable)
index 0000000..d6d6544
--- /dev/null
@@ -0,0 +1,140 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef OCCVIEWER_VSERVICE_H
+#define OCCVIEWER_VSERVICE_H
+
+#ifndef _Handle_V3d_View_HeaderFile
+#include <Handle_V3d_View.hxx>
+#endif
+#ifndef _Standard_Integer_HeaderFile
+#include <Standard_Integer.hxx>
+#endif
+#ifndef _Xw_WindowQuality_HeaderFile
+#include <Xw_WindowQuality.hxx>
+#endif
+#ifndef _Handle_V3d_Viewer_HeaderFile
+#include <Handle_V3d_Viewer.hxx>
+#endif
+#ifndef _Standard_CString_HeaderFile
+#include <Standard_CString.hxx>
+#endif
+#ifndef _Standard_ExtString_HeaderFile
+#include <Standard_ExtString.hxx>
+#endif
+#ifndef _Quantity_Length_HeaderFile
+#include <Quantity_Length.hxx>
+#endif
+#ifndef _Quantity_NameOfColor_HeaderFile
+#include <Quantity_NameOfColor.hxx>
+#endif
+#ifndef _V3d_TypeOfOrientation_HeaderFile
+#include <V3d_TypeOfOrientation.hxx>
+#endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+#ifndef _Handle_Graphic2d_View_HeaderFile
+#include <Handle_Graphic2d_View.hxx>
+#endif
+#ifndef _Handle_Aspect_WindowDriver_HeaderFile
+#include <Handle_Aspect_WindowDriver.hxx>
+#endif
+
+class V3d_View;
+class V2d_View;
+class V3d_Viewer;
+class V2d_Viewer;
+class Graphic2d_View;
+class Aspect_WindowDriver;
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+
+#include <V3d_View.hxx>
+
+class Standard_EXPORT OCCViewer_VService
+{
+public:
+    inline void* operator new(size_t,void* anAddress)
+    {
+        return anAddress;
+    }
+    inline void* operator new(size_t size)
+    {
+        return Standard::Allocate(size);
+    }
+    inline void  operator delete(void *anAddress)
+    {
+        if ( anAddress ) Standard::Free((Standard_Address&)anAddress);
+    }
+
+    // STATIC METHODS
+    static Handle(Aspect_Window) 
+                    CreateWindow( const Handle(V3d_View)& view,
+                                  const Standard_Integer hiwin,
+                                  const Standard_Integer lowin,
+                                  const Xw_WindowQuality quality );
+
+    static void     SetWindow( const Handle(  V3d_View )& view,
+                               const Standard_Integer hiwin,
+                               const Standard_Integer lowin,
+                               const Xw_WindowQuality quality = Xw_WQ_3DQUALITY );
+
+    static void     SetMagnify( const Handle( V3d_View)& view,
+                                const Standard_Integer hiwin,
+                                const Standard_Integer lowin,
+                                const Handle( V3d_View)& aPreviousView,
+                                const Standard_Integer x1,
+                                const Standard_Integer y1,
+                                const Standard_Integer x2,
+                                const Standard_Integer y2,
+                                const Xw_WindowQuality quality = Xw_WQ_3DQUALITY );
+    static Handle_V3d_Viewer
+                    Viewer3d( const Standard_CString display,
+                              const Standard_ExtString name,
+                              const Standard_CString domain = "",
+                              const Quantity_Length ViewSize = 1000.0,
+                              const V3d_TypeOfOrientation ViewProj = V3d_XposYnegZpos,
+                              const Standard_Boolean ComputedMode = Standard_True,
+                              const Standard_Boolean DefaultComputedMode = Standard_True );
+
+    static Handle_Aspect_WindowDriver
+                    WindowDriver( const Standard_CString display,
+                                  const Standard_Integer hiwin,
+                                  const Standard_Integer lowin,
+                                  const Quantity_NameOfColor color = Quantity_NOC_GRAY69 );
+    /*static Handle_Aspect_WindowDriver
+                    XdpsDriver( const Standard_CString display,
+                                const Standard_Integer hiwin,
+                                const Standard_Integer lowin,
+                                const Quantity_NameOfColor color = Quantity_NOC_GRAY69 );
+    */
+    static Handle_Aspect_WindowDriver
+                    ImageDriver( const Standard_CString display,
+                                 const Standard_Integer hiwin,
+                                 const Standard_Integer lowin,
+                                 const Quantity_NameOfColor color = Quantity_NOC_GRAY69 );
+
+};
+
+#endif
diff --git a/src/OCCViewer/OCCViewer_ViewManager.cxx b/src/OCCViewer/OCCViewer_ViewManager.cxx
new file mode 100755 (executable)
index 0000000..a9c3b83
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "OCCViewer_ViewManager.h"
+#include "OCCViewer_ViewWindow.h"
+#include "SUIT_Desktop.h"
+
+/*!
+  Constructor
+*/
+OCCViewer_ViewManager::OCCViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop, bool DisplayTrihedron )
+: SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron ) )
+{
+  setTitle( tr( "OCC_VIEW_TITLE" ) );
+}
+
+/*!
+  Destructor
+*/
+OCCViewer_ViewManager::~OCCViewer_ViewManager()
+{
+}
+
+/*!
+  Fills popup menu with custom actions
+ \param popup - popup menu to be filled with
+*/
+void OCCViewer_ViewManager::contextMenuPopup( QMenu* popup )
+{
+  SUIT_ViewManager::contextMenuPopup( popup );
+  // if it is necessary invoke method CreatePopup of ViewPort
+  // be sure that existing QMenu menu is used for that.
+}
diff --git a/src/OCCViewer/OCCViewer_ViewManager.h b/src/OCCViewer/OCCViewer_ViewManager.h
new file mode 100755 (executable)
index 0000000..c39e43c
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef OCCVIEWER_VIEWMANAGER_H
+#define OCCVIEWER_VIEWMANAGER_H
+
+#include "OCCViewer_ViewModel.h"
+
+#include "SUIT_ViewManager.h"
+
+class SUIT_Desktop;
+
+class OCCVIEWER_EXPORT OCCViewer_ViewManager : public SUIT_ViewManager
+{
+  Q_OBJECT
+
+public:
+  OCCViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop, bool DisplayTrihedron = true );
+  ~OCCViewer_ViewManager();
+
+  OCCViewer_Viewer* getOCCViewer() { return (OCCViewer_Viewer*) myViewModel; }
+
+  virtual void      contextMenuPopup( QMenu* );
+};
+
+#endif
diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx
new file mode 100755 (executable)
index 0000000..28e8548
--- /dev/null
@@ -0,0 +1,622 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "OCCViewer_ViewModel.h"
+#include "OCCViewer_ViewWindow.h"
+#include "OCCViewer_VService.h"
+#include "OCCViewer_ViewPort3d.h"
+
+#include "SUIT_ViewWindow.h"
+#include "SUIT_ViewManager.h"
+#include "SUIT_Desktop.h"
+#include "SUIT_Session.h"
+
+#include <QMenu>
+#include <QMouseEvent>
+#include <QToolBar>
+#include <QColorDialog>
+
+#include <AIS_Axis.hxx>
+#include <AIS_Drawer.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+
+#include <Geom_Axis2Placement.hxx>
+#include <Prs3d_DatumAspect.hxx>
+#include <Prs3d_LineAspect.hxx>
+
+/*!
+  Constructor
+  \param DisplayTrihedron - is trihedron displayed
+*/
+OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron )
+: SUIT_ViewModel(),
+myBgColor( Qt::black )
+{
+  // init CasCade viewers
+  myV3dViewer = OCCViewer_VService::Viewer3d( "", (short*) "Viewer3d", "", 1000.,
+                                              V3d_XposYnegZpos, true, true );
+
+  myV3dViewer->Init();
+
+  myV3dCollector = OCCViewer_VService::Viewer3d( "", (short*) "Collector3d", "", 1000.,
+                                                 V3d_XposYnegZpos, true, true );
+  myV3dCollector->Init();
+
+  // init selector
+  myAISContext = new AIS_InteractiveContext( myV3dViewer, myV3dCollector);
+
+  myAISContext->SelectionColor( Quantity_NOC_WHITE );
+  
+  // display isoline on planar faces (box for ex.)
+  myAISContext->IsoOnPlane( true );
+
+  clearViewAspects();
+
+  /* create trihedron */
+  if( DisplayTrihedron )
+  {
+    Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement(gp::XOY());
+    myTrihedron = new AIS_Trihedron(anAxis);
+    myTrihedron->SetInfiniteState( Standard_True );
+
+    Quantity_Color Col(193/255., 205/255., 193/255., Quantity_TOC_RGB);
+    //myTrihedron->SetColor( Col );
+    myTrihedron->SetArrowColor( Col.Name() );
+    myTrihedron->SetSize(100);
+    Handle(AIS_Drawer) drawer = myTrihedron->Attributes();
+    if (drawer->HasDatumAspect()) {
+        Handle(Prs3d_DatumAspect) daspect = drawer->DatumAspect();
+        daspect->FirstAxisAspect()->SetColor(Quantity_Color(1.0, 0.0, 0.0, Quantity_TOC_RGB));
+        daspect->SecondAxisAspect()->SetColor(Quantity_Color(0.0, 1.0, 0.0, Quantity_TOC_RGB));
+        daspect->ThirdAxisAspect()->SetColor(Quantity_Color(0.0, 0.0, 1.0, Quantity_TOC_RGB));
+    }
+
+    myAISContext->Display(myTrihedron);
+    myAISContext->Deactivate(myTrihedron);
+  }
+
+  // selection
+  mySelectionEnabled = true;
+  myMultiSelectionEnabled = true;
+}
+
+/*!
+  Destructor
+*/
+OCCViewer_Viewer::~OCCViewer_Viewer() 
+{
+}
+
+/*!
+  \return background color of viewer
+*/
+QColor OCCViewer_Viewer::backgroundColor() const
+{
+  return myBgColor;
+}
+
+/*!
+  Sets background color
+  \param c - new background color
+*/
+void OCCViewer_Viewer::setBackgroundColor( const QColor& c )
+{
+  if ( c.isValid() )
+    myBgColor = c;
+}
+
+/*!
+  Start initialization of view window
+  \param view - view window to be initialized
+*/
+void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view )
+{
+  if ( view ) {
+    view->initLayout();
+    
+    OCCViewer_ViewPort3d* vp3d = view->getViewPort();
+    if ( vp3d )
+      vp3d->setBackgroundColor( myBgColor );
+  }
+}
+
+/*!
+  Creates new view window
+  \param theDesktop - main window of application
+*/
+SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop )
+{
+  OCCViewer_ViewWindow* view = new OCCViewer_ViewWindow(theDesktop, this);
+  initView( view );
+  return view;
+}
+
+/*!
+  Sets new view manager
+  \param theViewManager - new view manager
+*/
+void OCCViewer_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
+{
+  SUIT_ViewModel::setViewManager(theViewManager);
+  if (theViewManager)
+  {
+    connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), 
+            this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
+
+    connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), 
+            this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
+
+    connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), 
+            this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
+  }
+}
+
+/*!
+  SLOT: called on mouse button press, stores current mouse position as start point for transformations
+*/
+void OCCViewer_Viewer::onMousePress(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
+{
+  myStartPnt.setX(theEvent->x()); myStartPnt.setY(theEvent->y());
+}
+
+/*!
+  SLOT: called on mouse move, processes transformation or hilighting
+*/
+void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
+{
+  if (!mySelectionEnabled) return;
+  if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
+
+  OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
+  if ( isSelectionEnabled() )
+    myAISContext->MoveTo(theEvent->x(), theEvent->y(), aView->getViewPort()->getView());
+}
+
+
+/*!
+  SLOT: called on mouse button release, finishes transformation or selection
+*/
+void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
+{
+  if (!mySelectionEnabled) return;
+  if (theEvent->button() != Qt::LeftButton) return;
+  if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
+
+
+  myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y());
+  OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
+  bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
+
+  if (myStartPnt == myEndPnt)
+  {
+    if (aHasShift && myMultiSelectionEnabled)
+      myAISContext->ShiftSelect();
+    else
+      myAISContext->Select();
+  }
+  else
+  {
+    if (aHasShift && myMultiSelectionEnabled)
+      myAISContext->ShiftSelect(myStartPnt.x(), myStartPnt.y(),
+                                myEndPnt.x(), myEndPnt.y(),
+                                aView->getViewPort()->getView(), Standard_False );
+    else
+      myAISContext->Select(myStartPnt.x(), myStartPnt.y(),
+                           myEndPnt.x(), myEndPnt.y(),
+                           aView->getViewPort()->getView(), Standard_False );
+
+    int Nb = myAISContext->NbSelected();
+    if( Nb>1 && !myMultiSelectionEnabled )
+    {
+        myAISContext->InitSelected();
+        Handle( SelectMgr_EntityOwner ) anOwner = myAISContext->SelectedOwner();
+        if( !anOwner.IsNull() )
+        {
+            myAISContext->ClearSelected( Standard_False );
+            myAISContext->AddOrRemoveSelected( anOwner, Standard_False );
+        }
+    }
+
+    myAISContext->UpdateCurrentViewer();
+  }
+  emit selectionChanged();
+}
+
+
+/*!
+  Sets selection enabled status
+  \param isEnabled - new status
+*/
+void OCCViewer_Viewer::enableSelection(bool isEnabled)
+{
+  mySelectionEnabled = isEnabled;
+  //!! To be done for view windows
+  if ( !myViewManager )
+    return;
+
+  QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+  for ( int i = 0; i < (int)wins.count(); i++ )
+  {
+    OCCViewer_ViewWindow* win = qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+    if ( win )
+      win->updateEnabledDrawMode();
+  }
+}
+
+/*!
+  Sets multiselection enabled status
+  \param isEnabled - new status
+*/
+void OCCViewer_Viewer::enableMultiselection(bool isEnable)
+{
+  myMultiSelectionEnabled = isEnable;
+  //!! To be done for view windows
+  if ( !myViewManager )
+    return;
+
+  QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+  for ( int i = 0; i < (int)wins.count(); i++ )
+  {
+    OCCViewer_ViewWindow* win = qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+    if ( win )
+      win->updateEnabledDrawMode();
+  }
+}
+
+/*!
+  Builds popup for occ viewer
+*/
+void OCCViewer_Viewer::contextMenuPopup(QMenu* thePopup)
+{
+  thePopup->addAction( tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
+  thePopup->addAction( tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) );
+
+  thePopup->addSeparator();
+
+  OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
+  //Support of several toolbars in the popup menu
+  if( aView )
+  {
+    QList<QToolBar*> lst = qFindChildren<QToolBar*>( aView );
+    QList<QToolBar*>::const_iterator it = lst.begin(), last = lst.end();
+    for ( ; it!=last; it++ )
+    {
+      if ( (*it)->parentWidget()->isVisible() )
+        thePopup->addAction( (*it)->toggleViewAction() );
+    }
+  }
+}
+
+/*!
+  SLOT: called on dump view operation is activated, stores scene to raster file
+*/
+void OCCViewer_Viewer::onDumpView()
+{
+  OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
+  if ( aView )
+    aView->onDumpView();
+}
+
+/*!
+  SLOT: called if background color is to be changed changed, passes new color to view port
+*/
+void OCCViewer_Viewer::onChangeBgColor()
+{
+  OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
+  if( !aView )
+    return;
+  OCCViewer_ViewPort3d* aViewPort3d = aView->getViewPort();
+  if( !aViewPort3d )
+    return;
+  QColor aColorActive = aViewPort3d->backgroundColor();
+
+  QColor selColor = QColorDialog::getColor( aColorActive, aView);
+  if ( selColor.isValid() )
+    aViewPort3d->setBackgroundColor(selColor);
+}
+
+/*!
+  Updates OCC 3D viewer
+*/
+void OCCViewer_Viewer::update()
+{
+  if (!myV3dViewer.IsNull())
+    myV3dViewer->Update();
+}
+
+/*!
+  \return objects selected in 3D viewer
+  \param theList - list to be filled with selected objects
+*/
+void OCCViewer_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList)
+{
+  theList.Clear();
+  for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected())
+    theList.Append(myAISContext->SelectedInteractive());
+}
+
+/*!
+  Selects objects in 3D viewer. Other selected objects are left as selected
+  \param theList - list objects to be selected
+*/
+void OCCViewer_Viewer::setObjectsSelected(const AIS_ListOfInteractive& theList)
+{
+  AIS_ListIteratorOfListOfInteractive aIt;
+  for (aIt.Initialize(theList); aIt.More(); aIt.Next())
+    myAISContext->AddOrRemoveSelected(aIt.Value(), false);
+  myAISContext->UpdateCurrentViewer();
+}
+
+/*!
+  Auxiliary method to emit signal selectionChanged()
+*/
+void OCCViewer_Viewer::performSelectionChanged()
+{
+    emit selectionChanged();
+}
+
+/*!
+  SLOT, clears view aspects
+*/
+void OCCViewer_Viewer::onClearViewAspects()
+{
+    clearViewAspects();
+}
+
+/*!
+  Clears view aspects
+*/
+void OCCViewer_Viewer::clearViewAspects()
+{
+       myViewAspects.clear();
+}
+
+/*!
+  \return const reference to list of view aspects
+*/
+const viewAspectList& OCCViewer_Viewer::getViewAspects()
+{
+       return myViewAspects;
+}
+
+/*!
+  Appends new view aspect
+  \param aParams - new view aspects
+*/
+void OCCViewer_Viewer::appendViewAspect( const viewAspect& aParams )
+{
+       myViewAspects.append( aParams );
+}
+
+/*!
+  Replaces old view aspects by new ones
+  \param aViewList - list of new view aspects
+*/
+void OCCViewer_Viewer::updateViewAspects( const viewAspectList& aViewList )
+{
+       myViewAspects = aViewList;
+}
+
+/*!
+  Hilights/unhilights object in viewer
+  \param obj - object to be updated
+  \param hilight - if it is true, object will be hilighted, otherwise it will be unhilighted
+  \param update - update current viewer
+*/
+bool OCCViewer_Viewer::highlight( const Handle(AIS_InteractiveObject)& obj,
+                                  bool hilight, bool update )
+{
+  bool isInLocal = myAISContext->HasOpenedContext();
+  if( !obj.IsNull() )
+    if( !isInLocal )
+    {
+      if ( hilight && !myAISContext->IsSelected( obj ) )
+        myAISContext->AddOrRemoveCurrentObject( obj, false );
+      else if ( !hilight && myAISContext->IsSelected( obj ) )
+        myAISContext->AddOrRemoveCurrentObject( obj, false );
+    }
+
+  if ( update )
+    myV3dViewer->Redraw();
+    
+  return false;
+}
+
+/*!
+  Unhilights all objects in viewer
+  \param updateviewer - update current viewer
+*/
+bool OCCViewer_Viewer::unHighlightAll( bool updateviewer )
+{
+  if ( myAISContext->HasOpenedContext() )
+    myAISContext->ClearSelected( updateviewer );
+  else
+    myAISContext->ClearCurrents( updateviewer );
+  return false;
+}
+
+/*!
+  \return true if object is in viewer or in collector
+  \param obj - object to be checked
+  \param onlyInViewer - search object only in viewer (so object must be displayed)
+*/
+bool OCCViewer_Viewer::isInViewer( const Handle(AIS_InteractiveObject)& obj,
+                                   bool onlyInViewer )
+{
+  AIS_ListOfInteractive List;
+  myAISContext->DisplayedObjects(List);
+
+  if( !onlyInViewer )
+  {
+    AIS_ListOfInteractive List1;
+    myAISContext->ObjectsInCollector(List1);
+    List.Append(List1);
+  }
+
+  AIS_ListIteratorOfListOfInteractive ite(List);
+  for ( ; ite.More(); ite.Next() )
+    if( ite.Value()==obj )
+      return true;
+
+  return false;
+}
+
+/*!
+  \return true if object is displayed in viewer
+  \param obj - object to be checked
+*/
+bool OCCViewer_Viewer::isVisible( const Handle(AIS_InteractiveObject)& obj )
+{
+  return myAISContext->IsDisplayed( obj );
+}
+
+/*!
+  Sets color of object
+  \param obj - object to be updated
+  \param color - new color
+  \param update - update current viewer
+*/
+void OCCViewer_Viewer::setColor( const Handle(AIS_InteractiveObject)& obj,
+                                 const QColor& color,
+                                 bool update )
+{
+  if( !obj.IsNull() )
+  {
+    Quantity_Color CSFColor = Quantity_Color ( color.red() / 255.,
+                                               color.green() / 255.,
+                                               color.blue() / 255.,
+                                               Quantity_TOC_RGB );
+    obj->SetColor( CSFColor );
+  }
+
+  if( update )
+    myV3dViewer->Update();
+}
+
+/*!
+  Changes display mode of object
+  \param obj - object to be processed
+  \param mode - new display mode
+  \param update - update current viewer
+*/
+void OCCViewer_Viewer::switchRepresentation( const Handle(AIS_InteractiveObject)& obj,
+                                             int mode, bool update )
+{
+  myAISContext->SetDisplayMode( obj, (Standard_Integer)mode, update );
+  if( update )
+    myV3dViewer->Update();
+}
+
+/*!
+  Changes transparency of object
+  \param obj - object to be processed
+  \param trans - new transparency
+  \param update - update current viewer
+*/
+void OCCViewer_Viewer::setTransparency( const Handle(AIS_InteractiveObject)& obj,
+                                        float trans, bool update )
+{
+  myAISContext->SetTransparency( obj, trans, false );
+  myAISContext->Redisplay( obj, Standard_False, Standard_True );
+  if( update )
+    myV3dViewer->Update();
+}
+
+/*!
+  Changes visibility of trihedron to opposite
+*/
+void OCCViewer_Viewer::toggleTrihedron()
+{
+  setTrihedronShown( !isTrihedronVisible() );
+}
+
+/*!
+  \return true if trihedron is visible
+*/
+bool OCCViewer_Viewer::isTrihedronVisible() const
+{
+  return !myTrihedron.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myTrihedron );
+}
+
+/*!
+  Sets visibility state of trihedron
+  \param on - new state
+*/
+
+void OCCViewer_Viewer::setTrihedronShown( const bool on )
+{
+  if ( myTrihedron.IsNull() )
+    return;
+
+  if ( on )
+    myAISContext->Display( myTrihedron );
+  else
+    myAISContext->Erase( myTrihedron );
+}
+
+/*!
+  \return trihedron size
+*/
+double OCCViewer_Viewer::trihedronSize() const
+{
+  double sz = 0;
+  if ( !myTrihedron.IsNull() )
+    sz = myTrihedron->Size();
+  return sz;
+}
+
+/*!
+  Changes trihedron size
+  \param sz - new size
+*/
+void OCCViewer_Viewer::setTrihedronSize( const double sz )
+{
+  if ( !myTrihedron.IsNull() )
+    myTrihedron->SetSize( sz );
+}
+
+/*!
+  Set number of isolines
+  \param u - u-isolines (first parametric co-ordinate)
+  \param v - v-isolines (second parametric co-ordinate)
+*/
+void OCCViewer_Viewer::setIsos( const int u, const int v )
+{
+  Handle(AIS_InteractiveContext) ic = getAISContext();
+  if ( ic.IsNull() )
+  return;
+
+  ic->SetIsoNumber( u, AIS_TOI_IsoU );
+  ic->SetIsoNumber( v, AIS_TOI_IsoV );
+}
+
+/*!
+  \return number of isolines
+  \param u - to return u-isolines (first parametric co-ordinate)
+  \param v - to return v-isolines (second parametric co-ordinate)
+*/
+void OCCViewer_Viewer::isos( int& u, int& v ) const
+{
+  Handle(AIS_InteractiveContext) ic = getAISContext();
+  if ( !ic.IsNull() )
+  {
+    u = ic->IsoNumber( AIS_TOI_IsoU );
+    v = ic->IsoNumber( AIS_TOI_IsoV );
+  }
+}
diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h
new file mode 100755 (executable)
index 0000000..3744266
--- /dev/null
@@ -0,0 +1,175 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef OCCVIEWER_VIEWMODEL_H
+#define OCCVIEWER_VIEWMODEL_H
+
+#include <qcolor.h>
+#include <qcursor.h>
+
+#include "OCCViewer.h"
+
+#include "SUIT_ViewModel.h"
+
+#include <V3d_View.hxx>
+#include <AIS_Trihedron.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_InteractiveContext.hxx>
+
+class SUIT_ViewWindow;
+class SUIT_Desktop;
+class OCCViewer_ViewWindow;
+class QMouseEvent;
+
+struct viewAspect
+{
+public:
+       double    scale;
+       double  centerX;
+       double  centerY;
+       double    projX;
+       double    projY;
+       double    projZ;
+       double    twist;
+       double      atX;
+       double      atY;
+       double      atZ;
+       double     eyeX;
+       double     eyeY;
+       double     eyeZ;
+       QString    name;
+};
+
+typedef QList<viewAspect> viewAspectList;
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+class OCCVIEWER_EXPORT OCCViewer_Viewer: public SUIT_ViewModel
+{
+  Q_OBJECT
+
+public:
+  static QString Type() { return "OCCViewer"; }
+
+  OCCViewer_Viewer( bool DisplayTrihedron = true );
+  virtual ~OCCViewer_Viewer();
+
+  void update();
+
+       virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
+
+       virtual void                    setViewManager(SUIT_ViewManager* theViewManager);
+  virtual QString                 getType() const { return Type(); }
+
+  virtual void                    contextMenuPopup(QMenu*);
+  
+  void                            getSelectedObjects(AIS_ListOfInteractive& theList);
+  void                            setObjectsSelected(const AIS_ListOfInteractive& theList);
+  void                            setSelected(const Handle(AIS_InteractiveObject)& theIO)
+  { myAISContext->SetSelected(theIO);}
+
+  void                            performSelectionChanged();
+  // emit signal selectionChanged
+
+  virtual const viewAspectList&   getViewAspects();
+  virtual void                    appendViewAspect( const viewAspect& );
+  virtual void                    updateViewAspects( const viewAspectList& );
+  virtual void                    clearViewAspects();
+
+  QColor                          backgroundColor() const;
+  void                            setBackgroundColor( const QColor& );
+
+  //! 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 );
+
+  double                          trihedronSize() const;
+  virtual void                    setTrihedronSize( const double );
+
+public slots:
+  void                            onClearViewAspects();
+public:
+  Handle(V3d_Viewer)              getViewer3d()    const { return myV3dViewer;}
+  Handle(V3d_Viewer)              getCollector3d() const { return myV3dCollector; }
+  Handle(AIS_InteractiveContext)  getAISContext()  const { return myAISContext; }
+  Handle(AIS_Trihedron)           getTrihedron()   const { return myTrihedron; }
+
+  void                            enableSelection(bool isEnabled);
+  bool                            isSelectionEnabled() const 
+  { return mySelectionEnabled; }
+
+  void                            enableMultiselection(bool isEnable);
+  bool                            isMultiSelectionEnabled() const 
+  { return myMultiSelectionEnabled; }
+
+  int                             getSelectionCount() const 
+  { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
+
+  /* Selection management */
+  bool         highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true );
+  bool         unHighlightAll( bool=true ); 
+  bool    isInViewer( const Handle(AIS_InteractiveObject)&, bool=false );
+  bool    isVisible( const Handle(AIS_InteractiveObject)& );
+
+  void    setColor( const Handle(AIS_InteractiveObject)&, const QColor&, bool=true );
+  void    switchRepresentation( const Handle(AIS_InteractiveObject)&, int, bool=true );
+  void    setTransparency( const Handle(AIS_InteractiveObject)&, float, bool=true );
+  void    setIsos( const int u, const int v ); // number of isolines
+  void    isos( int& u, int& v ) const;
+
+signals:
+  void selectionChanged();
+
+protected:
+  void initView( OCCViewer_ViewWindow* view );
+
+protected slots:
+  void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
+  void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
+  void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
+
+  void onDumpView();
+  void onChangeBgColor();
+
+private:
+  Handle(V3d_Viewer)              myV3dViewer;
+  Handle(V3d_Viewer)              myV3dCollector;
+
+  Handle(AIS_Trihedron)           myTrihedron;
+  Handle(AIS_InteractiveContext)  myAISContext;
+
+  viewAspectList                  myViewAspects;
+
+  bool                            mySelectionEnabled;
+  bool                            myMultiSelectionEnabled;
+
+  QColor                          myBgColor;
+  QPoint                          myStartPnt, myEndPnt;
+};
+
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
+#endif
diff --git a/src/OCCViewer/OCCViewer_ViewPort.cxx b/src/OCCViewer/OCCViewer_ViewPort.cxx
new file mode 100755 (executable)
index 0000000..0602e77
--- /dev/null
@@ -0,0 +1,485 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#if !defined WNT
+#define QT_CLEAN_NAMESPACE         /* avoid definition of INT32 and INT8 */
+#endif
+
+#include "OCCViewer_ViewPort.h"
+
+#include "SUIT_Session.h"
+
+#include <Qt>
+#include <QMenu>
+#include <QPainter>
+#include <QColorDialog>
+#include <QMultiHash>
+#include <QCoreApplication>
+#include <QColormap>
+
+#include <stdlib.h>
+
+#if !defined WNT
+#include <GL/glx.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/Xmu/StdCmap.h>
+#undef QT_CLEAN_NAMESPACE
+#include <Xw_Window.hxx>
+#include <Graphic3d_GraphicDevice.hxx>
+#include <QX11Info>
+
+struct CMapEntry
+{
+       CMapEntry();
+       ~CMapEntry();
+       Colormap          cmap;
+       bool              alloc;
+       XStandardColormap scmap;
+};
+
+/*!
+  Constructor
+*/
+CMapEntry::CMapEntry()
+{
+       cmap = 0;
+       alloc = false;
+       scmap.colormap = 0;
+}
+
+/*!
+  Destructor
+*/
+CMapEntry::~CMapEntry()
+{
+  if ( alloc )
+    XFreeColormap( QX11Info::display(), cmap );
+}
+
+static QMultiHash<int,CMapEntry> *cmap_dict = 0;
+static bool mesa_gl = false;
+
+static void cleanup_cmaps()
+{
+       if ( !cmap_dict )
+               return;
+       //cmap_dict->setAutoDelete( true );
+       cmap_dict->clear();
+       delete cmap_dict;
+       cmap_dict = 0;
+}
+
+static Colormap choose_cmap( Display *dpy, XVisualInfo *vi )
+{
+       if ( !cmap_dict )
+       {
+               cmap_dict = new QMultiHash<int,CMapEntry>;
+               const char *v = glXQueryServerString( dpy, vi->screen, GLX_VERSION );
+               mesa_gl = strstr( v,"Mesa" ) != 0;
+               qAddPostRoutine( cleanup_cmaps );
+       }
+
+    QHash<int,CMapEntry>::iterator itH = cmap_dict->find( (long)vi->visualid );
+    if ( itH != cmap_dict->end() )  // found colormap for visual
+      return itH.value().cmap;
+
+    CMapEntry x;
+
+    XStandardColormap *c;
+    int n, i;
+
+#ifdef DEBUG
+    cout << "Choosing cmap for vID = " << vi->visualid << endl;
+#endif
+
+    if ( vi->visualid == XVisualIDFromVisual( (Visual*)QX11Info::appVisual() ) )
+       {
+#ifdef DEBUG
+               cout << "Using x11AppColormap" << endl;
+#endif
+               return QX11Info::appColormap();
+    }
+
+    if ( mesa_gl )
+       {
+               Atom hp_cmaps = XInternAtom( dpy, "_HP_RGB_SMOOTH_MAP_LIST", true );
+               if ( hp_cmaps && vi->visual->c_class == TrueColor && vi->depth == 8 )
+               {
+               if ( XGetRGBColormaps( dpy, RootWindow( dpy, vi->screen ), &c, &n, hp_cmaps ) )
+            {
+                       i = 0;
+                           while ( i < n && x.cmap == 0 )
+                {
+                               if ( c[i].visualid == vi->visual->visualid )
+                                   {
+                                       x.cmap = c[i].colormap;
+                                           x.scmap = c[i];
+                               }
+                                   i++;
+                }
+                           XFree( (char*)c );
+               }
+        }
+       }
+#if !defined( _OS_SOLARIS_ )
+    if ( !x.cmap )
+    {
+           if ( XmuLookupStandardColormap( dpy, vi->screen, vi->visualid, vi->depth, XA_RGB_DEFAULT_MAP, false, true ) )
+        {
+                   if ( XGetRGBColormaps( dpy, RootWindow( dpy, vi->screen ), &c, &n, XA_RGB_DEFAULT_MAP ) )
+            {
+                           i = 0;
+                               while ( i < n && x.cmap == 0 )
+                               {
+                                   if ( c[i].visualid == vi->visualid )
+                    {
+                                           x.cmap = c[i].colormap;
+                                               x.scmap = c[i];
+                                   }
+                                       i++;
+                }
+                               XFree( (char *)c );
+            }
+        }
+    }
+#endif
+       if ( !x.cmap )
+       {
+               // no shared cmap found
+               x.cmap = XCreateColormap( dpy, RootWindow( dpy, vi->screen ), vi->visual, AllocNone );
+               x.alloc = true;
+       }
+
+       cmap_dict->insert( (long)vi->visualid, x ); // associate cmap with visualid
+       return x.cmap;
+}
+#endif
+
+
+/*!
+    Constructor
+*/
+OCCViewer_ViewPort::OCCViewer_ViewPort( QWidget* parent )
+: QWidget( parent )
+{
+  initialize();
+}
+
+/*!
+    Destructor
+*/
+OCCViewer_ViewPort::~OCCViewer_ViewPort()
+{
+  cleanup();
+}
+
+/*!
+    Initializes viewport. [ private ]
+*/
+void OCCViewer_ViewPort::initialize()
+{
+  //myPopupActions.setAutoDelete( true );//Not supported in Qt4
+  myPaintersRedrawing = false;
+  myEnableSketching = false;
+  myEnableTransform = true;
+  
+  setMouseTracking( true );
+  setBackgroundRole( QPalette::NoRole );
+  // set focus policy to threat QContextMenuEvent from keyboard  
+  setFocusPolicy( Qt::StrongFocus );
+  setAttribute( Qt::WA_PaintOnScreen );
+  setAttribute( Qt::WA_NoSystemBackground );
+}
+
+/*!
+    Cleans up the viewport. [ private ]
+*/
+void OCCViewer_ViewPort::cleanup()
+{
+}
+
+/*!
+    Selects visual ID for OpenGL window ( X11 specific ). [ protected ]
+*/
+void OCCViewer_ViewPort::selectVisualId()
+{
+#if !defined WNT
+       XVisualInfo* pVisualInfo;
+       if ( QX11Info::display() )
+       {
+               /* Initialization with the default VisualID */
+               Visual *v = DefaultVisual( QX11Info::display(), DefaultScreen( QX11Info::display() ) );
+               int visualID = XVisualIDFromVisual( v );
+
+               /*  Here we use the settings from Optimizer_ViewInfo::TxglCreateWindow() */
+               int visualAttr[] = { GLX_RGBA, GLX_DEPTH_SIZE, 1, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1,
+                                                        GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, None };
+
+               pVisualInfo = ::glXChooseVisual( QX11Info::display(), DefaultScreen( QX11Info::display() ), visualAttr );
+
+               if ( isVisible() )
+            hide();
+
+               XSetWindowAttributes a;
+
+               a.colormap = choose_cmap( QX11Info::display(), pVisualInfo );       /* find best colormap */
+               a.background_pixel = QColormap::instance().pixel( backgroundColor() );
+               a.border_pixel = QColormap::instance().pixel( Qt::black );
+               Window p = RootWindow( QX11Info::display(), DefaultScreen( QX11Info::display() ) );
+               if ( parentWidget() )
+            p = parentWidget()->winId();
+
+        Window w;
+       /*        if ( type == Type2D )  // creating simple X window for 2d
+        {
+            unsigned long xbackground =
+                BlackPixel( QX11Info::display(), DefaultScreen( QX11Info::display() ) );
+            unsigned long xforeground =
+                WhitePixel( QX11Info::display(), DefaultScreen( QX11Info::display() ) );
+
+            w = XCreateSimpleWindow ( QX11Info::display(), p, x(), y(), width(),
+                                      height(), 0, xforeground, xbackground );
+        }
+        else if ( type == Type3D )
+        {
+                   w = XCreateWindow( QX11Info::display(), p,  x(), y(), width(), height(),
+                               0, pVisualInfo->depth, InputOutput, pVisualInfo->visual,
+                               CWBackPixel | CWBorderPixel | CWColormap, &a );
+               }
+               else
+               return;*/
+       w = XCreateWindow( QX11Info::display(), p,  x(), y(), width(), height(),
+                          0, pVisualInfo->depth, InputOutput, pVisualInfo->visual,
+                          CWBackPixel | CWBorderPixel | CWColormap, &a );
+       
+               Window *cmw;
+               Window *cmwret;
+               int count;
+               if ( XGetWMColormapWindows( QX11Info::display(), topLevelWidget()->winId(), &cmwret, &count ) )
+               {
+                       cmw = new Window[count+1];
+                       memcpy( (char*)cmw, (char*)cmwret, sizeof(Window) * count );
+                       XFree( (char*)cmwret );
+            int i;
+
+                       for ( i = 0; i < count; i++ )
+                       {
+                               if ( cmw[i] == winId() ) /* replace old window */
+                               {
+                                       cmw[i] = w;
+                                       break;
+                               }
+                       }
+
+                       if ( i >= count )                        /* append new window */
+                               cmw[count++] = w;
+               }
+               else
+               {
+                       count = 1;
+                       cmw = new Window[count];
+                       cmw[0] = w;
+               }
+
+               /* Creating new window (with good VisualID) for this widget */
+               create(w);
+               XSetWMColormapWindows( QX11Info::display(), topLevelWidget()->winId(), cmw, count );
+               delete[] cmw;
+
+               if ( isVisible() )
+            show();
+
+               if ( pVisualInfo )
+        {
+                       XFree( (char *)pVisualInfo );
+               }
+               XFlush( QX11Info::display() );
+       }
+#endif
+}
+
+/*!
+    Sets the background 'color'. [ virtual ]
+*/
+void OCCViewer_ViewPort::setBackgroundColor( const QColor& color )
+{
+  QPalette pal = palette();
+  pal.setColor( QPalette::Background, color );
+  setPalette( pal );
+  repaint();
+  emit vpChangeBGColor( color );
+}
+
+/*!
+    Returns the background color. [ virtual ]
+*/
+QColor OCCViewer_ViewPort::backgroundColor() const
+{
+  return palette().color( QPalette::Active, QPalette::Background );
+}
+
+/*!
+    Returns 'true' if sketching is enabled in  this viewport. [ public ]
+*/
+bool OCCViewer_ViewPort::isSketchingEnabled() const
+{
+    return myEnableSketching;
+}
+
+/*!
+    Enables / disables sketching  [ public ]
+*/
+void OCCViewer_ViewPort::setSketchingEnabled( bool enable )
+{
+       myEnableSketching = enable;
+}
+
+/*!
+    Returns 'true' if transformations ( rotation, zoom etc. )
+    are enabled in this viewport. [ public ]
+*/
+bool OCCViewer_ViewPort::isTransformEnabled() const
+{
+    return myEnableTransform;
+}
+
+/*!
+    Enables / disables transformations. [ public ]
+*/
+void OCCViewer_ViewPort::setTransformEnabled( bool enable )
+{
+       myEnableTransform = enable;
+}
+
+/*!
+    Emits 'mouseEvent' signal. [ virtual protected ]
+*/
+void OCCViewer_ViewPort::mousePressEvent( QMouseEvent *e )
+{
+    emit vpMouseEvent( e );
+}
+
+/*!
+    Emits 'mouseEvent' signal. [ virtual protected ]
+*/
+void OCCViewer_ViewPort::mouseMoveEvent( QMouseEvent* e )
+{
+    emit vpMouseEvent( e );
+}
+
+/*!
+    Emits 'mouseEvent' signal. [ virtual protected ]
+*/
+void OCCViewer_ViewPort::mouseReleaseEvent( QMouseEvent *e )
+{
+    emit vpMouseEvent( e );
+}
+
+/*!
+    Emits 'mouseEvent' signal. [ virtual protected ]
+*/
+void OCCViewer_ViewPort::mouseDoubleClickEvent( QMouseEvent *e )
+{
+    emit vpMouseEvent( e );
+}
+
+/*!
+    Emits 'keyEvent' signal. [ virtual protected ]
+*/
+void OCCViewer_ViewPort::keyPressEvent( QKeyEvent *e )
+{
+    emit vpKeyEvent( e );
+}
+
+/*!
+    Emits 'keyEvent' signal. [ virtual protected ]
+*/
+void OCCViewer_ViewPort::keyReleaseEvent( QKeyEvent *e )
+{
+    emit vpKeyEvent( e );
+}
+
+/*!
+    Repaints the viewport. [ virtual protected ]
+*/
+void OCCViewer_ViewPort::paintEvent( QPaintEvent* )
+{
+       if ( myPaintersRedrawing )
+       {
+               QPainter p( this );
+               emit vpDrawExternal( &p );
+               myPaintersRedrawing = false;
+       }
+}
+
+/*!
+    Forces to redraw the viewport by an external painter. [ public ]
+*/
+void OCCViewer_ViewPort::redrawPainters()
+{
+       myPaintersRedrawing = true;
+       repaint();
+}
+
+/*!
+    Updates this view. Does nothing by default. [ virtual public ]
+*/
+void OCCViewer_ViewPort::onUpdate()
+{
+}
+
+/*!
+    Creates the popup. [ virtual protected ]
+*/
+/*void OCCViewer_ViewPort::onCreatePopup( QMenu* popup )
+{
+       if ( popup )
+       {
+               QtxAction* a = new QtxAction( "", tr( "MEN_VP_CHANGEBGR" ), 0, this );
+        a->setStatusTip( tr( "PRP_VP_CHANGEBGR" ) );
+               connect( a, SIGNAL( activated() ), SLOT( onChangeBgColor()));
+               myPopupActions.append( a );
+               a->addTo( popup );
+       }
+}*/
+
+/*!
+    Destroys the popup. [ virtual protected ]
+*/
+/*void OCCViewer_ViewPort::onDestroyPopup( QMenu* popup )
+{
+       if ( popup )
+       {
+               for ( QtxAction* a = myPopupActions.first(); a; a = myPopupActions.next() )
+                       a->removeFrom( popup );
+               myPopupActions.clear();
+       }
+}*/
+
+/*!
+    Sets the background color with color selection dialog. [ virtual protected slot ]
+*/
+void OCCViewer_ViewPort::onChangeBgColor()
+{
+    QColor selColor = QColorDialog::getColor ( backgroundColor(), this );
+    if ( selColor.isValid() )
+        setBackgroundColor( selColor );
+}
diff --git a/src/OCCViewer/OCCViewer_ViewPort.h b/src/OCCViewer/OCCViewer_ViewPort.h
new file mode 100755 (executable)
index 0000000..9bc545a
--- /dev/null
@@ -0,0 +1,122 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef OCCVIEWER_VIEWPORT_H
+#define OCCVIEWER_VIEWPORT_H
+
+#include "OCCViewer.h"
+
+#include "QtxAction.h"
+
+#include <qlist.h>
+#include <qcolor.h>
+#include <qwidget.h>
+
+#include <Aspect_Window.hxx>
+
+class QRect;
+class QCursor;
+class QPainter;
+class OCCViewer_ViewSketcher;
+class OCCViewer_ViewTransformer;
+
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
+/*!
+  \class OCCViewer_ViewPort
+  Visualisation canvas of SUIT-based application
+*/
+class OCCVIEWER_EXPORT OCCViewer_ViewPort : public QWidget
+{
+       Q_OBJECT
+
+  friend class OCCViewer_ViewSketcher;
+
+public:
+  OCCViewer_ViewPort( QWidget* parent );
+       virtual ~OCCViewer_ViewPort();
+
+public:
+       void                             setSketchingEnabled( bool );
+  bool                           isSketchingEnabled() const;
+  void                          setTransformEnabled( bool );
+  bool                           isTransformEnabled() const;
+
+  virtual QColor                        backgroundColor() const;
+  virtual void                     setBackgroundColor( const QColor& );
+
+  void                          redrawPainters();
+
+  virtual void                     onUpdate();
+
+protected:
+//     enum ViewType { Type2D, Type3D };
+       void                                     selectVisualId();
+
+// EVENTS
+       virtual void                   paintEvent( QPaintEvent *);
+       virtual void                     mouseMoveEvent( QMouseEvent *);
+       virtual void                     mouseReleaseEvent( QMouseEvent *);
+       virtual void                     mousePressEvent( QMouseEvent *);
+       virtual void                     mouseDoubleClickEvent( QMouseEvent *);
+  virtual void                     keyPressEvent( QKeyEvent *);
+  virtual void                     keyReleaseEvent( QKeyEvent *);
+
+// TO BE REDEFINED
+  virtual void                  reset() = 0;
+  virtual void                  pan( int, int ) = 0;
+       virtual void                     setCenter( int, int ) = 0;
+       virtual void                     fitRect( const QRect& ) = 0;
+  virtual void                  zoom( int, int, int, int ) = 0;
+  virtual void                  fitAll( bool keepScale = false, bool withZ = true, bool upd = true ) = 0;
+
+// POPUP
+//  void                             onCreatePopup( QMenu* );
+//     void                             onDestroyPopup( QMenu* );
+
+protected slots:
+  virtual void                  onChangeBgColor();
+
+signals:
+  void                                  vpKeyEvent( QKeyEvent* );
+  void                                  vpMouseEvent( QMouseEvent* );
+       void                                 vpDrawExternal( QPainter* );
+  void                           vpChangeBGColor( QColor );
+
+private:
+       void                             initialize();
+       void                             cleanup();
+
+protected:
+  Handle(Aspect_Window)         myWindow;
+  bool                                     myEnableSketching;
+  bool                                     myEnableTransform;
+  bool                                     myPaintersRedrawing;        /* set to draw externally */
+  QList<QtxAction*>             myPopupActions;
+
+private:
+       static int                               nCounter;                              /* objects counter */
+};
+
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
+#endif
diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx
new file mode 100755 (executable)
index 0000000..973b466
--- /dev/null
@@ -0,0 +1,505 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "OCCViewer_ViewPort3d.h"
+
+#include "OCCViewer_VService.h"
+
+#include <qrect.h>
+#include <qevent.h>
+#include <qapplication.h>
+
+#include <Visual3d_View.hxx>
+#include <V3d_PerspectiveView.hxx>
+#include <V3d_OrthographicView.hxx>
+
+#if defined WNT
+#include <WNT_Window.hxx>
+#else
+#include <Xw_Window.hxx>
+#endif
+
+/*!
+    Constructor
+*/
+OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_Viewer)& viewer, V3d_TypeOfView  type )
+: OCCViewer_ViewPort( parent ),
+myScale( 1.0 ),
+myDegenerated( true ),
+myAnimate( false ),
+myZAxis( false )
+{
+  selectVisualId();
+  setAttribute( Qt::WA_NativeWindow, true );
+  setAttribute( Qt::WA_OpaquePaintEvent, true );
+
+  if ( type == V3d_ORTHOGRAPHIC ) {
+    myOrthoView = new V3d_OrthographicView( viewer );
+    myActiveView = myOrthoView;
+    myPerspView = 0;
+  } else {
+    myPerspView = new V3d_PerspectiveView( viewer );
+    myActiveView = myPerspView;
+  }
+  if ( myDegenerated )
+    activeView()->SetDegenerateModeOn();
+}
+
+/*!
+    Destructor
+*/
+OCCViewer_ViewPort3d::~OCCViewer_ViewPort3d()
+{
+  /*Handle(V3d_View) aView = activeView();
+  if (!aView.IsNull())
+    aView->Remove();*/
+}
+
+/*!
+    Activates the desired 'type' of view in the viewer
+    ( view of 'type' is created if it doesn't exist ). [ public ]
+*/
+/*void OCCViewer_ViewPort3d::setActive( V3d_TypeOfView type )
+{
+    if ( activeView().IsNull() )
+        return;
+
+    if ( activeView()->Type() != type )
+    {
+        if ( type == V3d_ORTHOGRAPHIC )
+            setView( myOrthoView );
+        if ( type == V3d_PERSPECTIVE )
+            setView( myPerspView );
+    }
+}*/
+
+/*!
+    Maps CasCade 'view' to this viewport. [ private ]
+*/
+bool OCCViewer_ViewPort3d::mapView( const Handle(V3d_View)& view )
+{
+  if ( !setWindow( view ) )
+    return false;
+
+  if ( !mapped( view ) )
+       {
+               view->SetWindow( myWindow );
+               if ( view != activeView() )
+           view->View()->Deactivate();
+       }
+  return true;
+}
+
+/*!
+    Sets new CASCADE view on viewport. Returns the previous active view. [ public ]
+*/
+Handle( V3d_View ) OCCViewer_ViewPort3d::setView( const Handle( V3d_View )& view )
+{
+  /* map the new view */
+  if ( view == activeView() || !mapView( view ) )
+    return activeView();
+
+    /* activate the new view*/
+  Handle( V3d_View ) oldView = activeView();
+  if ( !oldView.IsNull() )
+  {
+    oldView->View()->Deactivate();
+    view->SetBackgroundColor( Quantity_NOC_BLACK );//oldView->BackgroundColor() );
+  }
+  if ( myDegenerated )
+    view->SetDegenerateModeOn();
+  else
+    view->SetDegenerateModeOff();
+
+  view->View()->Activate();
+  activeView() = view;
+  return oldView;
+}
+
+/*!
+    Returns CasCade 3D view. [ public ]
+*/
+Handle(V3d_View) OCCViewer_ViewPort3d::getView() const
+{
+       return activeView();
+}
+
+/*!
+    Returns CasCade 3D viewer [ public ]
+*/
+Handle(V3d_Viewer) OCCViewer_ViewPort3d::getViewer() const
+{
+       Handle(V3d_Viewer) viewer;
+       if ( !activeView().IsNull() )
+    viewer = activeView()->Viewer();
+       return viewer;
+}
+
+/*!
+    Syncronizes visual state of this viewport with 'ref'
+    ( scale, projection, eye etc ) Returns 'true' if copied OK,
+    'false' otherwise. [ virtual public ]
+*/
+bool OCCViewer_ViewPort3d::syncronize( const OCCViewer_ViewPort3d* ref )
+{
+  OCCViewer_ViewPort3d* ref3d = (OCCViewer_ViewPort3d*)ref;
+  Handle(V3d_View) refView = ref3d->getView();
+  Handle(V3d_View) tgtView = getView();
+
+  /* Syncronize view types */
+/*    if ( tgtView->Type() != refView->Type() )
+  {
+      setActive( refView->Type() );
+      tgtView = getView();
+  }*/
+
+  /*  The following params are copied:
+      - view type( ortho/persp )
+      - position of view point
+      - orientation of high point
+      - position of the eye
+      - projection vector
+      - view center ( 2D )
+      - view twist
+      - view scale
+  */
+
+  /* we'll update after setting all params */
+  tgtView->SetImmediateUpdate( Standard_False );
+
+  /* perspective */
+  if ( refView->Type() == V3d_PERSPECTIVE )
+      tgtView->SetFocale( refView->Focale() );
+
+  /* copy params */
+  Standard_Real x, y, z;
+  refView->At( x, y, z ); tgtView->SetAt( x, y, z );
+  refView->Up( x, y, z ); tgtView->SetUp( x, y, z );
+  refView->Eye( x, y, z ); tgtView->SetEye( x, y, z );
+  refView->Proj( x, y, z ); tgtView->SetProj( x, y, z );
+  refView->Center( x, y ); tgtView->SetCenter( x, y );
+  tgtView->SetScale( refView->Scale() );
+  tgtView->SetTwist( refView->Twist() );
+
+  /* update */
+  tgtView->Update();
+  tgtView->SetImmediateUpdate( Standard_True );
+  return true;
+}
+
+/*!
+    Returns Z-size of this view. [ public ]
+*/
+double OCCViewer_ViewPort3d::getZSize() const
+{
+  if ( !activeView().IsNull() )
+    return activeView()->ZSize();
+  return 0;
+}
+
+/*!
+    Sets Z-size of this view ( for both orthographic and perspective ). [ public ]
+*/
+void OCCViewer_ViewPort3d::setZSize( double zsize )
+{
+  myActiveView->SetZSize( zsize );
+/*    if ( !myOrthoView.IsNull() )
+        myOrthoView->SetZSize( zsize );
+    if ( !myPerspView.IsNull() )
+        myPerspView->SetZSize( zsize );*/
+}
+
+/*!
+    Returns the background color [ virtual public ]
+*/
+QColor OCCViewer_ViewPort3d::backgroundColor() const
+{
+       if ( !activeView().IsNull() )
+       {
+               Standard_Real aRed, aGreen, aBlue;
+               activeView()->BackgroundColor( Quantity_TOC_RGB, aRed, aGreen, aBlue );
+               int red = (int) (aRed * 255);
+               int green = (int) (aGreen * 255);
+               int blue = (int) (aBlue * 255);
+               return QColor( red, green, blue );
+       }
+       return OCCViewer_ViewPort::backgroundColor();
+}
+
+/*!
+    Sets the background color [ virtual public ]
+*/
+void OCCViewer_ViewPort3d::setBackgroundColor( const QColor& color )
+{
+       if ( !activeView().IsNull() )
+       {
+               activeView()->SetBackgroundColor( Quantity_TOC_RGB, color.red()/255.,
+                                                                                                 color.green()/255., color.blue()/255.);
+               activeView()->Update();
+    emit vpChangeBGColor( color );
+       }
+}
+
+/*!
+  Set animation mode
+  \param theDegenerated - degenerated mode
+*/
+void OCCViewer_ViewPort3d::setAnimationMode(bool theDegenerated)
+{
+       if ( !activeView().IsNull() )
+       {
+    myAnimate = theDegenerated;
+    activeView()->SetAnimationMode(true, theDegenerated);
+  }
+}
+
+/*!
+    Updates the active viewport. [ virtual public ]
+*/
+void OCCViewer_ViewPort3d::onUpdate()
+{
+  if ( !activeView().IsNull() )
+    activeView()->Update();
+}
+
+/*!
+    Called at 'window fit' transformation. [ virtual protected ]
+*/
+void OCCViewer_ViewPort3d::fitRect( const QRect& rect )
+{
+       if ( !activeView().IsNull() )
+         activeView()->WindowFit( rect.left(), rect.top(), rect.right(), rect.bottom() );
+}
+
+/*!
+    Called at 'zoom' transformation. [ virtual protected ]
+*/
+void OCCViewer_ViewPort3d::zoom( int x0, int y0, int x, int y )
+{
+       if ( !activeView().IsNull() )
+           activeView()->Zoom( x0, y0, x, y );
+}
+
+/*!
+    Centers the viewport. [ virtual protected ]
+*/
+void OCCViewer_ViewPort3d::setCenter( int x, int y )
+{
+       if ( !activeView().IsNull() )
+           activeView()->Place( x, y, myScale );
+}
+
+/*!
+    Called at 'pan' transformation. [ virtual protected ]
+*/
+void OCCViewer_ViewPort3d::pan( int dx, int dy )
+{
+       if ( !activeView().IsNull() )
+        activeView()->Pan( dx, dy, 1.0 );
+}
+
+/*!
+    Inits 'rotation' transformation. [ protected ]
+*/
+void OCCViewer_ViewPort3d::startRotation( int x, int y )
+{
+       if ( !activeView().IsNull() )
+  {
+               myDegenerated = activeView()->DegenerateModeIsOn();
+               activeView()->SetDegenerateModeOn();
+    if (myAnimate) activeView()->SetAnimationModeOn();
+
+    if( !myZAxis )
+      activeView()->StartRotation( x, y, 0.45 );
+    else
+    {
+      myX0 = x; myY0 = y;
+      V3d_Coordinate exx, eyy;
+      activeView()->Project( 0.0, 0.0, 0.0, exx, eyy );
+      activeView()->Convert( exx, eyy, myXc, myYc );
+      //cout << myXc << "; " << myYc << endl;
+      activeView()->Rotate( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Standard_True );
+    }
+       }
+}
+
+/*!
+    Rotates the viewport. [ protected ]
+*/
+void OCCViewer_ViewPort3d::rotate( int x, int y )
+{
+  if( !myZAxis )
+         activeView()->Rotation( x, y );
+  else
+  {
+    double angle = 0.0, c, s;
+    gp_Vec v1, v2;
+    if( ( x!=myXc || y!=myYc ) && ( myX0!=myXc || myY0!=myYc ) )
+    {
+      v1 = gp_Vec( myX0-myXc, myY0-myYc, 0.0 );
+      v2 = gp_Vec( x-myXc, y-myYc, 0.0 );
+      c = v1.Dot( v2 ) / v1.Magnitude() / v2.Magnitude();
+      s = v1.Crossed( v2 ).Z() / v1.Magnitude() / v2.Magnitude();
+      angle = acos( c );
+      if( s<0 )
+        angle = -angle;
+    }
+    activeView()->Rotate( 0.0, 0.0, angle, 0.0, 0.0, 0.0, Standard_False );
+  }
+}
+
+/*!
+    Resets the viewport after 'rotation'. [ protected ]
+*/
+void OCCViewer_ViewPort3d::endRotation()
+{
+       if ( !activeView().IsNull() )
+  {
+    if (myAnimate) activeView()->SetAnimationModeOff();
+               if ( !myDegenerated )
+      activeView()->SetDegenerateModeOff();
+    activeView()->ZFitAll(1.);
+    activeView()->SetZSize(0.);
+    activeView()->Update();
+       }
+}
+
+/*!
+    Repaints the viewport. [ virtual protected ]
+*/
+void OCCViewer_ViewPort3d::paintEvent( QPaintEvent* e )
+{
+#ifndef WNT
+       /* X11 : map before show doesn't work */
+       if ( !mapped( activeView() ) )
+         mapView( activeView() );
+#endif
+       if ( !myWindow.IsNull() )
+       {
+         QApplication::syncX();
+         QRect rc = e->rect();
+         if ( !myPaintersRedrawing )
+           activeView()->Redraw( rc.x(), rc.y(), rc.width(), rc.height() );
+       }
+       OCCViewer_ViewPort::paintEvent( e );
+}
+
+/*!
+    Resizes the viewport. [ virtual protected ]
+*/
+void OCCViewer_ViewPort3d::resizeEvent( QResizeEvent* e )
+{
+#ifdef WNT
+       /* Win32 : map before first show to avoid flicker */
+       if ( !mapped( activeView() ) )
+           mapView( activeView() );
+#endif
+    QApplication::syncX();
+    if ( !activeView().IsNull() )
+        activeView()->MustBeResized();
+}
+
+/*!
+    Fits all objects in view. [ virtual protected ]
+*/
+void OCCViewer_ViewPort3d::fitAll( bool keepScale, bool withZ, bool upd )
+{
+  if ( activeView().IsNull() )
+    return;
+
+  if ( keepScale )
+    myScale = activeView()->Scale();
+
+  Standard_Real margin = 0.01;
+  activeView()->FitAll( margin, withZ, upd );
+  activeView()->SetZSize(0.);
+}
+
+/*!
+    Resets the view. [ virtual protected ]
+*/
+void OCCViewer_ViewPort3d::reset()
+{
+//  double zsize = getZSize();
+       if ( !activeView().IsNull() )
+        activeView()->Reset();
+//    setZSize( zsize );
+}
+
+/*!
+    Passed the handle of native window of the component to CASCADE view. [ private ]
+*/
+bool OCCViewer_ViewPort3d::setWindow( const Handle(V3d_View)& view )
+{
+       if ( !myWindow.IsNull() )
+               return true;
+
+       if ( view.IsNull() )
+               return false;
+
+       int hwnd = (int)winId();
+       if ( !hwnd )
+        return false;
+
+       /* set this widget as the drawing window */
+       short lo = (short)(hwnd);
+       short hi = (short)( hwnd >> 16 );
+       printf( "%i %i\n", lo, hi );
+        attachWindow( view, OCCViewer_VService::CreateWindow( view, (int)hi, (int)lo, Xw_WQ_SAMEQUALITY ) );
+
+        myWindow = view->Window();
+        return !myWindow.IsNull();
+}
+
+void OCCViewer_ViewPort3d::attachWindow( const Handle(V3d_View)& view,
+                                         const Handle(Aspect_Window)& window)
+{
+  if (!view.IsNull()) {
+    view->SetWindow( window );
+    //updateBackground();
+  }
+}
+
+/*!
+       Returns the current active view. [ private ]
+*/
+Handle(V3d_View) OCCViewer_ViewPort3d::activeView() const
+{
+       return myActiveView;
+}
+
+/*!
+       Returns the current inactive view [ private ]
+*/
+/*Handle(V3d_View) OCCViewer_ViewPort3d::inactiveView() const
+{
+       return ( activeView() == myOrthoView ? myPerspView : myOrthoView );
+}*/
+
+/*!
+       Returns 'true' if the given view is mapped to window. [ private ]
+*/
+bool OCCViewer_ViewPort3d::mapped( const Handle(V3d_View)& view ) const
+{
+       return ( !view.IsNull() && view->View()->IsDefined() );
+}
+void OCCViewer_ViewPort3d::fixZRotAxis( const bool on )
+{
+  myZAxis = on;
+}
diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.h b/src/OCCViewer/OCCViewer_ViewPort3d.h
new file mode 100755 (executable)
index 0000000..0845028
--- /dev/null
@@ -0,0 +1,106 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef OCCVIEWER_VIEWPORT3D_H
+#define OCCVIEWER_VIEWPORT3D_H
+
+#include "OCCViewer_ViewPort.h"
+
+#include <qcolor.h>
+
+#include <V3d_View.hxx>
+#include <V3d_Viewer.hxx>
+
+class QRect;
+
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
+class OCCVIEWER_EXPORT OCCViewer_ViewPort3d: public OCCViewer_ViewPort
+{
+       Q_OBJECT
+
+  friend class OCCViewer_ViewTransformer;
+
+public:
+       OCCViewer_ViewPort3d( QWidget*, const Handle(V3d_Viewer)&, V3d_TypeOfView = V3d_ORTHOGRAPHIC );
+       virtual ~OCCViewer_ViewPort3d();
+
+public:
+       Handle(V3d_View)        getView() const;
+  Handle(V3d_View)                 setView( const Handle(V3d_View)& );
+       Handle(V3d_Viewer)      getViewer() const;
+
+  void setAnimationMode(bool theDegenerated);
+
+       virtual void                    setBackgroundColor( const QColor& color);
+  virtual QColor       backgroundColor() const;
+
+//   void         setActive( V3d_TypeOfView );
+  virtual bool syncronize( const OCCViewer_ViewPort3d* );
+
+  double getZSize() const;
+  void   setZSize( double );
+
+  virtual void onUpdate();
+
+  // TRANSFORMATIONS
+  virtual void         reset();
+  virtual void         pan( int , int );
+       virtual void            setCenter( int , int );
+       virtual void            fitRect( const QRect& );
+       virtual void            zoom( int, int, int, int );
+  virtual void         fitAll( bool keepScale = false, bool withZ = true, bool upd = true );
+
+       void                    startRotation( int, int );
+       void                    rotate( int, int );
+       void                    endRotation();
+
+  void fixZRotAxis( const bool );
+
+protected:
+    // EVENTS
+       virtual void                    paintEvent( QPaintEvent* );
+  virtual void      resizeEvent( QResizeEvent* );
+
+  void attachWindow( const Handle(V3d_View)&, const Handle(Aspect_Window)& );
+
+private:
+       Handle(V3d_View) activeView() const;
+       Handle(V3d_View) inactiveView() const;
+       bool mapView( const Handle(V3d_View)& );
+       bool setWindow( const Handle(V3d_View)& );
+       bool mapped( const Handle(V3d_View)& ) const;
+
+private:
+  Handle(V3d_View)             myOrthoView;
+  Handle(V3d_View)             myPerspView;
+  Handle(V3d_View)             myActiveView;
+       bool            myDegenerated;
+  bool    myAnimate;
+       double  myScale;
+  bool    myZAxis;
+  int myX0, myY0, myXc, myYc;
+};
+
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
+#endif
diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx
new file mode 100755 (executable)
index 0000000..e62b48c
--- /dev/null
@@ -0,0 +1,1094 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// OCCViewer_ViewWindow.cxx: implementation of the OCCViewer_ViewWindow class.
+
+
+#include "OCCViewer_ViewWindow.h"
+#include "OCCViewer_ViewModel.h"
+#include "OCCViewer_ViewPort3d.h"
+#include "OCCViewer_CreateRestoreViewDlg.h"
+#include "OCCViewer_ClippingDlg.h"
+
+#include "SUIT_Desktop.h"
+#include "SUIT_Session.h"
+#include "SUIT_Tools.h"
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_MessageBox.h"
+#include "SUIT_ViewManager.h"
+
+#include <QtxActionToolMgr.h>
+#include <QtxMultiAction.h>
+
+#include <QToolBar>
+#include <QMouseEvent>
+#include <QPainter>
+#include <QTime>
+
+#include <V3d_Plane.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pln.hxx>
+
+const char* imageZoomCursor[] = { 
+"32 32 3 1",
+". c None",
+"a c #000000",
+"# c #ffffff",
+"................................",
+"................................",
+".#######........................",
+"..aaaaaaa.......................",
+"................................",
+".............#####..............",
+"...........##.aaaa##............",
+"..........#.aa.....a#...........",
+".........#.a.........#..........",
+".........#a..........#a.........",
+"........#.a...........#.........",
+"........#a............#a........",
+"........#a............#a........",
+"........#a............#a........",
+"........#a............#a........",
+".........#...........#.a........",
+".........#a..........#a.........",
+".........##.........#.a.........",
+"........#####.....##.a..........",
+".......###aaa#####.aa...........",
+"......###aa...aaaaa.......#.....",
+".....###aa................#a....",
+"....###aa.................#a....",
+"...###aa...............#######..",
+"....#aa.................aa#aaaa.",
+".....a....................#a....",
+"..........................#a....",
+"...........................a....",
+"................................",
+"................................",
+"................................",
+"................................"};
+
+const char* imageRotateCursor[] = { 
+"32 32 3 1",
+". c None",
+"a c #000000",
+"# c #ffffff",
+"................................",
+"................................",
+"................................",
+"................................",
+"........#.......................",
+".......#.a......................",
+"......#######...................",
+".......#aaaaa#####..............",
+"........#..##.a#aa##........##..",
+".........a#.aa..#..a#.....##.aa.",
+".........#.a.....#...#..##.aa...",
+".........#a.......#..###.aa.....",
+"........#.a.......#a..#aa.......",
+"........#a.........#..#a........",
+"........#a.........#a.#a........",
+"........#a.........#a.#a........",
+"........#a.........#a.#a........",
+".........#.........#a#.a........",
+"........##a........#a#a.........",
+"......##.a#.......#.#.a.........",
+"....##.aa..##.....##.a..........",
+"..##.aa.....a#####.aa...........",
+"...aa.........aaa#a.............",
+"................#.a.............",
+"...............#.a..............",
+"..............#.a...............",
+"...............a................",
+"................................",
+"................................",
+"................................",
+"................................",
+"................................"};
+
+const char* imageCrossCursor[] = { 
+  "32 32 3 1",
+  ". c None",
+  "a c #000000",
+  "# c #ffffff",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "...............#................",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  ".......#################........",
+  "........aaaaaaa#aaaaaaaaa.......",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "...............#a...............",
+  "................a...............",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................",
+  "................................"};
+
+
+/*!
+  Constructor
+  \param theDesktop - main window of application
+  \param theModel - OCC 3D viewer
+*/
+OCCViewer_ViewWindow::OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel)
+: SUIT_ViewWindow(theDesktop)
+{
+  myModel = theModel;
+  myRestoreFlag = 0;
+  myEnableDrawMode = false;
+  updateEnabledDrawMode();
+  myClippingDlg = 0;
+  myToolbarId = -1;
+}
+
+/*!
+  Initialization of view window
+*/
+void OCCViewer_ViewWindow::initLayout()
+{
+  myViewPort = new OCCViewer_ViewPort3d( this, myModel->getViewer3d(), V3d_ORTHOGRAPHIC );
+  //myViewPort->setBackgroundColor(Qt::black);
+  myViewPort->installEventFilter(this);
+  setCentralWidget(myViewPort);
+  myOperation = NOTHING;
+
+  setTransformRequested ( NOTHING );
+  setTransformInProcess ( false );
+
+  createActions();
+  createToolBar();
+}
+
+/*!
+  \return type of operation by states of mouse and keyboard buttons
+  \param theEvent - mouse event
+*/
+OCCViewer_ViewWindow::OperationType OCCViewer_ViewWindow::getButtonState(QMouseEvent* theEvent)
+{
+  OperationType aOp = NOTHING;
+  if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[SUIT_ViewModel::ZOOM]) &&
+      (theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::ZOOM]) )
+    aOp = ZOOMVIEW;
+  else if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[SUIT_ViewModel::PAN]) && 
+           (theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::PAN]) )
+    aOp = PANVIEW;
+  else if( (theEvent->modifiers()  == SUIT_ViewModel::myStateMap[SUIT_ViewModel::ROTATE]) &&
+           (theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::ROTATE]) )
+    aOp = ROTATE;
+
+  return aOp;
+}
+
+/*!
+  Custom event handler
+*/
+bool OCCViewer_ViewWindow::eventFilter(QObject* watched, QEvent* e)
+{
+  if ( watched == myViewPort ) {
+    int aType = e->type();
+    switch(aType) {
+    case QEvent::MouseButtonPress:
+      vpMousePressEvent((QMouseEvent*) e);
+      return true;
+
+    case QEvent::MouseButtonRelease:
+      vpMouseReleaseEvent((QMouseEvent*) e);
+      return true;
+
+    case QEvent::MouseMove:
+      vpMouseMoveEvent((QMouseEvent*) e);
+      return true;
+
+    case QEvent::MouseButtonDblClick:
+      emit mouseDoubleClicked(this, (QMouseEvent*)e);
+      return true;
+
+    case QEvent::Wheel:
+      {
+        QWheelEvent* aEvent = (QWheelEvent*) e;
+        double aDelta = aEvent->delta();
+        double aScale = (aDelta < 0) ? 100./(-aDelta) : aDelta/100.; 
+        myViewPort->getView()->SetZoom(aScale);
+      }
+      return true;
+
+    case QEvent::ContextMenu:
+      {
+        QContextMenuEvent * aEvent = (QContextMenuEvent*)e;
+        if ( aEvent->reason() != QContextMenuEvent::Mouse )
+          emit contextMenuRequested( aEvent );
+      }
+      return true;
+
+    default:
+      break;
+    }
+  }
+  return SUIT_ViewWindow::eventFilter(watched, e);
+}
+
+/*!
+  Updates state of enable draw mode state
+*/
+void OCCViewer_ViewWindow::updateEnabledDrawMode()
+{
+  if ( myModel )
+    myEnableDrawMode = myModel->isSelectionEnabled() && myModel->isMultiSelectionEnabled();
+}
+
+/*!
+  Handler of mouse press event
+*/
+void OCCViewer_ViewWindow::vpMousePressEvent(QMouseEvent* theEvent)
+{
+  myStartX = theEvent->x();
+  myStartY = theEvent->y();
+  switch ( myOperation ) {
+  case WINDOWFIT:
+    if ( theEvent->button() == Qt::LeftButton )
+      emit vpTransformationStarted ( WINDOWFIT );
+    break;    
+   
+  case PANGLOBAL:
+    if ( theEvent->button() == Qt::LeftButton )
+      emit vpTransformationStarted ( PANGLOBAL );
+    break;    
+    
+  case ZOOMVIEW:
+    if ( theEvent->button() == Qt::LeftButton )
+      emit vpTransformationStarted ( ZOOMVIEW );
+    break;
+    
+  case PANVIEW:
+    if ( theEvent->button() == Qt::LeftButton )
+      emit vpTransformationStarted ( PANVIEW );
+    break;
+
+  case ROTATE:
+    if ( theEvent->button() == Qt::LeftButton ) {
+           myViewPort->startRotation(myStartX, myStartY);
+           emit vpTransformationStarted ( ROTATE );
+         }
+    break;
+      
+  default:
+  /*  Try to activate a transformation */
+    switch ( getButtonState(theEvent) ) {
+    case ZOOMVIEW:
+           activateZoom();
+      break;
+    case PANVIEW:
+           activatePanning();
+      break;
+    case ROTATE:
+           activateRotation();
+           myViewPort->startRotation(myStartX, myStartY);
+      break;
+    default:
+      emit mousePressed(this, theEvent);
+      break;
+    }
+    /* notify that we start a transformation */
+    if ( transformRequested() ) 
+           emit vpTransformationStarted ( myOperation );
+  }
+  if ( transformRequested() ) 
+    setTransformInProcess( true );              
+}
+
+
+/*!
+  Starts zoom operation, sets corresponding cursor
+*/
+void OCCViewer_ViewWindow::activateZoom()
+{
+  if ( !transformRequested() && !myCursorIsHand )
+    myCursor = cursor();               /* save old cursor */
+  
+  if ( myOperation != ZOOMVIEW ) {
+    QPixmap zoomPixmap (imageZoomCursor);
+    QCursor zoomCursor (zoomPixmap);
+    setTransformRequested ( ZOOMVIEW );                
+    setCursor( zoomCursor );
+  }
+}
+
+
+/*!
+  Starts panning operation, sets corresponding cursor
+*/
+void OCCViewer_ViewWindow::activatePanning()
+{
+  if ( !transformRequested() && !myCursorIsHand )
+    myCursor = cursor();               // save old cursor 
+  
+  if ( myOperation != PANVIEW ) {
+    QCursor panCursor (Qt::SizeAllCursor);
+    setTransformRequested ( PANVIEW );
+    setCursor( panCursor );
+  }
+}
+
+/*!
+  Starts rotation operation, sets corresponding cursor
+*/
+void OCCViewer_ViewWindow::activateRotation()
+{
+  if ( !transformRequested() && !myCursorIsHand )
+    myCursor = cursor();               // save old cursor 
+  
+  if ( myOperation != ROTATE ) {
+    QPixmap rotatePixmap (imageRotateCursor);
+    QCursor rotCursor (rotatePixmap);
+    setTransformRequested ( ROTATE );
+    setCursor( rotCursor );    
+  }
+}
+
+/*!
+  Starts global panning operation, sets corresponding cursor
+*/
+void OCCViewer_ViewWindow::activateGlobalPanning()
+{
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) {
+    QPixmap globalPanPixmap (imageCrossCursor);
+    QCursor glPanCursor (globalPanPixmap);
+    myCurScale = aView3d->Scale();
+    aView3d->FitAll(0.01, false);
+    myCursor = cursor();               // save old cursor 
+    myViewPort->fitAll(); // fits view before selecting a new scene center 
+    setTransformRequested( PANGLOBAL );
+    setCursor( glPanCursor );
+  }
+}
+
+/*!
+  Starts fit operation, sets corresponding cursor
+*/
+void OCCViewer_ViewWindow::activateWindowFit()
+{
+  if ( !transformRequested() && !myCursorIsHand )
+    myCursor = cursor();               /* save old cursor */
+
+  if ( myOperation != WINDOWFIT ) {
+    QCursor handCursor (Qt::PointingHandCursor);
+    setTransformRequested ( WINDOWFIT );               
+    setCursor ( handCursor );
+    myCursorIsHand = true;
+  }
+}
+
+/*!
+  Stores which viewer operation is requesting
+*/
+void OCCViewer_ViewWindow::setTransformRequested ( OperationType op )
+{    
+  myOperation = op;
+  myViewPort->setMouseTracking( myOperation == NOTHING );  
+}
+
+
+/*!
+  Handler of mouse move event
+*/
+void OCCViewer_ViewWindow::vpMouseMoveEvent(QMouseEvent* theEvent)
+{
+  myCurrX = theEvent->x();
+  myCurrY = theEvent->y();
+  switch (myOperation) {
+  case ROTATE:
+    myViewPort->rotate(myCurrX, myCurrY);
+    break;
+    
+  case ZOOMVIEW:
+    myViewPort->zoom(myStartX, myStartY, myCurrX, myCurrY);
+    myStartX = myCurrX;
+    myStartY = myCurrY;
+    break;
+    
+  case PANVIEW:
+    myViewPort->pan(myCurrX - myStartX, myStartY - myCurrY);
+    myStartX = myCurrX;
+    myStartY = myCurrY;
+    break;
+    
+/*    case WINDOWFIT:
+    myDrawRect = true;
+    repaint();
+    break;
+*/      
+  case PANGLOBAL:
+    break;
+    
+  default:
+    int aState = theEvent->modifiers();
+    int aButton = theEvent->button();
+    if ( aButton == Qt::LeftButton )
+    {
+      myDrawRect = myEnableDrawMode;
+      if ( myDrawRect ) {
+        drawRect();
+           if ( !myCursorIsHand )      {   // we are going to sketch a rectangle
+        QCursor handCursor (Qt::PointingHandCursor);
+         myCursorIsHand = true;                
+         myCursor = cursor();
+         setCursor( handCursor );
+       }
+      }
+    } 
+    else {
+      emit mouseMoving( this, theEvent ); 
+    }          
+  }
+}
+
+/*!
+  Handler of mouse release event
+*/
+void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent)
+{
+  switch ( myOperation ) {
+  case NOTHING:
+    {
+      emit mouseReleased(this, theEvent);
+      if(theEvent->button() == Qt::RightButton)
+      {
+        QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
+                                  theEvent->pos(), theEvent->globalPos(),
+                                  theEvent->modifiers() );
+        emit contextMenuRequested( &aEvent );
+      }
+    }
+    break;
+  case ROTATE:
+    myViewPort->endRotation();
+    resetState();
+    break;
+    
+  case PANVIEW:
+  case ZOOMVIEW:
+    resetState();
+    break;
+    
+  case PANGLOBAL:
+    if ( theEvent->button() == Qt::LeftButton ) {
+           myViewPort->setCenter( theEvent->x(), theEvent->y() );
+      myViewPort->getView()->SetScale(myCurScale);
+           resetState();
+         }
+    break;
+      
+  case WINDOWFIT:
+    if ( theEvent->button() == Qt::LeftButton ) {
+           myCurrX = theEvent->x();
+           myCurrY = theEvent->y();
+           QRect rect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);
+           if ( !rect.isEmpty() ) myViewPort->fitRect(rect);
+           resetState();
+         }
+    break;
+  }
+  
+  // NOTE: viewer 3D detects a rectangle of selection using this event
+  // so we must emit it BEFORE resetting the selection rectangle
+  
+  if ( theEvent->button() == Qt::LeftButton && myDrawRect ) {
+    myDrawRect = false;
+    drawRect();
+    resetState(); 
+    myViewPort->update();
+  }
+}
+
+/*!
+  Sets the viewport to its initial state
+  ( no transformations in process etc. )
+*/
+void OCCViewer_ViewWindow::resetState()
+{
+  myDrawRect = false;
+  
+  /* make rectangle empty (left > right) */
+  myRect.setLeft(2);
+  myRect.setRight(0);
+  
+  if ( transformRequested() || myCursorIsHand ) 
+    setCursor( myCursor );
+  myCursorIsHand = false;
+  
+  if ( transformRequested() ) 
+    emit vpTransformationFinished (myOperation);
+  
+  setTransformInProcess( false );              
+  setTransformRequested( NOTHING );    
+}
+
+
+/*!
+  Draws rectangle by starting and current points
+*/
+void OCCViewer_ViewWindow::drawRect()
+{
+  QPainter aPainter(myViewPort);
+  aPainter.setCompositionMode( QPainter::RasterOp_SourceXorDestination );
+  aPainter.setPen(Qt::white);
+  QRect aRect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);
+  if ( !myRect.isEmpty() )
+         aPainter.drawRect( myRect );
+  aPainter.drawRect(aRect);
+  myRect = aRect;
+}
+
+/*!
+  Creates actions of OCC view window
+*/
+void OCCViewer_ViewWindow::createActions()
+{
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  
+  QtxAction* aAction;
+
+  // Dump view
+  aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_DUMP" ) ),
+                           tr( "MNU_DUMP_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView()));
+       toolMgr()->registerAction( aAction, DumpId );
+
+  // FitAll
+  aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITALL" ) ),
+                           tr( "MNU_FITALL" ), 0, this);
+  aAction->setStatusTip(tr("DSC_FITALL"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(onFitAll()));
+       toolMgr()->registerAction( aAction, FitAllId );
+
+  // FitRect
+  aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITAREA" ) ),
+                           tr( "MNU_FITRECT" ), 0, this);
+  aAction->setStatusTip(tr("DSC_FITRECT"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
+       toolMgr()->registerAction( aAction, FitRectId );
+
+  // Zoom
+  aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ZOOM" ) ),
+                           tr( "MNU_ZOOM_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(activateZoom()));
+       toolMgr()->registerAction( aAction, ZoomId );
+
+  // Panning
+  aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_PAN" ) ),
+                           tr( "MNU_PAN_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_PAN_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(activatePanning()));
+       toolMgr()->registerAction( aAction, PanId );
+
+  // Global Panning
+  aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_GLOBALPAN" ) ),
+                           tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
+       toolMgr()->registerAction( aAction, GlobalPanId );
+
+  // Rotation
+  aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATE" ) ),
+                           tr( "MNU_ROTATE_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(activateRotation()));
+       toolMgr()->registerAction( aAction, RotationId );
+
+  // Projections
+  aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FRONT" ) ),
+                           tr( "MNU_FRONT_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_FRONT_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(onFrontView()));
+       toolMgr()->registerAction( aAction, FrontId );
+
+  aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BACK" ) ),
+                           tr( "MNU_BACK_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_BACK_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(onBackView()));
+       toolMgr()->registerAction( aAction, BackId );
+
+  aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TOP" ) ),
+                           tr( "MNU_TOP_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_TOP_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(onTopView()));
+       toolMgr()->registerAction( aAction, TopId );
+
+  aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BOTTOM" ) ),
+                           tr( "MNU_BOTTOM_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(onBottomView()));
+       toolMgr()->registerAction( aAction, BottomId );
+
+  aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_LEFT" ) ),
+                           tr( "MNU_LEFT_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_LEFT_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(onLeftView()));
+       toolMgr()->registerAction( aAction, LeftId );
+
+  aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RIGHT" ) ),
+                           tr( "MNU_RIGHT_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(onRightView()));
+  toolMgr()->registerAction( aAction, RightId );
+
+  // Reset
+  aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RESET" ) ),
+                           tr( "MNU_RESET_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_RESET_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(onResetView()));
+       toolMgr()->registerAction( aAction, ResetId );
+
+  // Reset
+  aAction = new QtxAction(tr("MNU_CLONE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLONE_VIEW" ) ),
+                           tr( "MNU_CLONE_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_CLONE_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(onCloneView()));
+       toolMgr()->registerAction( aAction, CloneId );
+
+  myClippingAction = new QtxAction(tr("MNU_CLIPPING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" ) ),
+                           tr( "MNU_CLIPPING" ), 0, this);
+  myClippingAction->setStatusTip(tr("DSC_CLIPPING"));
+  myClippingAction->setCheckable( true );
+  connect(myClippingAction, SIGNAL(toggled( bool )), this, SLOT(onClipping( bool )));
+       toolMgr()->registerAction( myClippingAction, ClippingId );
+
+  aAction = new QtxAction(tr("MNU_SHOOT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SHOOT_VIEW" ) ),
+                           tr( "MNU_SHOOT_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_SHOOT_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(onMemorizeView()));
+       toolMgr()->registerAction( aAction, MemId );
+
+  aAction = new QtxAction(tr("MNU_PRESETS_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESETS_VIEW" ) ),
+                           tr( "MNU_PRESETS_VIEW" ), 0, this);
+  aAction->setStatusTip(tr("DSC_PRESETS_VIEW"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(onRestoreView()));
+       toolMgr()->registerAction( aAction, RestoreId );
+
+  if (myModel->trihedronActivated()) {
+    aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TRIHEDRON" ) ),
+                             tr( "MNU_SHOW_TRIHEDRE" ), 0, this);
+    aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRE"));
+    connect(aAction, SIGNAL(activated()), this, SLOT(onTrihedronShow()));
+         toolMgr()->registerAction( aAction, TrihedronShowId );
+  }
+}
+
+/*!
+  Creates toolbar of OCC view window
+*/
+void OCCViewer_ViewWindow::createToolBar()
+{
+  myToolbarId = toolMgr()->createToolBar( tr( "LBL_TOOLBAR_LABEL" ), false );
+
+  toolMgr()->insert( DumpId, myToolbarId );
+  if ( myModel->trihedronActivated() ) 
+    toolMgr()->insert( TrihedronShowId, myToolbarId );
+
+  QtxMultiAction* aScaleAction = new QtxMultiAction( this );
+  aScaleAction->insertAction( toolMgr()->action( FitAllId ) );
+  aScaleAction->insertAction( toolMgr()->action( FitRectId ) );
+  aScaleAction->insertAction( toolMgr()->action( ZoomId ) );
+  toolMgr()->insert( aScaleAction, myToolbarId );
+
+  QtxMultiAction* aPanningAction = new QtxMultiAction( this );
+  aPanningAction->insertAction( toolMgr()->action( PanId ) );
+  aPanningAction->insertAction( toolMgr()->action( GlobalPanId ) );
+  toolMgr()->insert( aPanningAction, myToolbarId );
+
+  toolMgr()->insert( RotationId, myToolbarId );
+
+  QtxMultiAction* aViewsAction = new QtxMultiAction( this );
+  aViewsAction->insertAction( toolMgr()->action( FrontId ) );
+  aViewsAction->insertAction( toolMgr()->action( BackId ) );
+  aViewsAction->insertAction( toolMgr()->action( TopId ) );
+  aViewsAction->insertAction( toolMgr()->action( BottomId ) );
+  aViewsAction->insertAction( toolMgr()->action( LeftId ) );
+  aViewsAction->insertAction( toolMgr()->action( RightId ) );
+  toolMgr()->insert( aViewsAction, myToolbarId );
+
+  toolMgr()->insert( ResetId, myToolbarId );
+
+  QtxMultiAction* aMemAction = new QtxMultiAction( this );
+  aMemAction->insertAction( toolMgr()->action( MemId ) );
+  aMemAction->insertAction( toolMgr()->action( RestoreId ) );
+  toolMgr()->insert( toolMgr()->separator(), myToolbarId );
+  toolMgr()->insert( CloneId, myToolbarId );
+  toolMgr()->insert( toolMgr()->separator(), myToolbarId );
+  toolMgr()->insert( ClippingId, myToolbarId );
+}
+
+/*!
+  Processes operation fit all
+*/
+void OCCViewer_ViewWindow::onViewFitAll()
+{
+  myViewPort->fitAll();
+}
+
+/*!
+  Processes transformation "front view"
+*/
+void OCCViewer_ViewWindow::onFrontView()
+{
+  emit vpTransformationStarted ( FRONTVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xpos);
+  onViewFitAll();
+}
+
+/*!
+  Processes transformation "back view"
+*/
+void OCCViewer_ViewWindow::onBackView()
+{
+  emit vpTransformationStarted ( BACKVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xneg);
+  onViewFitAll();
+}
+
+/*!
+  Processes transformation "top view"
+*/
+void OCCViewer_ViewWindow::onTopView()
+{
+  emit vpTransformationStarted ( TOPVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zpos);
+  onViewFitAll();
+}
+
+/*!
+  Processes transformation "bottom view"
+*/
+void OCCViewer_ViewWindow::onBottomView()
+{
+  emit vpTransformationStarted ( BOTTOMVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zneg);
+  onViewFitAll();
+}
+
+/*!
+  Processes transformation "left view"
+*/
+void OCCViewer_ViewWindow::onLeftView()
+{
+  emit vpTransformationStarted ( LEFTVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Yneg);
+  onViewFitAll();
+}
+
+/*!
+  Processes transformation "right view"
+*/
+void OCCViewer_ViewWindow::onRightView()
+{
+  emit vpTransformationStarted ( RIGHTVIEW );
+  Handle(V3d_View) aView3d = myViewPort->getView();
+  if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Ypos);
+  onViewFitAll();
+}
+
+/*!
+  Processes transformation "reset view": sets default orientation of viewport camera
+*/
+void OCCViewer_ViewWindow::onResetView()
+{
+  emit vpTransformationStarted( RESETVIEW );
+  bool upd = myViewPort->getView()->SetImmediateUpdate( false );
+  myViewPort->getView()->Reset( false );
+  myViewPort->fitAll( false, true, false );
+  myViewPort->getView()->SetImmediateUpdate( upd );
+  myViewPort->getView()->Update();
+}
+
+/*!
+  Processes transformation "fit all"
+*/
+void OCCViewer_ViewWindow::onFitAll()
+{
+  emit vpTransformationStarted( FITALLVIEW );
+  myViewPort->fitAll();
+}
+
+/*!
+  Creates one more window with same content
+*/
+void OCCViewer_ViewWindow::onCloneView()
+{
+  SUIT_ViewWindow* vw = myManager->createViewWindow();
+  vw->show();
+}
+
+/*!
+  SLOT: called if clipping operation is activated, enables/disables of clipping plane
+*/
+void OCCViewer_ViewWindow::onClipping( bool on )
+{
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  if ( on )
+    toolMgr()->action( ClippingId )->setIcon(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING_PRESSED" )));
+  else
+    toolMgr()->action( ClippingId )->setIcon(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" )));
+  
+  if( on )
+  {
+    if( !myClippingDlg )
+         {
+         myClippingDlg = new OCCViewer_ClippingDlg( this, myDesktop );
+           myClippingDlg->SetAction( myClippingAction );
+         }
+
+    if( !myClippingDlg->isVisible() )
+           myClippingDlg->show();
+  }
+  else
+  {
+    if( myClippingDlg->isVisible() )
+           myClippingDlg->hide();
+    setCuttingPlane(false);
+  }
+}
+
+/*!
+  Stores view parameters
+*/
+void OCCViewer_ViewWindow::onMemorizeView()
+{
+  myModel->appendViewAspect( getViewParams() );
+}
+
+/*!
+  Restores view parameters
+*/
+void OCCViewer_ViewWindow::onRestoreView()
+{
+       OCCViewer_CreateRestoreViewDlg* aDlg = new OCCViewer_CreateRestoreViewDlg( centralWidget(), myModel );
+       connect( aDlg, SIGNAL( dlgOk() ), this, SLOT( setRestoreFlag() ) );
+       aDlg->exec();
+       myModel->updateViewAspects( aDlg->parameters() );
+       if( myRestoreFlag && aDlg->parameters().count() )
+               performRestoring( aDlg->currentItem() );
+}
+
+/*!
+  Restores view parameters from structure viewAspect
+*/
+void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem )
+{
+       Handle(V3d_View) aView3d = myViewPort->getView();
+
+       Standard_Boolean prev = aView3d->SetImmediateUpdate( Standard_False );
+       aView3d->SetScale( anItem.scale );
+       aView3d->SetCenter( anItem.centerX, anItem.centerY );
+       aView3d->SetTwist( anItem.twist );
+       aView3d->SetAt( anItem.atX, anItem.atY, anItem.atZ );
+       aView3d->SetImmediateUpdate( prev );
+       aView3d->SetEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ );
+       aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ );
+               
+       myRestoreFlag = 0;
+}
+
+/*!
+  Sets restore flag
+*/
+void OCCViewer_ViewWindow::setRestoreFlag()
+{
+       myRestoreFlag = 1;
+}
+
+/*!
+  SLOT: called when action "show/hide" trihedron is activated
+*/
+void OCCViewer_ViewWindow::onTrihedronShow()
+{
+  myModel->toggleTrihedron();
+}
+
+/*!
+  \return QImage, containing all scene rendering in window
+*/
+QImage OCCViewer_ViewWindow::dumpView()
+{
+  QPixmap px = QPixmap::grabWindow( myViewPort->winId() );
+  return px.toImage();
+}
+
+/*!
+  Sets parameters of cutting plane
+  \param on - is cutting plane enabled
+  \param x - x-position of plane point 
+  \param y - y-position of plane point 
+  \param z - z-position of plane point 
+  \param dx - x-coordinate of plane normal
+  \param dy - y-coordinate of plane normal
+  \param dz - z-coordinate of plane normal
+*/
+void  OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x,  const double y,  const double z,
+                                                     const double dx, const double dy, const double dz )
+{
+  Handle(V3d_View) view = myViewPort->getView();
+  if ( view.IsNull() )
+    return;
+
+  if ( on ) {
+    Handle(V3d_Viewer) viewer = myViewPort->getViewer();
+    
+    // try to use already existing plane or create a new one
+    Handle(V3d_Plane) clipPlane;
+    view->InitActivePlanes();
+    
+    // set new a,b,c,d values for the plane
+    gp_Pln pln( gp_Pnt( x, y, z ), gp_Dir( dx, dy, dz ) );
+    double a, b, c, d;
+    pln.Coefficients( a, b, c, d );
+    
+    if ( view->MoreActivePlanes() )
+    {
+      clipPlane = view->ActivePlane();
+      clipPlane->SetPlane( a, b, c, d );
+    }
+    else
+      clipPlane = new V3d_Plane( a, b, c, d );
+    
+    view->SetPlaneOn( clipPlane );
+  } 
+  else
+    view->SetPlaneOff();
+  
+  view->Update();
+  view->Redraw();
+}
+
+/*!
+  \return true if there is at least one cutting plane
+*/
+bool OCCViewer_ViewWindow::isCuttingPlane()
+{
+  Handle(V3d_View) view = myViewPort->getView();
+  view->InitActivePlanes();
+  return (view->MoreActivePlanes());
+}
+
+/*!
+  The method returns the visual parameters of this view as a viewAspect object
+*/
+viewAspect OCCViewer_ViewWindow::getViewParams() const
+{
+  double centerX, centerY, projX, projY, projZ, twist;
+  double atX, atY, atZ, eyeX, eyeY, eyeZ;
+
+  Handle(V3d_View) aView3d = myViewPort->getView();
+
+  aView3d->Center( centerX, centerY );
+  aView3d->Proj( projX, projY, projZ );
+  aView3d->At( atX, atY, atZ );
+  aView3d->Eye( eyeX, eyeY, eyeZ );
+  twist = aView3d->Twist();
+
+  QString aName = QTime::currentTime().toString() + QString::fromLatin1( " h:m:s" );
+
+  viewAspect params;
+  params.scale    = aView3d->Scale();
+  params.centerX  = centerX;
+  params.centerY  = centerY;
+  params.projX    = projX;
+  params.projY    = projY;
+  params.projZ    = projZ;
+  params.twist    = twist;
+  params.atX      = atX;
+  params.atY      = atY;
+  params.atZ      = atZ;
+  params.eyeX     = eyeX;
+  params.eyeY     = eyeY;
+  params.eyeZ     = eyeZ;
+  params.name    = aName;
+
+  return params;
+}
+
+
+/*!
+  The method returns the visual parameters of this view as a formated string
+*/
+QString OCCViewer_ViewWindow::getVisualParameters()
+{
+  viewAspect params = getViewParams();
+  QString retStr;
+  retStr.sprintf( "%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e", params.scale,
+                 params.centerX, params.centerY, params.projX, params.projY, params.projZ, params.twist,
+                 params.atX, params.atY, params.atZ, params.eyeX, params.eyeY, params.eyeZ );
+  return retStr;
+}
+
+/*!
+  The method restors visual parameters of this view from a formated string
+*/
+void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters )
+{
+  QStringList paramsLst = parameters.split( '*', QString::KeepEmptyParts );
+  if ( paramsLst.size() == 13 ) {
+    viewAspect params;
+    params.scale    = paramsLst[0].toDouble();
+    params.centerX  = paramsLst[1].toDouble();
+    params.centerY  = paramsLst[2].toDouble();
+    params.projX    = paramsLst[3].toDouble();
+    params.projY    = paramsLst[4].toDouble();
+    params.projZ    = paramsLst[5].toDouble();
+    params.twist    = paramsLst[6].toDouble();
+    params.atX      = paramsLst[7].toDouble();
+    params.atY      = paramsLst[8].toDouble();
+    params.atZ      = paramsLst[9].toDouble();
+    params.eyeX     = paramsLst[10].toDouble();
+    params.eyeY     = paramsLst[11].toDouble();
+    params.eyeZ     = paramsLst[12].toDouble();
+
+    performRestoring( params );
+  }
+}
+
+int OCCViewer_ViewWindow::toolBarId() const
+{
+  return myToolbarId;
+}
diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h
new file mode 100755 (executable)
index 0000000..adbc776
--- /dev/null
@@ -0,0 +1,162 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef OCCVIEWER_VIEWWINDOW_H
+#define OCCVIEWER_VIEWWINDOW_H
+
+#include "OCCViewer_ViewModel.h"
+
+#include "SUIT_ViewWindow.h"
+
+#include "QtxAction.h"
+
+#include <qcursor.h>
+#include <QList>
+
+class SUIT_Desktop;
+class OCCViewer_ViewPort3d;
+
+class OCCViewer_ClippingDlg;
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+class OCCVIEWER_EXPORT OCCViewer_ViewWindow : public SUIT_ViewWindow  
+{
+  Q_OBJECT
+
+public:
+  enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
+                      FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW };
+
+  OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
+       virtual ~OCCViewer_ViewWindow() {};
+
+  OCCViewer_ViewPort3d* getViewPort() { return myViewPort; }
+
+  bool eventFilter(QObject* watched, QEvent* e);
+
+  void performRestoring( const viewAspect& );
+  
+  virtual void initLayout();
+
+  void updateEnabledDrawMode();
+
+  void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0,
+                                 const double dx = 0, const double dy = 0, const double dz = 1);
+
+  bool isCuttingPlane();
+
+  virtual QString   getVisualParameters();
+  virtual void      setVisualParameters( const QString& parameters );
+  int toolBarId() const;
+
+public slots:
+  void onFrontView();
+  void onViewFitAll();
+  void onBackView();
+  void onTopView();
+  void onBottomView();
+  void onLeftView();
+  void onRightView();
+  void onResetView();
+  void onFitAll();
+  void activateZoom();
+  void activateWindowFit();
+  void activateRotation();
+  void activatePanning();
+  void activateGlobalPanning();
+  void onCloneView();
+  void onClipping( bool on );
+  void onMemorizeView();
+  void onRestoreView();
+  void onTrihedronShow();
+  void setRestoreFlag();
+  
+signals:
+  void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type);
+  void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type);
+  void cloneView();
+
+protected:
+  enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
+         FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId,
+         TrihedronShowId };
+
+  typedef QMap<int, QtxAction*> ActionsMap;
+
+  QImage dumpView();
+
+  /* Transformation selected but not started yet */
+  bool transformRequested() const { return ( myOperation != NOTHING ); }
+  void setTransformRequested ( OperationType op );
+
+  /* Transformation is selected and already started */
+  bool         transformInProcess() const { return myEventStarted; }
+  void         setTransformInProcess( bool bOn ) { myEventStarted = bOn; }
+
+  void vpMousePressEvent(QMouseEvent* theEvent);
+  void vpMouseReleaseEvent(QMouseEvent* theEvent);
+  void vpMouseMoveEvent(QMouseEvent* theEvent);
+
+  void resetState();
+  void drawRect();
+
+  void createActions();
+  void createToolBar();
+  virtual OperationType getButtonState(QMouseEvent* theEvent);
+
+  viewAspect getViewParams() const;
+
+  OperationType         myOperation;
+  OCCViewer_Viewer*     myModel;
+  OCCViewer_ViewPort3d* myViewPort;
+
+  int                                  myRestoreFlag;
+
+  int                                  myStartX;
+  int                                  myStartY;
+  int                                  myCurrX;
+  int                                  myCurrY;
+
+  bool                 myEventStarted;       // set when transformation is in process 
+  bool                 myCursorIsHand;                 
+  bool                 myDrawRect;           // set when a rect is used for selection or magnify 
+  bool                 myEnableDrawMode;
+  bool                 myPaintersRedrawing;  // set to draw with external painters 
+  QRect                        myRect;                         
+  QCursor              myCursor;
+
+  double myCurScale;
+  int myToolbarId;
+
+private:
+  OCCViewer_ClippingDlg* myClippingDlg;
+  QtxAction* myClippingAction;
+  
+};
+
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
+#endif
diff --git a/src/OCCViewer/resources/OCCViewer_images.po b/src/OCCViewer/resources/OCCViewer_images.po
new file mode 100755 (executable)
index 0000000..b755303
--- /dev/null
@@ -0,0 +1,96 @@
+#  SALOME SALOMEGUI : implementation of desktop and GUI kernel
+#
+#  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+#
+#
+#  File   : SALOMEGUI_icons.po
+#  Module : SALOME
+
+msgid ""
+msgstr ""
+"Project-Id-Version: example-Qt-message-extraction\n"
+"POT-Creation-Date: 1999-02-23 15:38+0200\n"
+"PO-Revision-Date: 1999-02-23 15:38+0200\n"
+"Last-Translator: \n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
+msgid "ICON_OCCVIEWER_VIEW_BACK"
+msgstr "view_back.png"
+
+msgid "ICON_OCCVIEWER_VIEW_BOTTOM"
+msgstr "view_bottom.png"
+
+msgid "ICON_OCCVIEWER_VIEW_FITALL"
+msgstr "view_fitall.png"
+
+msgid "ICON_OCCVIEWER_VIEW_FITAREA"
+msgstr "view_fitarea.png"
+
+msgid "ICON_OCCVIEWER_VIEW_FRONT"
+msgstr "view_front.png"
+
+msgid "ICON_OCCVIEWER_VIEW_GLOBALPAN"
+msgstr "view_glpan.png"
+
+msgid "ICON_OCCVIEWER_VIEW_LEFT"
+msgstr "view_left.png"
+
+msgid "ICON_OCCVIEWER_VIEW_PAN"
+msgstr "view_pan.png"
+
+msgid "ICON_OCCVIEWER_VIEW_RESET"
+msgstr "view_reset.png"
+
+msgid "ICON_OCCVIEWER_VIEW_RIGHT"
+msgstr "view_right.png"
+
+msgid "ICON_OCCVIEWER_VIEW_ROTATE"
+msgstr "view_rotate.png"
+
+msgid "ICON_OCCVIEWER_VIEW_TOP"
+msgstr "view_top.png"
+
+msgid "ICON_OCCVIEWER_VIEW_ZOOM"
+msgstr "view_zoom.png"
+
+msgid "ICON_OCCVIEWER_VIEW_TRIHEDRON"
+msgstr "view_triedre.png"
+
+msgid "ICON_OCCVIEWER_VIEW_DUMP"
+msgstr "view_camera_dump.png"
+
+msgid "ICON_OCCVIEWER_CLONE_VIEW"
+msgstr "view_clone.png"
+
+msgid "ICON_OCCVIEWER_CLIPPING"
+msgstr "view_clipping.png"
+
+msgid "ICON_OCCVIEWER_CLIPPING_PRESSED"
+msgstr "view_clipping_pressed.png"
+
+msgid "ICON_OCCVIEWER_SHOOT_VIEW"
+msgstr "view_shoot.png"
+
+msgid "ICON_OCCVIEWER_PRESETS_VIEW"
+msgstr "view_presets.png"
+
+
+
diff --git a/src/OCCViewer/resources/OCCViewer_images.ts b/src/OCCViewer/resources/OCCViewer_images.ts
new file mode 100644 (file)
index 0000000..2fa8a8b
--- /dev/null
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+    <extra-po-header-po_revision_date>1999-02-23 15:38+0200</extra-po-header-po_revision_date>
+    <extra-po-headers>Project-Id-Version,POT-Creation-Date,PO-Revision-Date,Last-Translator,Content-Type</extra-po-headers>
+    <extra-po-header-project_id_version>example-Qt-message-extraction</extra-po-header-project_id_version>
+    <extra-po-header-pot_creation_date>1999-02-23 15:38+0200</extra-po-header-pot_creation_date>
+    <extra-po-header_comment>#  SALOME SALOMEGUI : implementation of desktop and GUI kernel
+#
+#  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+#  CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+#
+#
+#  File   : SALOMEGUI_icons.po
+#  Module : SALOME</extra-po-header_comment>
+    <extra-po-header-last_translator></extra-po-header-last_translator>
+<context>
+    <name>OCCViewer_ViewWindow</name>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_BACK</source>
+        <translation>view_back.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_BOTTOM</source>
+        <translation>view_bottom.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_FITALL</source>
+        <translation>view_fitall.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_FITAREA</source>
+        <translation>view_fitarea.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_FRONT</source>
+        <translation>view_front.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_GLOBALPAN</source>
+        <translation>view_glpan.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_LEFT</source>
+        <translation>view_left.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_PAN</source>
+        <translation>view_pan.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_RESET</source>
+        <translation>view_reset.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_RIGHT</source>
+        <translation>view_right.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_ROTATE</source>
+        <translation>view_rotate.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_TOP</source>
+        <translation>view_top.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_ZOOM</source>
+        <translation>view_zoom.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_TRIHEDRON</source>
+        <translation>view_triedre.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_VIEW_DUMP</source>
+        <translation>view_camera_dump.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_CLONE_VIEW</source>
+        <translation>view_clone.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_CLIPPING</source>
+        <translation>view_clipping.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_CLIPPING_PRESSED</source>
+        <translation>view_clipping_pressed.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_SHOOT_VIEW</source>
+        <translation>view_shoot.png</translation>
+    </message>
+    <message>
+        <source>ICON_OCCVIEWER_PRESETS_VIEW</source>
+        <translation>view_presets.png</translation>
+    </message>
+</context>
+</TS>
diff --git a/src/OCCViewer/resources/OCCViewer_msg_en.po b/src/OCCViewer/resources/OCCViewer_msg_en.po
new file mode 100755 (executable)
index 0000000..b9f31fa
--- /dev/null
@@ -0,0 +1,184 @@
+#  SALOME SALOMEGUI : implementation of desktop and GUI kernel
+#
+#  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+#
+#
+#  File   : SALOMEGUI_msg_en.po
+#  Module : SALOME
+
+msgid ""
+msgstr ""
+"Project-Id-Version: example-Qt-message-extraction\n"
+"POT-Creation-Date: 1999-02-23 15:38+0200\n"
+"PO-Revision-Date: 1999-02-23 15:38+0200\n"
+"Last-Translator: \n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
+msgid "LBL_TOOLBAR_LABEL"
+msgstr "View Operations"
+
+msgid "DSC_FRONT_VIEW"
+msgstr "Front View"
+
+msgid "MNU_FRONT_VIEW"
+msgstr "Front"
+
+msgid "DSC_BACK_VIEW"
+msgstr "Back View"
+
+msgid "MNU_BACK_VIEW"
+msgstr "Back"
+
+msgid "DSC_TOP_VIEW"
+msgstr "Top View"
+
+msgid "MNU_TOP_VIEW"
+msgstr "Top"
+
+msgid "DSC_BOTTOM_VIEW"
+msgstr "Bottom View"
+
+msgid "MNU_BOTTOM_VIEW"
+msgstr "Bottom"
+
+msgid "DSC_LEFT_VIEW"
+msgstr "Left View"
+
+msgid "MNU_LEFT_VIEW"
+msgstr "Left"
+
+msgid "DSC_RIGHT_VIEW"
+msgstr "Right View"
+
+msgid "MNU_RIGHT_VIEW"
+msgstr "Right"
+
+msgid "DSC_RESET_VIEW"
+msgstr "Reset View Point"
+
+msgid "MNU_RESET_VIEW"
+msgstr "Reset"
+
+msgid "DSC_FITALL"
+msgstr "Fit all objects inside the view frame"
+
+msgid "MNU_FITALL"
+msgstr "Fit All"
+
+msgid "DSC_FITRECT"
+msgstr "Fit area within the view frame"
+
+msgid "MNU_FITRECT"
+msgstr "Fit Area"
+
+msgid "DSC_ZOOM_VIEW"
+msgstr "Zoom the view"
+
+msgid "MNU_ZOOM_VIEW"
+msgstr "Zoom"
+
+msgid "DSC_PAN_VIEW"
+msgstr "Panning the view"
+
+msgid "MNU_PAN_VIEW"
+msgstr "Panning"
+
+msgid "DSC_GLOBALPAN_VIEW"
+msgstr "Selection of a new center of the view"
+
+msgid "MNU_GLOBALPAN_VIEW"
+msgstr "Global Panning"
+
+msgid "DSC_ROTATE_VIEW"
+msgstr "Rotation of the point of view around the scene center"
+
+msgid "MNU_ROTATE_VIEW"
+msgstr "Rotation"
+
+msgid "DSC_CLONE_VIEW"
+msgstr "Create new OCC viewer for the active scene"
+
+msgid "MNU_CLONE_VIEW"
+msgstr "Clone View"
+
+msgid "MNU_DUMP_VIEW"
+msgstr "Dump view"
+
+msgid "DSC_CLIPPING"
+msgstr "Set clipping plane"
+
+msgid "MNU_CLIPPING"
+msgstr "Clipping"
+
+msgid "DSC_DUMP_VIEW"
+msgstr "Saves the active view in the image file"
+
+msgid "MNU_SHOOT_VIEW"
+msgstr "Memorize View"
+
+msgid "DSC_SHOOT_VIEW"
+msgstr "Memorizes the state of the active view and adds it to the list"
+
+msgid "MNU_PRESETS_VIEW"
+msgstr "Restore View"
+
+msgid "DSC_PRESETS_VIEW"
+msgstr "Selection of the memorized state of the active view"
+
+msgid "OCC_IMAGE_FILES"
+msgstr "Images Files (*.bmp *.png *.jpg *.jpeg)"
+
+msgid "INF_APP_DUMP_VIEW"
+msgstr "Dump view"
+
+msgid "INF_APP_SHOOT_VIEW"
+msgstr "Memorize view"
+
+msgid "INF_APP_PRESETS_VIEW"
+msgstr "Restore view"
+
+msgid "ERR_DOC_CANT_SAVE_FILE"
+msgstr "Cannot save file"
+
+msgid "ERROR"
+msgstr "Error"
+
+msgid "OCCViewer_Viewer::MEN_DUMP_VIEW"
+msgstr "Dump view..."
+
+msgid "OCCViewer_Viewer::MEN_SHOW_TOOLBAR"
+msgstr "Show toolbar"
+
+msgid "OCCViewer_Viewer::MEN_CHANGE_BACKGROUD"
+msgstr "Change background..."
+
+msgid "OCCViewer_ViewManager::OCC_VIEW_TITLE"
+msgstr "OCC scene:%M - viewer:%V"
+
+
+msgid "OCCViewer_CreateRestoreViewDlg::CAPTION"
+msgstr "Restore view"
+
+msgid "MNU_SHOW_TRIHEDRE"
+msgstr "Show/Hide trihedron"
+
+msgid "DSC_SHOW_TRIHEDRE"
+msgstr "Show/Hide trihedron in the current view"
diff --git a/src/OCCViewer/resources/OCCViewer_msg_en.ts b/src/OCCViewer/resources/OCCViewer_msg_en.ts
new file mode 100644 (file)
index 0000000..63bb7c8
--- /dev/null
@@ -0,0 +1,248 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="en_US">
+  <extra-po-header-po_revision_date>1999-02-23 15:38+0200</extra-po-header-po_revision_date>
+  <extra-po-headers>Project-Id-Version,POT-Creation-Date,PO-Revision-Date,Last-Translator,Content-Type</extra-po-headers>
+  <extra-po-header-project_id_version>example-Qt-message-extraction</extra-po-header-project_id_version>
+  <extra-po-header-pot_creation_date>1999-02-23 15:38+0200</extra-po-header-pot_creation_date>
+  <extra-po-header_comment>
+    #  SALOME SALOMEGUI : implementation of desktop and GUI kernel
+    #
+    #  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+    #  CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+    #
+    #
+    #
+    #  File   : SALOMEGUI_msg_en.po
+    #  Module : SALOME
+  </extra-po-header_comment>
+  <extra-po-header-last_translator></extra-po-header-last_translator>
+  <context>
+    <name>OCCViewer_ViewWindow</name>
+    <message>
+      <source>LBL_TOOLBAR_LABEL</source>
+      <translation>View Operations</translation>
+    </message>
+    <message>
+      <source>DSC_FRONT_VIEW</source>
+      <translation>Front View</translation>
+    </message>
+    <message>
+      <source>MNU_FRONT_VIEW</source>
+      <translation>Front</translation>
+    </message>
+    <message>
+      <source>DSC_BACK_VIEW</source>
+      <translation>Back View</translation>
+    </message>
+    <message>
+      <source>MNU_BACK_VIEW</source>
+      <translation>Back</translation>
+    </message>
+    <message>
+      <source>DSC_TOP_VIEW</source>
+      <translation>Top View</translation>
+    </message>
+    <message>
+      <source>MNU_TOP_VIEW</source>
+      <translation>Top</translation>
+    </message>
+    <message>
+      <source>DSC_BOTTOM_VIEW</source>
+      <translation>Bottom View</translation>
+    </message>
+    <message>
+      <source>MNU_BOTTOM_VIEW</source>
+      <translation>Bottom</translation>
+    </message>
+    <message>
+      <source>DSC_LEFT_VIEW</source>
+      <translation>Left View</translation>
+    </message>
+    <message>
+      <source>MNU_LEFT_VIEW</source>
+      <translation>Left</translation>
+    </message>
+    <message>
+      <source>DSC_RIGHT_VIEW</source>
+      <translation>Right View</translation>
+    </message>
+    <message>
+      <source>MNU_RIGHT_VIEW</source>
+      <translation>Right</translation>
+    </message>
+    <message>
+      <source>DSC_RESET_VIEW</source>
+      <translation>Reset View Point</translation>
+    </message>
+    <message>
+      <source>MNU_RESET_VIEW</source>
+      <translation>Reset</translation>
+    </message>
+    <message>
+      <source>DSC_FITALL</source>
+      <translation>Fit all objects inside the view frame</translation>
+    </message>
+    <message>
+      <source>MNU_FITALL</source>
+      <translation>Fit All</translation>
+    </message>
+    <message>
+      <source>DSC_FITRECT</source>
+      <translation>Fit area within the view frame</translation>
+    </message>
+    <message>
+      <source>MNU_FITRECT</source>
+      <translation>Fit Area</translation>
+    </message>
+    <message>
+      <source>DSC_ZOOM_VIEW</source>
+      <translation>Zoom the view</translation>
+    </message>
+    <message>
+      <source>MNU_ZOOM_VIEW</source>
+      <translation>Zoom</translation>
+    </message>
+    <message>
+      <source>DSC_PAN_VIEW</source>
+      <translation>Panning the view</translation>
+    </message>
+    <message>
+      <source>MNU_PAN_VIEW</source>
+      <translation>Panning</translation>
+    </message>
+    <message>
+      <source>DSC_GLOBALPAN_VIEW</source>
+      <translation>Selection of a new center of the view</translation>
+    </message>
+    <message>
+      <source>MNU_GLOBALPAN_VIEW</source>
+      <translation>Global Panning</translation>
+    </message>
+    <message>
+      <source>DSC_ROTATE_VIEW</source>
+      <translation>Rotation of the point of view around the scene center</translation>
+    </message>
+    <message>
+      <source>MNU_ROTATE_VIEW</source>
+      <translation>Rotation</translation>
+    </message>
+    <message>
+      <source>DSC_CLONE_VIEW</source>
+      <translation>Create new OCC viewer for the active scene</translation>
+    </message>
+    <message>
+      <source>MNU_CLONE_VIEW</source>
+      <translation>Clone View</translation>
+    </message>
+    <message>
+      <source>MNU_DUMP_VIEW</source>
+      <translation>Dump view</translation>
+    </message>
+    <message>
+      <source>DSC_CLIPPING</source>
+      <translation>Set clipping plane</translation>
+    </message>
+    <message>
+      <source>MNU_CLIPPING</source>
+      <translation>Clipping</translation>
+    </message>
+    <message>
+      <source>DSC_DUMP_VIEW</source>
+      <translation>Saves the active view in the image file</translation>
+    </message>
+    <message>
+      <source>MNU_SHOOT_VIEW</source>
+      <translation>Memorize View</translation>
+    </message>
+    <message>
+      <source>DSC_SHOOT_VIEW</source>
+      <translation>Memorizes the state of the active view and adds it to the list</translation>
+    </message>
+    <message>
+      <source>MNU_PRESETS_VIEW</source>
+      <translation>Restore View</translation>
+    </message>
+    <message>
+      <source>DSC_PRESETS_VIEW</source>
+      <translation>Selection of the memorized state of the active view</translation>
+    </message>
+    <message>
+      <source>OCC_IMAGE_FILES</source>
+      <translation>Images Files (*.bmp *.png *.jpg *.jpeg)</translation>
+    </message>
+    <message>
+      <source>INF_APP_DUMP_VIEW</source>
+      <translation>Dump view</translation>
+    </message>
+    <message>
+      <source>INF_APP_SHOOT_VIEW</source>
+      <translation>Memorize view</translation>
+    </message>
+    <message>
+      <source>INF_APP_PRESETS_VIEW</source>
+      <translation>Restore view</translation>
+    </message>
+    <message>
+      <source>ERR_DOC_CANT_SAVE_FILE</source>
+      <translation>Cannot save file</translation>
+    </message>
+    <message>
+      <source>ERROR</source>
+      <translation>Error</translation>
+    </message>
+    <message>
+      <source>MNU_SHOW_TRIHEDRE</source>
+      <translation>Show/Hide trihedron</translation>
+    </message>
+    <message>
+      <source>DSC_SHOW_TRIHEDRE</source>
+      <translation>Show/Hide trihedron in the current view</translation>
+    </message>
+  </context>
+  <context>
+    <name>OCCViewer_Viewer</name>
+    <message>
+      <source>MEN_DUMP_VIEW</source>
+      <translation>Dump view...</translation>
+    </message>
+    <message>
+      <source>MEN_SHOW_TOOLBAR</source>
+      <translation>Show toolbar</translation>
+    </message>
+    <message>
+      <source>MEN_CHANGE_BACKGROUD</source>
+      <translation>Change background...</translation>
+    </message>
+  </context>
+  <context>
+    <name>OCCViewer_ViewManager</name>
+    <message>
+      <source>OCC_VIEW_TITLE</source>
+      <translation>OCC scene:%M - viewer:%V</translation>
+    </message>
+  </context>
+  <context>
+    <name>OCCViewer_CreateRestoreViewDlg</name>
+    <message>
+      <source>CAPTION</source>
+      <translation>Restore view</translation>
+    </message>
+  </context>
+</TS>
diff --git a/src/OCCViewer/resources/view_back.png b/src/OCCViewer/resources/view_back.png
new file mode 100755 (executable)
index 0000000..721c15b
Binary files /dev/null and b/src/OCCViewer/resources/view_back.png differ
diff --git a/src/OCCViewer/resources/view_bottom.png b/src/OCCViewer/resources/view_bottom.png
new file mode 100755 (executable)
index 0000000..c0fd041
Binary files /dev/null and b/src/OCCViewer/resources/view_bottom.png differ
diff --git a/src/OCCViewer/resources/view_camera_dump.png b/src/OCCViewer/resources/view_camera_dump.png
new file mode 100755 (executable)
index 0000000..bd438d3
Binary files /dev/null and b/src/OCCViewer/resources/view_camera_dump.png differ
diff --git a/src/OCCViewer/resources/view_clipping.png b/src/OCCViewer/resources/view_clipping.png
new file mode 100644 (file)
index 0000000..46cf6d5
Binary files /dev/null and b/src/OCCViewer/resources/view_clipping.png differ
diff --git a/src/OCCViewer/resources/view_clipping_pressed.png b/src/OCCViewer/resources/view_clipping_pressed.png
new file mode 100644 (file)
index 0000000..89c4af8
Binary files /dev/null and b/src/OCCViewer/resources/view_clipping_pressed.png differ
diff --git a/src/OCCViewer/resources/view_clone.png b/src/OCCViewer/resources/view_clone.png
new file mode 100755 (executable)
index 0000000..8e19f41
Binary files /dev/null and b/src/OCCViewer/resources/view_clone.png differ
diff --git a/src/OCCViewer/resources/view_fitall.png b/src/OCCViewer/resources/view_fitall.png
new file mode 100755 (executable)
index 0000000..db6f86d
Binary files /dev/null and b/src/OCCViewer/resources/view_fitall.png differ
diff --git a/src/OCCViewer/resources/view_fitarea.png b/src/OCCViewer/resources/view_fitarea.png
new file mode 100755 (executable)
index 0000000..4e7ca30
Binary files /dev/null and b/src/OCCViewer/resources/view_fitarea.png differ
diff --git a/src/OCCViewer/resources/view_front.png b/src/OCCViewer/resources/view_front.png
new file mode 100755 (executable)
index 0000000..22bac13
Binary files /dev/null and b/src/OCCViewer/resources/view_front.png differ
diff --git a/src/OCCViewer/resources/view_glpan.png b/src/OCCViewer/resources/view_glpan.png
new file mode 100755 (executable)
index 0000000..186a75a
Binary files /dev/null and b/src/OCCViewer/resources/view_glpan.png differ
diff --git a/src/OCCViewer/resources/view_left.png b/src/OCCViewer/resources/view_left.png
new file mode 100755 (executable)
index 0000000..ecef7c4
Binary files /dev/null and b/src/OCCViewer/resources/view_left.png differ
diff --git a/src/OCCViewer/resources/view_pan.png b/src/OCCViewer/resources/view_pan.png
new file mode 100755 (executable)
index 0000000..50db458
Binary files /dev/null and b/src/OCCViewer/resources/view_pan.png differ
diff --git a/src/OCCViewer/resources/view_presets.png b/src/OCCViewer/resources/view_presets.png
new file mode 100755 (executable)
index 0000000..7b8eb82
Binary files /dev/null and b/src/OCCViewer/resources/view_presets.png differ
diff --git a/src/OCCViewer/resources/view_reset.png b/src/OCCViewer/resources/view_reset.png
new file mode 100755 (executable)
index 0000000..7ba93b9
Binary files /dev/null and b/src/OCCViewer/resources/view_reset.png differ
diff --git a/src/OCCViewer/resources/view_right.png b/src/OCCViewer/resources/view_right.png
new file mode 100755 (executable)
index 0000000..a7094b6
Binary files /dev/null and b/src/OCCViewer/resources/view_right.png differ
diff --git a/src/OCCViewer/resources/view_rotate.png b/src/OCCViewer/resources/view_rotate.png
new file mode 100755 (executable)
index 0000000..164468c
Binary files /dev/null and b/src/OCCViewer/resources/view_rotate.png differ
diff --git a/src/OCCViewer/resources/view_shoot.png b/src/OCCViewer/resources/view_shoot.png
new file mode 100755 (executable)
index 0000000..6dde6ec
Binary files /dev/null and b/src/OCCViewer/resources/view_shoot.png differ
diff --git a/src/OCCViewer/resources/view_top.png b/src/OCCViewer/resources/view_top.png
new file mode 100755 (executable)
index 0000000..230157e
Binary files /dev/null and b/src/OCCViewer/resources/view_top.png differ
diff --git a/src/OCCViewer/resources/view_triedre.png b/src/OCCViewer/resources/view_triedre.png
new file mode 100755 (executable)
index 0000000..3154cf0
Binary files /dev/null and b/src/OCCViewer/resources/view_triedre.png differ
diff --git a/src/OCCViewer/resources/view_zoom.png b/src/OCCViewer/resources/view_zoom.png
new file mode 100755 (executable)
index 0000000..d4eafbc
Binary files /dev/null and b/src/OCCViewer/resources/view_zoom.png differ
index 731a94538b169a1c37fa58a38038c512e2580ae1..7ebc7a223b29e0273a1cfcd9608c7f8b60876de6 100644 (file)
 #include <QApplication>
 #include <QHBoxLayout>
 #include <QVBoxLayout>
-#include <QLabel>
 #include <QLayout>
 #include <QMainWindow>
 #include <QResizeEvent>
 #include <QStyleOption>
 #include <QStylePainter>
 #include <QToolButton>
-#include <QWindowsStyle>
 
-/*!
-  \class QtxDockTitleStyle
-  \internal
-  \brief Internal class that implements customizable label style for a dock widget.
-*/
-class QtxDockTitleStyle : public QWindowsStyle
+QtxDockTitleStyle::QtxDockTitleStyle( const bool& isVertical )
+  : QWindowsStyle(), m_bIsVertical( isVertical )
 {
-  Q_OBJECT
-public:
-  QtxDockTitleStyle( const bool& isVertical ) : QWindowsStyle(), m_bIsVertical( isVertical ) {};
-  virtual ~QtxDockTitleStyle() {};
+}
 
-  void   setVertical( const bool& isVertical ) { m_bIsVertical = isVertical; }
-  bool   isVertical() const { return m_bIsVertical; }
+QtxDockTitleStyle::~QtxDockTitleStyle()
+{
+}
 
-  virtual void drawItemText( QPainter* painter, const QRect& rectangle,
+void QtxDockTitleStyle::setVertical( const bool& isVertical )
+{
+  m_bIsVertical = isVertical;
+}
+
+bool QtxDockTitleStyle::isVertical() const
+{
+  return m_bIsVertical;
+}
+
+void QtxDockTitleStyle::drawItemText( QPainter* painter, const QRect& rectangle,
                       int alignment, const QPalette& palette,
                       bool enabled, const QString& text,
-                      QPalette::ColorRole textRole = QPalette::NoRole ) const
-  {
-    QRect r = rectangle;
-    if ( isVertical() ) {
-      QSize s = r.size();
-      s.transpose();
-      r.setSize( s );
-      painter->save();
-      painter->translate( r.left(), r.top() + r.width() );
-      painter->rotate( -90 );
-      painter->translate( -r.left(), -r.top() );
-
-    }
-    QWindowsStyle::drawItemText( painter, r, alignment, palette,
-                                 enabled, text, textRole );
-    if ( isVertical() )
-      painter->restore();
+                      QPalette::ColorRole textRole ) const
+{
+  QRect r = rectangle;
+  if ( isVertical() ) {
+    QSize s = r.size();
+    s.transpose();
+    r.setSize( s );
+    painter->save();
+    painter->translate( r.left(), r.top() + r.width() );
+    painter->rotate( -90 );
+    painter->translate( -r.left(), -r.top() );
   }
+  QWindowsStyle::drawItemText( painter, r, alignment, palette,
+                               enabled, text, textRole );
+  if ( isVertical() )
+    painter->restore();
+}
 
-private:
-  bool   m_bIsVertical;
-};
-
-/*!
-  \class QtxDockTitleLabel
-  \internal
-  \brief Internal class that implements customizable title label for a dock widget.
-*/
-class QtxDockTitleLabel : public QLabel
-{
-  Q_OBJECT
-public:
-
-  QtxDockTitleLabel( const QString& theText, QWidget* theParent );
-  virtual ~QtxDockTitleLabel() {}
 
-  void          setVertical( const bool& isVertical );
-  bool          isVertical() const { return m_bIsVertical; }
-
-  virtual QSize sizeHint() const;
-  virtual QSize minimumSizeHint() const;
-
-private:
-  bool          m_bIsVertical;
-  bool          m_bIsModified;
-};
 
 
 QtxDockTitleLabel::QtxDockTitleLabel( const QString& theText, QWidget* theParent )
@@ -106,6 +81,15 @@ QtxDockTitleLabel::QtxDockTitleLabel( const QString& theText, QWidget* theParent
   setStyle( new QtxDockTitleStyle( m_bIsVertical ) );
 }
 
+QtxDockTitleLabel::~QtxDockTitleLabel()
+{
+}
+
+bool QtxDockTitleLabel::isVertical() const
+{
+  return m_bIsVertical;
+}
+
 void QtxDockTitleLabel::setVertical( const bool& isVertical )
 {
   m_bIsVertical = isVertical;
@@ -140,51 +124,7 @@ QSize QtxDockTitleLabel::minimumSizeHint() const
   return QSize( 0, 0 );
 }
 
-/*!
-  \class QtxDockWidgetTitle
-  \internal
-  \brief Internal class that implements customizable title bar for a dock widget.
-
-  This is a convenient implementation of an application-defined title bar widget.
-  It contains a label with the window title, Undock and Close buttons by default, 
-  and any number of widgets can be inserted at required position into the title's QHBoxLayout.
-  Support for vertical title bar is not yet implemented.
-*/
 
-class QtxDockWidgetTitle : public QWidget
-{
-  Q_OBJECT
-
-public:
-
-  QtxDockWidgetTitle( QtxDockWidget* parent );
-  virtual ~QtxDockWidgetTitle();
-
-  QWidget*            widget( const int ) const;
-  int                 role( QWidget* ) const;
-
-  void                insertWidget( const int, QWidget* widget, const int = QtxDockWidget::Last );
-  void                removeWidget( const int );
-
-protected:
-  virtual void        paintEvent ( QPaintEvent* event );
-
-public slots:
-  virtual void        updateTitleBar();
-
-private:
-  void                initStyleOption( QStyleOptionDockWidget* ) const;
-  void                setupButton( QToolButton*, const int, QStyleOptionDockWidget*, QDockWidget* );
-  void                setLayout( const bool& );
-  void                fillLayout();
-
-
-private:
-  typedef QPair< int, QWidget* > RoleWidget;
-  typedef QList< RoleWidget > RoleWidgetList;
-
-  RoleWidgetList      myWidgets;
-};
 
 static inline bool hasFeature(const QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature)
 { return (dockwidget->features() & feature) == feature; }
@@ -973,5 +913,3 @@ void QtxDockWidget::updateState()
   \brief Emitted when the dockable window orientation is changed.
   \param o new window orientation
 */
-
-#include <QtxDockWidget.moc>
index 876204ea1415a78159f76d8c693b642d36ca89e3..0cf721391d6fad28e1717c0326ed2d58b3189ffa 100644 (file)
 #define QTXDOCKWIDGET_H
 
 #include "Qtx.h"
-
 #include <QDockWidget>
+#include <QWindowsStyle>
+#include <QLabel>
+
+class QToolButton;
 
 class QTX_EXPORT QtxDockWidget : public QDockWidget
 {
@@ -78,4 +81,99 @@ private:
   Qt::Orientation myOrientation;   //!< dockable window orientation
 };
 
+/*!
+  \class QtxDockTitleStyle
+  \internal
+  \brief Internal class that implements customizable label style for a dock widget.
+*/
+class QtxDockTitleStyle : public QWindowsStyle
+{
+  Q_OBJECT
+
+public:
+  QtxDockTitleStyle( const bool& isVertical );
+  virtual ~QtxDockTitleStyle();
+
+  void   setVertical( const bool& isVertical );
+  bool   isVertical() const;
+
+  virtual void drawItemText( QPainter* painter, const QRect& rectangle,
+                      int alignment, const QPalette& palette,
+                      bool enabled, const QString& text,
+                     QPalette::ColorRole textRole = QPalette::NoRole ) const;
+private:
+  bool   m_bIsVertical;
+};
+
+/*!
+  \class QtxDockTitleLabel
+  \internal
+  \brief Internal class that implements customizable title label for a dock widget.
+*/
+class QtxDockTitleLabel : public QLabel
+{
+  Q_OBJECT
+public:
+
+  QtxDockTitleLabel( const QString& theText, QWidget* theParent );
+  virtual ~QtxDockTitleLabel();
+
+  void          setVertical( const bool& isVertical );
+  bool          isVertical() const;
+
+  virtual QSize sizeHint() const;
+  virtual QSize minimumSizeHint() const;
+
+private:
+  bool          m_bIsVertical;
+  bool          m_bIsModified;
+};
+
+/*!
+  \class QtxDockWidgetTitle
+  \internal
+  \brief Internal class that implements customizable title bar for a dock widget.
+
+  This is a convenient implementation of an application-defined title bar widget.
+  It contains a label with the window title, Undock and Close buttons by default, 
+  and any number of widgets can be inserted at required position into the title's QHBoxLayout.
+  Support for vertical title bar is not yet implemented.
+*/
+
+class QtxDockWidgetTitle : public QWidget
+{
+  Q_OBJECT
+
+public:
+
+  QtxDockWidgetTitle( QtxDockWidget* parent );
+  virtual ~QtxDockWidgetTitle();
+
+  QWidget*            widget( const int ) const;
+  int                 role( QWidget* ) const;
+
+  void                insertWidget( const int, QWidget* widget, const int = QtxDockWidget::Last );
+  void                removeWidget( const int );
+
+protected:
+  virtual void        paintEvent ( QPaintEvent* event );
+
+public slots:
+  virtual void        updateTitleBar();
+
+private:
+  void                initStyleOption( QStyleOptionDockWidget* ) const;
+  void                setupButton( QToolButton*, const int, QStyleOptionDockWidget*, QDockWidget* );
+  void                setLayout( const bool& );
+  void                fillLayout();
+
+
+private:
+  typedef QPair< int, QWidget* > RoleWidget;
+  typedef QList< RoleWidget > RoleWidgetList;
+
+  RoleWidgetList      myWidgets;
+};
+
+
 #endif // QTXDOCKWIDGET_H
index 9964965638fca3392f3bb55ce2ddd23e41940a3e..f72e5ce314dde62365065eecd876ba2a51ea92ad 100644 (file)
 #include "QtxTreeModel.h"
 
 #include <QApplication>
-#include <QHeaderView>
 #include <QMenu>
 #include <QMouseEvent>
 #include <QPainter>
 #include <QPalette>
 
-/*!
-  \class QtxTreeView::Header
-  \brief Custom tree view header class.
-  \internal
-*/
-
-class QtxTreeView::Header : public QHeaderView
-{
-  Q_OBJECT
-public:
-  Header( const bool, QWidget* = 0 );
-  ~Header();
-
-  void         setSortMenuEnabled( const bool );
-  bool         sortMenuEnabled() const;
-
-  void         setSortingEnabled( const bool );
-  bool         sortingEnabled() const;
-  void         setMultiSortEnabled( const bool );
-  bool         multiSortEnabled() const;
-  void         setSortIndicators( const QVector<int>&, const QVector<Qt::SortOrder>& );
-  void         sortIndicators( QVector<int>&, QVector<Qt::SortOrder>& ) const;
-  void         clearSortIndicators();
-  bool         sortIndicatorsShown() const;
-
-  void         addMenuAction( QAction* );
-protected:
-  virtual void contextMenuEvent( QContextMenuEvent* );
-  virtual void paintSection( QPainter* painter, const QRect& rect, int logicalIndex ) const;
-
-private slots:
-  void         onSectionClicked( int logicalIndex );
-
-private:
-  typedef QMap<int, QAction*> ActionsMap;
-  bool                   myEnableSortMenu;
-  ActionsMap             myActions;
-  bool                   myEnableMultiSort;
-  QVector<int>           mySortSections;
-  QVector<Qt::SortOrder> mySortOrders;
-};
-
 /*!
   \brief Constructor
   \param enableSortMenu show "Sorting" menu if \c true
@@ -817,5 +774,3 @@ void QtxTreeView::keyboardSearch( const QString& search )
   if ( isKeyboardSearchEnabled() )
     QAbstractItemView::keyboardSearch( search );
 }
-
-#include <QtxTreeView.moc>
index a80f9976babb568a542cba7c50884e4f466685a2..5f6b0e364b95854726fae539429ff7c1ea20b6f0 100644 (file)
@@ -30,6 +30,7 @@
 #endif
 
 #include <QTreeView>
+#include <QHeaderView>
 
 class QTX_EXPORT QtxTreeView : public QTreeView
 {
@@ -95,6 +96,48 @@ private:
   friend class QtxTreeView::Header;
 };
 
+/*!
+  \class QtxTreeView::Header
+  \brief Custom tree view header class.
+  \internal
+*/
+
+class QtxTreeView::Header : public QHeaderView
+{
+  Q_OBJECT
+public:
+  Header( const bool, QWidget* = 0 );
+  ~Header();
+
+  void         setSortMenuEnabled( const bool );
+  bool         sortMenuEnabled() const;
+
+  void         setSortingEnabled( const bool );
+  bool         sortingEnabled() const;
+  void         setMultiSortEnabled( const bool );
+  bool         multiSortEnabled() const;
+  void         setSortIndicators( const QVector<int>&, const QVector<Qt::SortOrder>& );
+  void         sortIndicators( QVector<int>&, QVector<Qt::SortOrder>& ) const;
+  void         clearSortIndicators();
+  bool         sortIndicatorsShown() const;
+
+  void         addMenuAction( QAction* );
+protected:
+  virtual void contextMenuEvent( QContextMenuEvent* );
+  virtual void paintSection( QPainter* painter, const QRect& rect, int logicalIndex ) const;
+
+private slots:
+  void         onSectionClicked( int logicalIndex );
+
+private:
+  typedef QMap<int, QAction*> ActionsMap;
+  bool                   myEnableSortMenu;
+  ActionsMap             myActions;
+  bool                   myEnableMultiSort;
+  QVector<int>           mySortSections;
+  QVector<Qt::SortOrder> mySortOrders;
+};
+
 #ifdef WIN32
 #pragma warning( default:4251 )
 #endif
index f20dc56330d901e26552e2e12a4dd84c2e3df7f6..a1306377ae2fbca6a844bc2e60cf4bcd835132b1 100755 (executable)
@@ -103,6 +103,8 @@ public:
   //! Invokes application-specific "Select Directory" dialog and returns the selected directory name.
   virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
 
+  QAction*              action( const int ) const;
+
 signals:
   void                  applicationClosed( SUIT_Application* );
   void                  activated( SUIT_Application* );
@@ -151,7 +153,6 @@ protected:
   void                  setActionShown( const int, const bool );
 
   static QAction*       separator();
-  QAction*              action( const int ) const;
   int                   actionId( const QAction* ) const;
 
   QList<QAction*>       actions() const;
index 53a821269d308c3ac58da7874015418be6472402..d8b6c2e67ce0b4c586be6d2a7311dc7776de027a 100755 (executable)
@@ -63,7 +63,7 @@ public:
   SUIT_DataObject( SUIT_DataObject* = 0 );
   virtual ~SUIT_DataObject();
 
-  SUIT_DataObject*            root() const;
+  virtual SUIT_DataObject*    root() const;
   SUIT_DataObject*            lastChild() const;
   SUIT_DataObject*            firstChild() const;
 
index 841ff6dc700173283238017712b6204c75cb3a97..4768eb788c33dfe89a088f0bbc9aabd4bca710e6 100755 (executable)
@@ -1078,7 +1078,8 @@ void SUIT_TreeModel::removeItem( SUIT_TreeModel::TreeItem* item )
 
   // Warning! obj can be deleted at this point!
 
-  SUIT_DataObject* parentObj = object( item->parent() );
+  TreeItem* parent=item->parent();
+  SUIT_DataObject* parentObj = object( parent );
   QModelIndex parentIdx = index( parentObj, 0 );
   int row = item->position();
 
@@ -1088,7 +1089,7 @@ void SUIT_TreeModel::removeItem( SUIT_TreeModel::TreeItem* item )
   if ( obj == root() )
     setRoot( 0 );
   else if ( item->parent() )
-    item->parent()->removeChild( item );
+    parent->removeChild( item );
 
   delete item;