From: asl Date: Thu, 14 Aug 2014 13:05:53 +0000 (+0000) Subject: GUI for local coordinate system X-Git-Tag: master_20140820~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b05a5367fb4b71ce222e1d52196c81638575da8c;p=modules%2Fhydro.git GUI for local coordinate system --- diff --git a/src/HYDROGUI/HYDROGUI_LocalCSDlg.cxx b/src/HYDROGUI/HYDROGUI_LocalCSDlg.cxx new file mode 100644 index 00000000..2b0168b3 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LocalCSDlg.cxx @@ -0,0 +1,73 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// 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 +#include +#include +#include + +const double RANGE = 1E+10; +const double STEP = 1.00; +const double PREC = 2; + +HYDROGUI_LocalCSDlg::HYDROGUI_LocalCSDlg( HYDROGUI_Module* theModule, const QString& theTitle ) +: HYDROGUI_InputPanel( theModule, theTitle ) +{ + QFrame* aFrame = new QFrame( mainFrame() ); + addWidget( aFrame, 1 ); + + QGridLayout* aLayout = new QGridLayout( aFrame ); + + myLX = new QtxDoubleSpinBox( 0, RANGE, STEP, PREC, PREC, aFrame ); + myLX->setValue( 0.0 ); + myLY = new QtxDoubleSpinBox( 0, RANGE, STEP, PREC, PREC, aFrame ); + myLY->setValue( 0.0 ); + + aLayout->addWidget( new QLabel( tr( "LX" ), aFrame ), 0, 0 ); + aLayout->addWidget( myLX, 0, 1 ); + aLayout->addWidget( new QLabel( tr( "LY" ), aFrame ), 1, 0 ); + aLayout->addWidget( myLY, 1, 1 ); + aLayout->setColumnStretch( 0, 0 ); + aLayout->setColumnStretch( 1, 1 ); + aLayout->setRowStretch( 2, 1 ); +} + +HYDROGUI_LocalCSDlg::~HYDROGUI_LocalCSDlg() +{ +} + +double HYDROGUI_LocalCSDlg::GetLocalX() const +{ + return myLX->value(); +} + +double HYDROGUI_LocalCSDlg::GetLocalY() const +{ + return myLY->value(); +} + +void HYDROGUI_LocalCSDlg::SetLocalCS( double theLX, double theLY ) +{ + myLX->setValue( theLX ); + myLY->setValue( theLY ); +} + diff --git a/src/HYDROGUI/HYDROGUI_LocalCSDlg.h b/src/HYDROGUI/HYDROGUI_LocalCSDlg.h new file mode 100644 index 00000000..f0fd13c2 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LocalCSDlg.h @@ -0,0 +1,47 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// 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 HYDROGUI_LocalCSDlg_H +#define HYDROGUI_LocalCSDlg_H + +#include "HYDROGUI_InputPanel.h" + +class QtxDoubleSpinBox; + +class HYDROGUI_LocalCSDlg : public HYDROGUI_InputPanel +{ + Q_OBJECT + +public: + HYDROGUI_LocalCSDlg( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_LocalCSDlg(); + + double GetLocalX() const; + double GetLocalY() const; + void SetLocalCS( double theLX, double theLY ); + +private: + QtxDoubleSpinBox* myLX; + QtxDoubleSpinBox* myLY; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_LocalCSOp.cxx b/src/HYDROGUI/HYDROGUI_LocalCSOp.cxx new file mode 100644 index 00000000..228a9fab --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LocalCSOp.cxx @@ -0,0 +1,72 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// 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 +#include +#include +#include +#include + +HYDROGUI_LocalCSOp::HYDROGUI_LocalCSOp( HYDROGUI_Module* theModule ) +: HYDROGUI_Operation( theModule ) +{ + setName( tr( "EDIT_LOCAL_CS" ) ); +} + +HYDROGUI_LocalCSOp::~HYDROGUI_LocalCSOp() +{ +} + +void HYDROGUI_LocalCSOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + HYDROGUI_LocalCSDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return; + + double aLX, aLY; + doc()->GetLocalCS( aLX, aLY ); + aPanel->SetLocalCS( aLX, aLY ); +} + +HYDROGUI_InputPanel* HYDROGUI_LocalCSOp::createInputPanel() const +{ + return new HYDROGUI_LocalCSDlg( module(), getName() ); +} + +bool HYDROGUI_LocalCSOp::processApply( int& theUpdateFlags, + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) +{ + HYDROGUI_LocalCSDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return false; + + double aLX = aPanel->GetLocalX(); + double aLY = aPanel->GetLocalY(); + doc()->SetLocalCS( aLX, aLY ); + + theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; + + return true; +} diff --git a/src/HYDROGUI/HYDROGUI_LocalCSOp.h b/src/HYDROGUI/HYDROGUI_LocalCSOp.h new file mode 100644 index 00000000..6ec1be1c --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LocalCSOp.h @@ -0,0 +1,45 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// 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 HYDROGUI_LocalCSOp_H +#define HYDROGUI_LocalCSOp_H + +#include "HYDROGUI_Operation.h" + +class HYDROGUI_LocalCSOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_LocalCSOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_LocalCSOp(); + +protected: + virtual void startOperation(); + + virtual HYDROGUI_InputPanel* createInputPanel() const; + + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); +}; + +#endif