]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
NPAL19067: To have a scaling button in the OCC View like in the VTK view.
authorvtn <vtn@opencascade.com>
Wed, 2 Apr 2008 14:04:21 +0000 (14:04 +0000)
committervtn <vtn@opencascade.com>
Wed, 2 Apr 2008 14:04:21 +0000 (14:04 +0000)
src/OCCViewer/Makefile.am
src/OCCViewer/OCCViewer_AxialScaleDlg.cxx [new file with mode: 0644]
src/OCCViewer/OCCViewer_AxialScaleDlg.h [new file with mode: 0644]
src/OCCViewer/OCCViewer_CreateRestoreViewDlg.cxx
src/OCCViewer/OCCViewer_ViewModel.h
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h
src/OCCViewer/resources/OCCViewer_images.po
src/OCCViewer/resources/OCCViewer_msg_en.po
src/OCCViewer/resources/view_scaling.png [new file with mode: 0644]

index 2bfc88875c944a25c531834f447e6d200a309e58..8d5b227d13d5a041498307e24a7d801d0f524147 100755 (executable)
@@ -37,6 +37,7 @@ salomeinclude_HEADERS= \
        OCCViewer_CreateRestoreViewDlg.h \
        OCCViewer.h \
        OCCViewer_ClippingDlg.h \
+       OCCViewer_AxialScaleDlg.h \
        OCCViewer_SetRotationPointDlg.h
 
 dist_libOCCViewer_la_SOURCES= \
@@ -50,7 +51,8 @@ dist_libOCCViewer_la_SOURCES= \
        OCCViewer_VService.cxx \
        OCCViewer_CreateRestoreViewDlg.cxx \
        OCCViewer_SetRotationPointDlg.cxx \
-       OCCViewer_ClippingDlg.cxx
+       OCCViewer_ClippingDlg.cxx \
+       OCCViewer_AxialScaleDlg.cxx
 
 MOC_FILES= \
        OCCViewer_AISSelector_moc.cxx \
@@ -62,7 +64,8 @@ MOC_FILES= \
        OCCViewer_ViewManager_moc.cxx \
        OCCViewer_CreateRestoreViewDlg_moc.cxx \
        OCCViewer_SetRotationPointDlg_moc.cxx \
-       OCCViewer_ClippingDlg_moc.cxx
+       OCCViewer_ClippingDlg_moc.cxx \
+       OCCViewer_AxialScaleDlg_moc.cxx
 nodist_libOCCViewer_la_SOURCES= $(MOC_FILES)
 
 dist_salomeres_DATA = \
@@ -72,6 +75,7 @@ dist_salomeres_DATA = \
        resources/view_clone.png \
        resources/view_clipping.png \
        resources/view_clipping_pressed.png \
+       resources/view_scaling.png \
        resources/view_fitall.png \
        resources/view_fitarea.png \
        resources/view_front.png \
diff --git a/src/OCCViewer/OCCViewer_AxialScaleDlg.cxx b/src/OCCViewer/OCCViewer_AxialScaleDlg.cxx
new file mode 100644 (file)
index 0000000..83f2068
--- /dev/null
@@ -0,0 +1,191 @@
+// 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_AxialScaleDlg.h"
+#include "OCCViewer_ViewWindow.h"
+#include "OCCViewer_ViewPort3d.h"
+
+#include <Standard_Real.hxx>
+
+#include "QtxDblSpinBox.h"
+
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+
+/*!
+  Constructor
+  \param view - view window
+  \param parent - parent widget
+  \param name - dialog name
+  \param modal - is this dialog modal
+  \param fl - flags
+*/
+OCCViewer_AxialScaleDlg::OCCViewer_AxialScaleDlg( OCCViewer_ViewWindow* view, QWidget* parent, const char* name, bool modal, WFlags fl )
+: QDialog( parent, "OCCViewer_AxialScaleDlg", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ),
+  myView( view )
+{
+  setCaption( tr( "DLG_SCALING" ) );
+  
+  setSizeGripEnabled(TRUE);
+
+  // Create layout for this dialog
+  QGridLayout* layoutDlg = new QGridLayout (this);
+  layoutDlg->setSpacing(6);
+  layoutDlg->setMargin(11);
+
+  // Create croup box with grid layout
+  QGroupBox* aGroupBox = new QGroupBox(this, "GroupBox");
+  QHBoxLayout* aHBoxLayout = new QHBoxLayout(aGroupBox);
+  aHBoxLayout->setMargin(11);
+  aHBoxLayout->setSpacing(6);
+
+  // "X" scaling
+  QLabel* TextLabelX = new QLabel (tr("LBL_X"), aGroupBox, "TextLabelX");
+  TextLabelX->setFixedWidth(15);
+  m_sbXcoeff = new QtxDblSpinBox(1e-7, RealLast(), 0.1, aGroupBox);
+  m_sbXcoeff->setMinimumWidth(80);
+  m_sbXcoeff->setValue(1.0);
+
+  // "Y" scaling
+  QLabel* TextLabelY = new QLabel (tr("LBL_Y"), aGroupBox, "TextLabelY");
+  TextLabelY->setFixedWidth(15);
+  m_sbYcoeff = new QtxDblSpinBox(1e-7, RealLast(), 0.1, aGroupBox);
+  m_sbYcoeff->setMinimumWidth(80);
+  m_sbYcoeff->setValue(1.0);
+
+  // "Z" scaling
+  QLabel* TextLabelZ = new QLabel (tr("LBL_Z"), aGroupBox, "TextLabelZ");
+  TextLabelZ->setFixedWidth(15);
+  m_sbZcoeff = new QtxDblSpinBox(1e-7, RealLast(), 0.1, aGroupBox);
+  m_sbZcoeff->setMinimumWidth(80);
+  m_sbZcoeff->setValue(1.0);
+
+  // Create <Reset> button
+  m_bReset = new QPushButton(tr("&Reset"), aGroupBox, "m_bReset");
+
+  // Layout widgets in the group box
+  aHBoxLayout->addWidget(TextLabelX);
+  aHBoxLayout->addWidget(m_sbXcoeff);
+  aHBoxLayout->addWidget(TextLabelY);
+  aHBoxLayout->addWidget(m_sbYcoeff);
+  aHBoxLayout->addWidget(TextLabelZ);
+  aHBoxLayout->addWidget(m_sbZcoeff);
+  //aHBoxLayout->addStretch();
+  aHBoxLayout->addWidget(m_bReset);
+
+  // OK, CANCEL, Apply button
+  QGroupBox* aGroupBox2 = new QGroupBox(this);
+  QHBoxLayout* aHBoxLayout2 = new QHBoxLayout(aGroupBox2);
+  aHBoxLayout2->setMargin(11);
+  aHBoxLayout2->setSpacing(6);
+  // Create <OK> button
+  QPushButton* m_bOk = new QPushButton(tr("O&K"), aGroupBox2, "m_bOk");
+  m_bOk->setDefault(TRUE);
+  m_bOk->setAutoDefault(TRUE);
+  // Create <Apply> button
+  QPushButton* m_bApply = new QPushButton(tr("&Apply"), aGroupBox2, "m_bApply");
+  m_bApply->setAutoDefault(TRUE);
+  // Create <Cancel> button
+  QPushButton* m_bCancel = new QPushButton(tr("&Cancel"), aGroupBox2, "m_bCancel");
+  m_bCancel->setAutoDefault(TRUE);
+
+  // Layout buttons
+  aHBoxLayout2->addWidget(m_bOk);
+  aHBoxLayout2->addWidget(m_bApply);
+  aHBoxLayout2->addStretch();
+  aHBoxLayout2->addWidget(m_bCancel);
+
+  // Layout top level widgets
+  layoutDlg->addWidget(aGroupBox,0,0);
+  layoutDlg->addWidget(aGroupBox2,1,0);
+
+  // signals and slots connections
+  connect(m_bCancel, SIGNAL(clicked()), this, SLOT(onClickClose()));
+  connect(m_bOk,     SIGNAL(clicked()), this, SLOT(onClickOk()));
+  connect(m_bApply,  SIGNAL(clicked()), this, SLOT(onClickApply()));
+  connect(m_bReset,  SIGNAL(clicked()), this, SLOT(onClickReset()));
+
+  connect(view, SIGNAL(Hide( QHideEvent * )), this, SLOT(onViewHide()));
+
+  this->resize(100, this->sizeHint().height());
+}
+
+/*!
+  Destructor
+  Destroys the object and frees any allocated resources
+*/
+OCCViewer_AxialScaleDlg::~OCCViewer_AxialScaleDlg()
+{
+  // no need to delete child widgets, Qt does it all for us
+}
+
+void 
+OCCViewer_AxialScaleDlg
+::Update()
+{
+  // Get values from the OCC view
+  Standard_Real aScaleFactor[3];
+  myView->getViewPort()->getView()->AxialScale(aScaleFactor[0],aScaleFactor[1],aScaleFactor[2]);
+  m_sbXcoeff->setValue(aScaleFactor[0]);
+  m_sbYcoeff->setValue(aScaleFactor[1]);
+  m_sbZcoeff->setValue(aScaleFactor[2]);
+}
+
+void 
+OCCViewer_AxialScaleDlg
+::onClickOk()
+{
+  //apply changes
+  onClickApply();
+  //Close dialog
+  accept();
+}
+
+void
+OCCViewer_AxialScaleDlg
+::onClickApply()
+{
+  double aScaleFactor[3] = {m_sbXcoeff->value(), m_sbYcoeff->value(), m_sbZcoeff->value()};
+  myView->getViewPort()->getView()->SetAxialScale(aScaleFactor[0],aScaleFactor[1],aScaleFactor[2]);
+}
+
+void
+OCCViewer_AxialScaleDlg
+::onClickReset()
+{
+  m_bReset->setFocus();
+  m_sbXcoeff->setValue(1.0);
+  m_sbYcoeff->setValue(1.0);
+  m_sbZcoeff->setValue(1.0);
+}
+
+void 
+OCCViewer_AxialScaleDlg
+::onClickClose()
+{
+  reject();
+}
+
+void OCCViewer_AxialScaleDlg::onViewHide()
+{
+  hide();
+}
+
diff --git a/src/OCCViewer/OCCViewer_AxialScaleDlg.h b/src/OCCViewer/OCCViewer_AxialScaleDlg.h
new file mode 100644 (file)
index 0000000..c0dc9ed
--- /dev/null
@@ -0,0 +1,62 @@
+// 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_AXIALSCALEDLG_H
+#define OCCVIEWER_AXIALSCALEDLG_H
+
+#include "OCCViewer.h"
+
+#include <qdialog.h>
+
+class OCCViewer_ViewWindow;
+
+class QtxDblSpinBox;
+class QPushButton;
+
+/*!
+  \class OCCViewer_AxialScaleDlg
+  \brief Dialog allowing to assign parameters of axes scaling
+*/
+class OCCViewer_AxialScaleDlg : public QDialog
+{
+    Q_OBJECT
+    
+    public:
+    OCCViewer_AxialScaleDlg(OCCViewer_ViewWindow* , QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0);
+    ~OCCViewer_AxialScaleDlg();
+
+    void Update();
+
+protected:
+    OCCViewer_ViewWindow *myView;
+    
+    QtxDblSpinBox* m_sbXcoeff;
+    QtxDblSpinBox* m_sbYcoeff;
+    QtxDblSpinBox* m_sbZcoeff;
+    QPushButton* m_bReset;
+
+protected slots:
+    void onClickApply();
+    void onClickReset();
+    void onClickOk();
+    void onClickClose();
+
+    void onViewHide();
+};
+
+#endif // OCCVIEWER_AXIALSCALEDLG_H
index e97cde8b9a9bbffcf3e3eb82050dfcf37bbcfab1..c53037040ee6467efb72aa2c0bd65384a982adfc 100755 (executable)
@@ -153,6 +153,7 @@ void OCCViewer_CreateRestoreViewDlg::changeImage( QListBoxItem* curItem )
                aView3d->SetAt( myCurrentItem.atX, myCurrentItem.atY, myCurrentItem.atZ );
                aView3d->SetImmediateUpdate( prev );
                aView3d->SetEye( myCurrentItem.eyeX, myCurrentItem.eyeY, myCurrentItem.eyeZ );
+               aView3d->SetAxialScale( myCurrentItem.scaleX, myCurrentItem.scaleY, myCurrentItem.scaleZ );
         }
 }
 
index 654dec238b0a2f1a34b32ab0734876042a3b18c4..e43201ada70d3954984b5ec5cbe42cb998f094a7 100755 (executable)
@@ -52,6 +52,9 @@ public:
        double     eyeY;
        double     eyeZ;
        QString    name;
+        double   scaleX;
+        double   scaleY;
+        double   scaleZ;
 };
 
 typedef QValueList<viewAspect> viewAspectList;
index 78bd7147e870c31cda7a521668d7c1fd5b761668..cf924147f180a6d018b3f6972bcf019cf891fc6f 100755 (executable)
@@ -27,6 +27,7 @@
 #include "OCCViewer_CreateRestoreViewDlg.h"
 #include "OCCViewer_ClippingDlg.h"
 #include "OCCViewer_SetRotationPointDlg.h"
+#include "OCCViewer_AxialScaleDlg.h"
 
 #include "SUIT_Desktop.h"
 #include "SUIT_Session.h"
@@ -192,6 +193,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_V
   myEnableDrawMode = false;
   updateEnabledDrawMode();
   myClippingDlg = 0;
+  myScalingDlg = 0;
   mySetRotationPointDlg = 0;
 
   mypSketcher = 0;
@@ -1006,6 +1008,13 @@ void OCCViewer_ViewWindow::createActions()
     connect(aAction, SIGNAL(activated()), this, SLOT(onTrihedronShow()));
          myActionsMap[ TrihedronShowId ] = aAction;
   }
+
+  // Scale
+  aAction = new QtxAction(tr("MNU_SCALING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SCALING" ) ),
+                           tr( "MNU_SCALING" ), 0, this);
+  aAction->setStatusTip(tr("DSC_SCALING"));
+  connect(aAction, SIGNAL(activated()), this, SLOT(onAxialScale()));
+  myActionsMap[ AxialScaleId ] = aAction;
 }
 
 /*!
@@ -1049,6 +1058,7 @@ void OCCViewer_ViewWindow::createToolBar()
   
   myToolBar->addSeparator();
   myActionsMap[ClippingId]->addTo(myToolBar);
+  myActionsMap[AxialScaleId]->addTo(myToolBar);
 }
 
 /*!
@@ -1217,6 +1227,20 @@ void OCCViewer_ViewWindow::onClipping( bool on )
     }
 }
 
+/*!
+  Creates one more window with same content
+*/
+void OCCViewer_ViewWindow::onAxialScale()
+{
+  if ( !myScalingDlg )
+    {
+      myScalingDlg = new OCCViewer_AxialScaleDlg( this, myDesktop );
+    }
+
+  if ( !myScalingDlg->isShown() )
+    myScalingDlg->show();
+}
+
 /*!
   Stores view parameters
 */
@@ -1253,6 +1277,7 @@ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem )
        aView3d->SetImmediateUpdate( prev );
        aView3d->SetEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ );
        aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ );
+       aView3d->SetAxialScale( anItem.scaleX, anItem.scaleY, anItem.scaleZ );
                
        myRestoreFlag = 0;
 }
@@ -1342,6 +1367,7 @@ viewAspect OCCViewer_ViewWindow::getViewParams() const
 {
   double centerX, centerY, projX, projY, projZ, twist;
   double atX, atY, atZ, eyeX, eyeY, eyeZ;
+  Standard_Real aScaleX, aScaleY, aScaleZ;
 
   Handle(V3d_View) aView3d = myViewPort->getView();
 
@@ -1351,6 +1377,8 @@ viewAspect OCCViewer_ViewWindow::getViewParams() const
   aView3d->Eye( eyeX, eyeY, eyeZ );
   twist = aView3d->Twist();
 
+  aView3d->AxialScale(aScaleX,aScaleY,aScaleZ);
+
   QString aName = QTime::currentTime().toString() + QString::fromLatin1( " h:m:s" );
 
   viewAspect params;
@@ -1368,6 +1396,9 @@ viewAspect OCCViewer_ViewWindow::getViewParams() const
   params.eyeY     = eyeY;
   params.eyeZ     = eyeZ;
   params.name    = aName;
+  params.scaleX   = aScaleX;
+  params.scaleY   = aScaleY;
+  params.scaleZ   = aScaleZ;
 
   return params;
 }
@@ -1380,9 +1411,10 @@ 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,
+  retStr.sprintf( "%.12e*%.12e*%.12e*%.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 );
+                 params.atX, params.atY, params.atZ, params.eyeX, params.eyeY, params.eyeZ,
+                 params.scaleX, params.scaleY, params.scaleZ );
   return retStr;
 }
 
@@ -1392,7 +1424,7 @@ QString OCCViewer_ViewWindow::getVisualParameters()
 void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters )
 {
   QStringList paramsLst = QStringList::split( '*', parameters, true );
-  if ( paramsLst.size() == 13 ) {
+  if ( paramsLst.size() >= 13 ) {
     viewAspect params;
     params.scale    = paramsLst[0].toDouble();
     params.centerX  = paramsLst[1].toDouble();
@@ -1407,6 +1439,15 @@ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters )
     params.eyeX     = paramsLst[10].toDouble();
     params.eyeY     = paramsLst[11].toDouble();
     params.eyeZ     = paramsLst[12].toDouble();
+    if(paramsLst.size() == 16) {
+      params.scaleX    = paramsLst[13].toDouble();
+      params.scaleY    = paramsLst[14].toDouble();
+      params.scaleZ    = paramsLst[15].toDouble();
+    } else {
+      params.scaleX    = 1.;
+      params.scaleY    = 1.;
+      params.scaleZ    = 1.;
+    }
 
     performRestoring( params );
   }
index c3e7ca9f48390079725cea2cee9e05ac215daa6c..0e4062f8afe5a46279f0d01a95ae68a4c4bb10a3 100755 (executable)
@@ -33,6 +33,7 @@ class SUIT_Desktop;
 class OCCViewer_ViewPort3d;
 
 class OCCViewer_ClippingDlg;
+class OCCViewer_AxialScaleDlg;
 class OCCViewer_SetRotationPointDlg;
 
 #ifdef WIN32
@@ -98,6 +99,7 @@ public slots:
   void onSetRotationPoint( bool on );
   void onCloneView();
   void onClipping( bool on );
+  void onAxialScale();
   void onMemorizeView();
   void onRestoreView();
   void onTrihedronShow();
@@ -123,7 +125,7 @@ protected:
   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId,
         ChangeRotationPointId, RotationId,
          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId,
-         TrihedronShowId };
+         TrihedronShowId, AxialScaleId };
 
   typedef QMap<int, QtxAction*> ActionsMap;
 
@@ -197,6 +199,8 @@ private:
   OCCViewer_ClippingDlg* myClippingDlg;
   QtxAction* myClippingAction;
 
+  OCCViewer_AxialScaleDlg* myScalingDlg;
+
   OCCViewer_SetRotationPointDlg* mySetRotationPointDlg;
   QtxAction* mySetRotationPointAction;
   
index 4ab78a38d3f3a9953f24e99107717e6470c4a535..b5b6ee052b2c3ef8447a930b9846e21a295a8340 100755 (executable)
@@ -95,5 +95,6 @@ msgstr "view_shoot.png"
 msgid "ICON_OCCVIEWER_PRESETS_VIEW"
 msgstr "view_presets.png"
 
-
+msgid "ICON_OCCVIEWER_SCALING"
+msgstr "view_scaling.png"
 
index 71689709e2598921bad867f688f6aee6749b8c4e..f19fb91b4ec8eb676983dad838939c66b9a437ce 100755 (executable)
@@ -164,6 +164,12 @@ msgstr "Set clipping plane"
 msgid "MNU_CLIPPING"
 msgstr "Clipping"
 
+msgid "DSC_SCALING"
+msgstr "Change scale of axes"
+
+msgid "MNU_SCALING"
+msgstr "Scaling"
+
 msgid "DSC_DUMP_VIEW"
 msgstr "Saves the active view in the image file"
 
@@ -218,3 +224,16 @@ msgstr "Show/Hide trihedron"
 
 msgid "DSC_SHOW_TRIHEDRE"
 msgstr "Show/Hide trihedron in the current view"
+
+msgid "OCCViewer_AxialScaleDlg::DLG_SCALING"
+msgstr "Axes scaling"
+
+msgid "OCCViewer_AxialScaleDlg::LBL_X"
+msgstr "X:"
+
+msgid "OCCViewer_AxialScaleDlg::LBL_Y"
+msgstr "Y:"
+
+msgid "OCCViewer_AxialScaleDlg::LBL_Z"
+msgstr "Z:"
+
diff --git a/src/OCCViewer/resources/view_scaling.png b/src/OCCViewer/resources/view_scaling.png
new file mode 100644 (file)
index 0000000..5d34436
Binary files /dev/null and b/src/OCCViewer/resources/view_scaling.png differ