OCCViewer_CreateRestoreViewDlg.h \
OCCViewer.h \
OCCViewer_ClippingDlg.h \
+ OCCViewer_AxialScaleDlg.h \
OCCViewer_SetRotationPointDlg.h
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 \
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 = \
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 \
--- /dev/null
+// 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();
+}
+
--- /dev/null
+// 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
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 );
}
}
double eyeY;
double eyeZ;
QString name;
+ double scaleX;
+ double scaleY;
+ double scaleZ;
};
typedef QValueList<viewAspect> viewAspectList;
#include "OCCViewer_CreateRestoreViewDlg.h"
#include "OCCViewer_ClippingDlg.h"
#include "OCCViewer_SetRotationPointDlg.h"
+#include "OCCViewer_AxialScaleDlg.h"
#include "SUIT_Desktop.h"
#include "SUIT_Session.h"
myEnableDrawMode = false;
updateEnabledDrawMode();
myClippingDlg = 0;
+ myScalingDlg = 0;
mySetRotationPointDlg = 0;
mypSketcher = 0;
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;
}
/*!
myToolBar->addSeparator();
myActionsMap[ClippingId]->addTo(myToolBar);
+ myActionsMap[AxialScaleId]->addTo(myToolBar);
}
/*!
}
}
+/*!
+ 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
*/
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;
}
{
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();
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;
params.eyeY = eyeY;
params.eyeZ = eyeZ;
params.name = aName;
+ params.scaleX = aScaleX;
+ params.scaleY = aScaleY;
+ params.scaleZ = aScaleZ;
return params;
}
{
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;
}
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();
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 );
}
class OCCViewer_ViewPort3d;
class OCCViewer_ClippingDlg;
+class OCCViewer_AxialScaleDlg;
class OCCViewer_SetRotationPointDlg;
#ifdef WIN32
void onSetRotationPoint( bool on );
void onCloneView();
void onClipping( bool on );
+ void onAxialScale();
void onMemorizeView();
void onRestoreView();
void onTrihedronShow();
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;
OCCViewer_ClippingDlg* myClippingDlg;
QtxAction* myClippingAction;
+ OCCViewer_AxialScaleDlg* myScalingDlg;
+
OCCViewer_SetRotationPointDlg* mySetRotationPointDlg;
QtxAction* mySetRotationPointAction;
msgid "ICON_OCCVIEWER_PRESETS_VIEW"
msgstr "view_presets.png"
-
+msgid "ICON_OCCVIEWER_SCALING"
+msgstr "view_scaling.png"
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"
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:"
+