From: skv Date: Fri, 28 Nov 2014 10:10:45 +0000 (+0300) Subject: Make GUI X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0f99c6b595f1887c4afeb8faba1217993858a313;p=modules%2Fgeom.git Make GUI --- diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 49a7e5362..acd492f16 100755 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -183,6 +183,7 @@ SET( _res_files torus.png torusdxyz.png toruspointvector.png + transfer_data.png translationDxyz.png translationPoints.png translationVector.png diff --git a/resources/transfer_data.png b/resources/transfer_data.png new file mode 100644 index 000000000..05ac19352 Binary files /dev/null and b/resources/transfer_data.png differ diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 14cf841bc..d039aea74 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -1347,6 +1347,10 @@ ICO_GET_SHARED_SHAPES shared_shapes.png + + ICO_TRANSFER_DATA + transfer_data.png + ICON_DLG_POINT_FACE pointonface.png @@ -1359,6 +1363,10 @@ ICON_DLG_SHARED_SHAPES shared_shapes.png + + ICON_DLG_TRANSFER_DATA + transfer_data.png + ICON_DLG_SCALE_ALONG_AXES scale_along_axes.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 1630caf5a..7b2e3b8f9 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -5040,6 +5040,18 @@ Please, select face, shell or solid and try again STB_GET_SHARED_SHAPES Get shared shapes + + TOP_TRANSFER_DATA + Transfer Data + + + MEN_TRANSFER_DATA + Transfer Data + + + STB_TRANSFER_DATA + Transfer Data + TOP_EXTENSION Extend Edge or Face @@ -7148,4 +7160,43 @@ Do you want to create new material? SurfaceFromFace + + OperationGUI_TransferDataDlg + + GEOM_TRANSFER_DATA_TITLE + Transfer Data + + + GEOM_TRANSFER_DATA + Transfer Data + + + GEOM_TRANSFER_DATA_FROM + Source Shape + + + GEOM_TRANSFER_DATA_TO + Destination Shape + + + GEOM_TRANSFER_DATA_METHOD + Type of Detection Operation + + + GEOM_TD_METHOD_GETINPLACE + Get In Place + + + GEOM_TD_METHOD_GETINPLACE_OLD + Get In Place (old) + + + GEOM_TD_METHOD_GETINPLACE_HISTORY + Get In Place By History + + + GEOM_TRANSFER_DATA_INFO + Transfer Data: Information + + diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index be77999a9..a8e6f6bca 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -602,6 +602,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT + case GEOMOp::OpTransferData: // MENU OPERATION - TRANSFER DATA libName = "OperationGUI"; break; case GEOMOp::OpSewing: // MENU REPAIR - SEWING @@ -971,6 +972,7 @@ void GeometryGUI::initialize( CAM_Application* app ) //createGeomAction( GEOMOp::OpClipping, "CLIPPING" ); createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" ); createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" ); + createGeomAction( GEOMOp::OpTransferData, "TRANSFER_DATA" ); createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" ); createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" ); createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" ); @@ -1214,6 +1216,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( GEOMOp::OpArchimede, operId, -1 ); createMenu( GEOMOp::OpShapesOnShape, operId, -1 ); createMenu( GEOMOp::OpSharedShapes, operId, -1 ); + createMenu( GEOMOp::OpTransferData, operId, -1 ); createMenu( separator(), operId, -1 ); @@ -1379,6 +1382,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpArchimede, operTbId ); createTool( GEOMOp::OpShapesOnShape, operTbId ); createTool( GEOMOp::OpSharedShapes, operTbId ); + createTool( GEOMOp::OpTransferData, operTbId ); int featTbId = createTool( tr( "TOOL_FEATURES" ), QString( "GEOMModification" ) ); createTool( GEOMOp::OpFillet1d, featTbId ); diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index 9a1e4fd40..7243340f4 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -157,6 +157,7 @@ namespace GEOMOp { OpSharedShapes = 3708, // MENU OPERATION - GET SHARED SHAPES OpExtrudedBoss = 3709, // MENU OPERATION - ETRUDED BOSS OpExtrudedCut = 3710, // MENU OPERATION - ETRUDED CUT + OpTransferData = 3711, // MENU OPERATION - TRANSFER DATA // RepairGUI -------------------//-------------------------------- OpSewing = 4000, // MENU REPAIR - SEWING OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES diff --git a/src/OperationGUI/CMakeLists.txt b/src/OperationGUI/CMakeLists.txt index 0f8ae114e..b4c76b04f 100755 --- a/src/OperationGUI/CMakeLists.txt +++ b/src/OperationGUI/CMakeLists.txt @@ -76,6 +76,7 @@ SET(OperationGUI_HEADERS OperationGUI_GetSharedShapesDlg.h OperationGUI_ExtrudedFeatureDlg.h OperationGUI_ClippingDlg.h + OperationGUI_TransferDataDlg.h ) # header files / to be processed by moc @@ -89,6 +90,7 @@ SET(_moc_HEADERS OperationGUI_GetSharedShapesDlg.h OperationGUI_ExtrudedFeatureDlg.h OperationGUI_ClippingDlg.h + OperationGUI_TransferDataDlg.h ) # header files / uic wrappings @@ -110,6 +112,7 @@ SET(OperationGUI_SOURCES OperationGUI_ChamferDlg.cxx OperationGUI_ExtrudedFeatureDlg.cxx OperationGUI_ClippingDlg.cxx + OperationGUI_TransferDataDlg.cxx ${_moc_SOURCES} ${_uic_files} ) diff --git a/src/OperationGUI/OperationGUI.cxx b/src/OperationGUI/OperationGUI.cxx index a705e0ae2..e72c96d4e 100644 --- a/src/OperationGUI/OperationGUI.cxx +++ b/src/OperationGUI/OperationGUI.cxx @@ -39,6 +39,7 @@ #include "OperationGUI_GetShapesOnShapeDlg.h" #include "OperationGUI_GetSharedShapesDlg.h" #include "OperationGUI_ExtrudedFeatureDlg.h" // Methods EXTRUDED BOSS / CUT +#include "OperationGUI_TransferDataDlg.h" //======================================================================= // function : OperationGUI() @@ -81,6 +82,7 @@ bool OperationGUI::OnGUIEvent (int theCommandID, SUIT_Desktop* parent) case GEOMOp::OpExtrudedCut: (new OperationGUI_ExtrudedFeatureDlg (CUT, getGeometryGUI(), parent))->show(); break; case GEOMOp::OpFillet1d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, true))->show(); break; case GEOMOp::OpFillet2d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, false))->show(); break; + case GEOMOp::OpTransferData: (new OperationGUI_TransferDataDlg (getGeometryGUI(), parent))->show(); break; default: app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); } diff --git a/src/OperationGUI/OperationGUI_TransferDataDlg.cxx b/src/OperationGUI/OperationGUI_TransferDataDlg.cxx new file mode 100644 index 000000000..53d63d118 --- /dev/null +++ b/src/OperationGUI/OperationGUI_TransferDataDlg.cxx @@ -0,0 +1,329 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 "OperationGUI_TransferDataDlg.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +//============================================================================== +// class : OperationGUI_TransferDataDlg() +// purpose : Constructs a OperationGUI_TransferDataDlg which is a child of +// 'parent'. +//================================================================================= +OperationGUI_TransferDataDlg::OperationGUI_TransferDataDlg (GeometryGUI* theGeometryGUI, + QWidget* parent) + : GEOMBase_Skeleton(theGeometryGUI, parent, false), + myGroup(NULL) +{ + SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); + QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TRANSFER_DATA"))); + QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setWindowTitle(tr("GEOM_TRANSFER_DATA_TITLE")); + + /***************************************************************/ + mainFrame()->GroupConstructors->setTitle(tr("GEOM_TRANSFER_DATA")); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton3->close(); + + mainFrame()->GroupBoxName->hide(); + + myGroup = new DlgRef_2Sel1List(centralWidget()); + myGroup->GroupBox1->setTitle(tr("GEOM_PARAMETERS")); + myGroup->TextLabel1->setText(tr("GEOM_TRANSFER_DATA_FROM")); + myGroup->TextLabel2->setText(tr("GEOM_TRANSFER_DATA_TO")); + myGroup->TextLabel3->setText(tr("GEOM_TRANSFER_DATA_METHOD")); + myGroup->PushButton1->setIcon(image1); + myGroup->PushButton2->setIcon(image1); + myGroup->LineEdit1->setReadOnly(true); + myGroup->LineEdit2->setReadOnly(true); + + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); layout->setSpacing(6); + layout->addWidget(myGroup); + /***************************************************************/ + + setHelpFileName("transferdata_page.html"); + + Init(); +} + +//================================================================================= +// function : ~OperationGUI_TransferDataDlg +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +OperationGUI_TransferDataDlg::~OperationGUI_TransferDataDlg() +{ +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void OperationGUI_TransferDataDlg::Init() +{ + // type for detection + myGroup->ComboBox1->addItem(tr("GEOM_TD_METHOD_GETINPLACE")); + myGroup->ComboBox1->addItem(tr("GEOM_TD_METHOD_GETINPLACE_OLD")); + myGroup->ComboBox1->addItem(tr("GEOM_TD_METHOD_GETINPLACE_HISTORY")); + + myGroup->LineEdit1->clear(); + myGroup->LineEdit2->clear(); + myObject1.nullify(); + myObject2.nullify(); + + // signals and slots connections + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(myGroup->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(myGroup->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(myGroup->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(myGroup->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(myGroup->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged())); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + myGroup->TextLabel3->show(); + myGroup->ComboBox1->show(); + myGroup->ComboBox1->setCurrentIndex(0); + + globalSelection(GEOM_ALLSHAPES); + + myGroup->PushButton1->click(); + SelectionIntoArgument(); + resize(100,100); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void OperationGUI_TransferDataDlg::ClickOnOk() +{ + setIsApplyAndClose( true ); + if (ClickOnApply()) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool OperationGUI_TransferDataDlg::ClickOnApply() +{ + if (!onAccept()) + return false; + // activate first line edit + myGroup->PushButton1->click(); + return true; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection is changed or on dialog initialization or activation +//================================================================================= +void OperationGUI_TransferDataDlg::SelectionIntoArgument() +{ + GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_SHAPE); + + if (aSelectedObject) { + myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject.get())); + + if (myEditCurrentArgument == myGroup->LineEdit1) { + myObject1 = aSelectedObject; + + if (!myObject2) { + myGroup->PushButton2->click(); + } + } else if (myEditCurrentArgument == myGroup->LineEdit2) { + myObject2 = aSelectedObject; + + if (!myObject1) { + myGroup->PushButton1->click(); + } + } + } else { + myEditCurrentArgument->setText(""); + + if (myEditCurrentArgument == myGroup->LineEdit1) { + myObject1.nullify(); + } else if (myEditCurrentArgument == myGroup->LineEdit2) { + myObject2.nullify(); + } + } +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void OperationGUI_TransferDataDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if (send == myGroup->PushButton1) { + myEditCurrentArgument = myGroup->LineEdit1; + + myGroup->PushButton2->setDown(false); + myGroup->LineEdit2->setEnabled(false); + } + else if (send == myGroup->PushButton2) { + myEditCurrentArgument = myGroup->LineEdit2; + + myGroup->PushButton1->setDown(false); + myGroup->LineEdit1->setEnabled(false); + } + + // enable line edit + myEditCurrentArgument->setEnabled(true); + myEditCurrentArgument->setFocus(); + // after setFocus(), because it will be setDown(false) when loses focus + send->setDown(true); +} + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void OperationGUI_TransferDataDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if (send == myGroup->LineEdit1 || send == myGroup->LineEdit2) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void OperationGUI_TransferDataDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + globalSelection(GEOM_ALLSHAPES); + connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), + this, SLOT( SelectionIntoArgument() ) ); +} + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void OperationGUI_TransferDataDlg::enterEvent (QEvent*) +{ + if (!mainFrame()->GroupConstructors->isEnabled()) + ActivateThisDialog(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr OperationGUI_TransferDataDlg::createOperation() +{ + return getGeomEngine()->GetIInsertOperations(getStudyId()); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool OperationGUI_TransferDataDlg::isValid(QString&) +{ + return myObject1 && myObject2; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool OperationGUI_TransferDataDlg::execute (ObjectList& objects) +{ + const int aLimit = myGroup->ComboBox1->currentIndex(); + GEOM::find_shape_method aMethod; + + switch (aLimit) + { + case 0: + aMethod = GEOM::FSM_GetInPlace; + break; + case 1: + aMethod = GEOM::FSM_GetInPlace_Old; + break; + case 2: + default: + aMethod = GEOM::FSM_GetInPlaceByHistory; + break; + } + + GEOM::GEOM_IInsertOperations_var anOper = + GEOM::GEOM_IInsertOperations::_narrow(getOperation()); + GEOM::GEOM_IInsertOperations::ListOfTransferDatum_var aResult; + + bool isOK = anOper->TransferData + (myObject1.get(), myObject2.get(), aMethod, aResult); + + if (isOK) { + // Construct info message. + QString aMsg; + int aNbTypes = aResult->length(); + + if (aNbTypes == 0) { + aMsg = tr("GEOM_TRANSFER_DATA_NOT_COPIED"); + } else { + aMsg = tr("GEOM_TRANSFER_DATA_COPIED\n"); + + int i; + + for (i = 0; i < aNbTypes; i++ ) { + if (i > 0) { + aMsg += "\n"; + } + + aMsg += tr(aResult[i].myName). + arg(aResult[i].myNumber).arg(aResult[i].myMaxNumber); + } + } + + // Show info message. + SUIT_MessageBox::information + (SUIT_Session::session()->activeApplication()->desktop(), + tr("GEOM_TRANSFER_DATA_INFO"), aMsg, tr("BUT_OK")); + } + + return isOK; +} diff --git a/src/OperationGUI/OperationGUI_TransferDataDlg.h b/src/OperationGUI/OperationGUI_TransferDataDlg.h new file mode 100644 index 000000000..a4b6ef947 --- /dev/null +++ b/src/OperationGUI/OperationGUI_TransferDataDlg.h @@ -0,0 +1,68 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 OPERATIONGUI_TRANSFERDATADLG_H +#define OPERATIONGUI_TRANSFERDATADLG_H + + +#include + +class DlgRef_2Sel1List; + +//================================================================================= +// class : OperationGUI_TransferDataDlg +// purpose : +//================================================================================= +class OperationGUI_TransferDataDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + OperationGUI_TransferDataDlg + ( GeometryGUI* theGeometryGUI, QWidget* parent = 0 ); + ~OperationGUI_TransferDataDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& ); + +private: + void Init(); + void enterEvent( QEvent* ); + +private: + GEOM::GeomObjPtr myObject1; + GEOM::GeomObjPtr myObject2; + int myShapeType; + + DlgRef_2Sel1List* myGroup; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void LineEditReturnPressed(); + void ActivateThisDialog(); +}; + +#endif // OPERATIONGUI_GETSHAPESONSHAPEDLG_H