diff --git a/doc/salome/examples/transformation_operations_ex07.py b/doc/salome/examples/transformation_operations_ex07.py index 0b324a101..f76bd9036 100644 --- a/doc/salome/examples/transformation_operations_ex07.py +++ b/doc/salome/examples/transformation_operations_ex07.py @@ -2,7 +2,6 @@ import salome salome.salome_init() -import GEOM from salome.geom import geomBuilder geompy = geomBuilder.New(salome.myStudy) @@ -25,24 +24,17 @@ projection = geompy.MakeProjection(curve, face_cyl) # add objects in the study geompy.addToStudy(cylinder, "cylinder") geompy.addToStudyInFather(cylinder, face_cyl, "face_cyl") -geompy.addToStudy(p1, "p1") -geompy.addToStudy(p2, "p2") -geompy.addToStudy(p3, "p3") -geompy.addToStudy(p4, "p4") -geompy.addToStudy(p5, "p5") geompy.addToStudy(curve, "curve") geompy.addToStudy(projection, "projection") -#projection of point on wire. +#projection of point on wire e1 = geompy.MakeLineTwoPnt(p1, p2) e2 = geompy.MakeLineTwoPnt(p2, p3) w1 = geompy.MakeWire([e1, e2], 1.e-7) v1 = geompy.MakeVertex(300, 40, 100) -prj = geompy.MakeProjectionOnWire(v1, w1) -geompy.addToStudy(e1, "e1") -geompy.addToStudy(e2, "e2") +prj = geompy.MakeProjection(v1, w1) geompy.addToStudy(w1, "w1") geompy.addToStudy(v1, "v1") -geompy.addToStudy(prj[1], "projOnWire") +geompy.addToStudy(prj, "projOnWire") diff --git a/doc/salome/gui/GEOM/images/projection_dlg.png b/doc/salome/gui/GEOM/images/projection_dlg.png index ac912b9a8..561ca30f3 100644 Binary files a/doc/salome/gui/GEOM/images/projection_dlg.png and b/doc/salome/gui/GEOM/images/projection_dlg.png differ diff --git a/doc/salome/gui/GEOM/images/projection_dlg1.png b/doc/salome/gui/GEOM/images/projection_dlg1.png new file mode 100644 index 000000000..342e7626f Binary files /dev/null and b/doc/salome/gui/GEOM/images/projection_dlg1.png differ diff --git a/doc/salome/gui/GEOM/images/projection_dlg2.png b/doc/salome/gui/GEOM/images/projection_dlg2.png new file mode 100644 index 000000000..1c0ab2780 Binary files /dev/null and b/doc/salome/gui/GEOM/images/projection_dlg2.png differ diff --git a/doc/salome/gui/GEOM/input/extension_operation.doc b/doc/salome/gui/GEOM/input/extension_operation.doc index 417577adb..605ff176f 100644 --- a/doc/salome/gui/GEOM/input/extension_operation.doc +++ b/doc/salome/gui/GEOM/input/extension_operation.doc @@ -27,7 +27,7 @@ parameter value, \em theMax the maximal parameter value. \note The input Edge parameters range is [0, 1]. If \b theMin parameter is negative, the input Edge is extended, otherwise it is shrinked by \b theMin parameter. If \b theMax is greater than 1, the Edge is - extended, otherwise it is shrinked by \btheMax parameter. + extended, otherwise it is shrinked by \b theMax parameter. Secondly it is possible to resize a \b Face. \n TUI Command: geompy.ExtendFace(theFace, theUMin, theUMax, diff --git a/doc/salome/gui/GEOM/input/projection_operation.doc b/doc/salome/gui/GEOM/input/projection_operation.doc index 6f7e8b4eb..b90373be8 100644 --- a/doc/salome/gui/GEOM/input/projection_operation.doc +++ b/doc/salome/gui/GEOM/input/projection_operation.doc @@ -1,23 +1,34 @@ /*! -\page projection_operation_page Projection on a Face +\page projection_operation_page Projection \n To produce a Projection in the Main Menu select Operations - > Transformation - > Projection -\n This operation makes normal projection of a Source vertex, edge - or wire on a given Target face. -\ref restore_presentation_parameters_page "Advanced options". +\n This operation makes normal projection of one shape to another. +\n There are 3 types of projection different by types of operands. + +Firstly, you can project Source vertex, edge or wire on a given Target face. \image html projection_dlg.png +Secondly, you can project Source vertex on a given Target wire. + +\image html projection_dlg1.png + +Thirdly, you can project Source vertex on a given Target edge. + +\image html projection_dlg2.png + +\ref restore_presentation_parameters_page "Advanced options". + \n Example: \image html projection_preview.png "The curve (in red) and its projection on the cylindric surface" \n TUI Command: geompy.MakeProjection(Source, Target), where \em Source is a shape which has to be projected, \em Target - is a face, on which the \em Source shape will be projected. The \em + is a shape, on which the \em Source shape will be projected. The \em Result will be a \em GEOM_Object. Our TUI Scripts provide you with useful examples of the use of diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 0b24f8c7d..83faa46bb 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -3860,8 +3860,8 @@ module GEOM GEOM_Object MakeCopy (in GEOM_Object theOriginal); /*! - * \brief Deprecated method. Use Export (from the - * corresponding plugin) instead; here is a name of format. + * \brief Deprecated method. Use Export\ (from the + * corresponding plugin) instead; here \ is a name of format. * * \brief Export the given shape into a file with given name. * \param theObject Shape to be stored in the file. @@ -3871,8 +3871,8 @@ module GEOM void Export (in GEOM_Object theObject, in string theFileName, in string theFormatName); /*! - * \brief Deprecated method. Use Import (from the - * corresponding plugin) instead; here is a name of format. + * \brief Deprecated method. Use Import\ (from the + * corresponding plugin) instead; here \ is a name of format. * * \brief Import a shape from the STL, BREP, IGES or STEP file * (depends on given format) with given name. diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index d841d3612..49a7e5362 100755 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -131,6 +131,8 @@ SET( _res_files normale.png offset.png projection.png + projection_on_edge.png + projection_on_wire.png origin_and_vectors.png partition.png partitionkeep.png diff --git a/resources/projection_on_edge.png b/resources/projection_on_edge.png new file mode 100644 index 000000000..b1f65ad5c Binary files /dev/null and b/resources/projection_on_edge.png differ diff --git a/resources/projection_on_wire.png b/resources/projection_on_wire.png new file mode 100644 index 000000000..a182d8f46 Binary files /dev/null and b/resources/projection_on_wire.png differ diff --git a/src/GEOM/GEOM_PythonDump.cxx b/src/GEOM/GEOM_PythonDump.cxx index 07aaa0e33..107203a40 100644 --- a/src/GEOM/GEOM_PythonDump.cxx +++ b/src/GEOM/GEOM_PythonDump.cxx @@ -44,11 +44,11 @@ namespace GEOM { if (--myCounter == 0) { TCollection_AsciiString aDescr; - if ( myAppend ) { + if ( myAppend ) aDescr = myFunction->GetDescription(); - if ( !aDescr.IsEmpty() ) aDescr += "\n\t"; - } std::string aString = myStream.str(); + if ( !aDescr.IsEmpty() && !aString.empty()) + aDescr += "\n\t"; aDescr += (char *)aString.c_str(); myFunction->SetDescription( aDescr ); } diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index 93c4c2da6..42ab59c1b 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -407,12 +407,12 @@ void GEOMBase_Helper::erasePreview( const bool update ) { SUIT_ViewManager* aViewManager = myViewWindow->getViewManager(); if ( aViewManager->getType() == OCCViewer_Viewer::Type() || - aViewManager->getType() == SVTK_Viewer::Type() ) + aViewManager->getType() == SVTK_Viewer::Type() ) { - SUIT_ViewModel* aViewModel = aViewManager->getViewModel(); - SALOME_View* aView = dynamic_cast(aViewModel); - if (aView) - aView->Erase( getDisplayer(), *anIter, true ); + SUIT_ViewModel* aViewModel = aViewManager->getViewModel(); + SALOME_View* aView = dynamic_cast(aViewModel); + if (aView) + aView->Erase( getDisplayer(), *anIter, true ); } } delete *anIter; @@ -843,21 +843,21 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction, b QString aName = getObjectName(obj); if (aName.isEmpty()) { aName = getNewObjectName(currObj); - if ( nbObjs > 1 ) { - if (aName.isEmpty()) - aName = getPrefix(obj); - if (nbObjs <= 30) { - // Try to find a unique name - aName = GEOMBase::GetDefaultName(aName, extractPrefix()); - } else { - // Don't check name uniqueness in case of numerous objects - aName = aName + "_" + QString::number(aNumber++); - } - } else { - // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName() - if ( aName.isEmpty() ) - aName = GEOMBase::GetDefaultName( getPrefix( obj ) ); - } + if ( nbObjs > 1 ) { + if (aName.isEmpty()) + aName = getPrefix(obj); + if (nbObjs <= 30) { + // Try to find a unique name + aName = GEOMBase::GetDefaultName(aName, extractPrefix()); + } else { + // Don't check name uniqueness in case of numerous objects + aName = aName + "_" + QString::number(aNumber++); + } + } else { + // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName() + if ( aName.isEmpty() ) + aName = GEOMBase::GetDefaultName( getPrefix( obj ) ); + } } anEntryList << addInStudy( obj, aName.toLatin1().constData() ); // updateView=false @@ -1137,10 +1137,10 @@ GEOM::GEOM_Object_ptr GEOMBase_Helper::findObjectInFather( GEOM::GEOM_Object_ptr if ( !CORBA::is_nil( cobject ) ) { GEOM::ListOfLong_var indices = cobject->GetSubShapeIndices(); int length = indices->length(); - // VSR 18/03/2014: we need only sub-shapes with single sub-shape index (to exclude groups, etc) - if ( length == 1 && indices[0] == theIndex ) { - object = cobject; - break; + // VSR 18/03/2014: we need only sub-shapes with single sub-shape index (to exclude groups, etc) + if ( length == 1 && indices[0] == theIndex ) { + object = cobject; + break; } } } diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index c8c70c163..14cf841bc 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -432,9 +432,17 @@ offset.png - ICON_DLG_PROJECTION + ICON_DLG_PROJECTION_ON_FACE projection.png + + ICON_DLG_PROJECTION_ON_WIRE + projection_on_wire.png + + + ICON_DLG_PROJECTION_ON_EDGE + projection_on_edge.png + ICON_DLG_EXTEND_EDGE edgeextension.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 27690e1f5..1630caf5a 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -1213,17 +1213,45 @@ Please, select face, shell or solid and try again Division pattern - GEOM_PROJECTION - Projection - - - GEOM_PROJECTION_TITLE + GEOM_PROJECTION_ON_FACE Projection on Face - GEOM_SOURCE_OBJECT + GEOM_PROJECTION_ON_WIRE + Projection on Wire + + + GEOM_PROJECTION_ON_EDGE + Projection on Edge + + + GEOM_PROJECTION_TITLE + Projection + + + GEOM_PROJ_ON_FACE_SOURCE Source vertex, edge or wire + + GEOM_PROJ_ON_FACE_TARGET + Target face + + + GEOM_PROJ_ON_WIRE_SOURCE + Source vertex + + + GEOM_PROJ_ON_WIRE_TARGET + Target wire + + + GEOM_PROJ_ON_EDGE_SOURCE + Source vertex + + + GEOM_PROJ_ON_EDGE_TARGET + Target edge + GEOM_SOLUTION Solution : @@ -1232,10 +1260,6 @@ Please, select face, shell or solid and try again GEOM_SOLUTION_I Solution %1 - - GEOM_TARGET_OBJECT - Target face - GEOM_WITH_CONTACT With contact diff --git a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx index 8e04e15ec..012d9982d 100644 --- a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx @@ -1155,8 +1155,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy * ProjectShapeCopy */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_ITransformOperations::ProjectShapeCopy - (Handle(GEOM_Object) theSource, Handle(GEOM_Object) theTarget) +Handle(GEOM_Object) +GEOMImpl_ITransformOperations::ProjectShapeCopy (Handle(GEOM_Object) theSource, + Handle(GEOM_Object) theTarget) { SetErrorCode(KO); @@ -1165,35 +1166,54 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ProjectShapeCopy Handle(GEOM_Function) aLastFunction = theSource->GetLastFunction(); if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be projected - //Add a new Projection object - Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION); + Handle(GEOM_Object) aCopy; - //Add a Projection function - Handle(GEOM_Function) aFunction = - aCopy->AddFunction(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_COPY); + TopoDS_Shape aTarget = theTarget->GetValue(); + if ( aTarget.IsNull() ) return NULL; + if ( aTarget.ShapeType() == TopAbs_EDGE || + aTarget.ShapeType() == TopAbs_WIRE ) + { + // a TPythonDump prevents dumping ProjectPointOnWire(), + // dump of MakeProjection() is done at the end of this function + GEOM::TPythonDump preventDump(aLastFunction, /*append=*/true); + Standard_Integer dummy; + ProjectPointOnWire( theSource, theTarget, aCopy, dummy ); + if ( aCopy.IsNull() || !IsDone() ) + return NULL; + } + else + { + //Add a new Projection object + aCopy = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION); - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) return NULL; + //Add a Projection function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_COPY); - GEOMImpl_IMirror aTI (aFunction); - aTI.SetPlane(theTarget->GetLastFunction()); - aTI.SetOriginal(aLastFunction); + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) return NULL; - //Compute the Projection - try { - OCC_CATCH_SIGNALS; - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("Projection driver failed"); + GEOMImpl_IMirror aTI (aFunction); + aTI.SetPlane(theTarget->GetLastFunction()); + aTI.SetOriginal(aLastFunction); + + //Compute the Projection + try { + OCC_CATCH_SIGNALS; + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Projection driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); return NULL; } } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } //Make a Python command + Handle(GEOM_Function) aFunction = aCopy->GetLastFunction(); GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeProjection(" << theSource << ", " << theTarget << ")"; diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index c3eead5dd..83c2e34b0 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -8785,9 +8785,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self._autoPublish(anObj, theName, "offset") return anObj - ## Create new object as projection of the given one on a 2D surface. + ## Create new object as projection of the given one on another. # @param theSource The source object for the projection. It can be a point, edge or wire. - # @param theTarget The target object. It can be planar or cylindrical face. + # Edge and wire are acceptable if @a theTarget is a face. + # @param theTarget The target object. It can be planar or cylindrical face, edge or wire. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. @@ -8798,11 +8799,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): @ManageTransactions("TrsfOp") def MakeProjection(self, theSource, theTarget, theName=None): """ - Create new object as projection of the given one on a 2D surface. + Create new object as projection of the given one on another. Parameters: theSource The source object for the projection. It can be a point, edge or wire. - theTarget The target object. It can be planar or cylindrical face. + Edge and wire are acceptable if theTarget is a face. + theTarget The target object. It can be planar or cylindrical face, edge or wire. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. diff --git a/src/TransformationGUI/TransformationGUI_ProjectionDlg.cxx b/src/TransformationGUI/TransformationGUI_ProjectionDlg.cxx index be7d741bf..73b2c528b 100644 --- a/src/TransformationGUI/TransformationGUI_ProjectionDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_ProjectionDlg.cxx @@ -38,6 +38,11 @@ #include +namespace +{ + enum EOperationType { PROJ_ON_FACE = 0, PROJ_ON_WIRE, PROJ_ON_EDGE }; +} + //================================================================================= // class : TransformationGUI_ProjectionDlg() // purpose : Constructs a TransformationGUI_ProjectionDlg which is a child of 'parent', with the @@ -49,23 +54,20 @@ TransformationGUI_ProjectionDlg::TransformationGUI_ProjectionDlg (GeometryGUI* t QWidget* parent, bool modal, Qt::WindowFlags fl) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl) { - QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PROJECTION"))); QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); + QPixmap image2 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PROJECTION_ON_FACE"))); + QPixmap image3 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PROJECTION_ON_WIRE"))); + QPixmap image4 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PROJECTION_ON_EDGE"))); setWindowTitle(tr("GEOM_PROJECTION_TITLE")); - mainFrame()->GroupConstructors->setTitle(tr("GEOM_PROJECTION")); - mainFrame()->RadioButton1->setIcon(image0); - mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); - mainFrame()->RadioButton2->close(); - mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); - mainFrame()->RadioButton3->close(); + mainFrame()->RadioButton1->setIcon(image2); + mainFrame()->RadioButton2->setIcon(image3); + mainFrame()->RadioButton3->setIcon(image4); myGroup = new DlgRef_2Sel (centralWidget()); myGroup->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - myGroup->TextLabel1->setText(tr("GEOM_SOURCE_OBJECT")); - myGroup->TextLabel2->setText(tr("GEOM_TARGET_OBJECT")); myGroup->PushButton1->setIcon(image1); myGroup->PushButton2->setIcon(image1); myGroup->LineEdit1->setReadOnly(true); @@ -108,6 +110,8 @@ void TransformationGUI_ProjectionDlg::Init() showOnlyPreviewControl(); // signals and slots connections + connect(this, SIGNAL( constructorsClicked( int )), + this, SLOT ( ConstructorsClicked( int ))); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); @@ -115,20 +119,17 @@ void TransformationGUI_ProjectionDlg::Init() connect(myGroup->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - initName(mainFrame()->GroupConstructors->title()); + initName( windowTitle() ); setTabOrder(mainFrame()->GroupConstructors, mainFrame()->GroupBoxName); setTabOrder(mainFrame()->GroupBoxName, mainFrame()->GroupMedium); setTabOrder(mainFrame()->GroupMedium, mainFrame()->GroupButtons); - mainFrame()->RadioButton1->setFocus(); + //mainFrame()->RadioButton1->setFocus(); + ConstructorsClicked( 0 ); - globalSelection(GEOM_ALLSHAPES); - - myGroup->PushButton1->click(); - SelectionIntoArgument(); resize(100,100); } @@ -153,8 +154,8 @@ bool TransformationGUI_ProjectionDlg::ClickOnApply() return false; initName(); - // activate selection and connect selection manager - myGroup->PushButton1->click(); + ConstructorsClicked( getConstructorId() ); + return true; } @@ -166,9 +167,25 @@ void TransformationGUI_ProjectionDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); - GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_SHAPE); + GEOM::GeomObjPtr aSelectedObject; + if ( myEditCurrentArgument == myGroup->LineEdit1 ) // what to project + switch( getConstructorId() ) { + case PROJ_ON_FACE: aSelectedObject = getSelected(TopAbs_SHAPE); break; + case PROJ_ON_WIRE: + case PROJ_ON_EDGE: aSelectedObject = getSelected(TopAbs_VERTEX); break; + default:; + } + else + switch( getConstructorId() ) { // where to project + case PROJ_ON_FACE: aSelectedObject = getSelected(TopAbs_FACE); break; + case PROJ_ON_WIRE: aSelectedObject = getSelected(TopAbs_WIRE); break; + case PROJ_ON_EDGE: aSelectedObject = getSelected(TopAbs_EDGE); break; + default:; + } + TopoDS_Shape aShape; - if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull()) { + if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull()) + { QString aName = GEOMBase::GetName(aSelectedObject.get()); myEditCurrentArgument->setText(aName); @@ -193,6 +210,7 @@ void TransformationGUI_ProjectionDlg::SelectionIntoArgument() if (myEditCurrentArgument == myGroup->LineEdit1) myObject1.nullify(); else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2.nullify(); } + processPreview(); } //================================================================================= @@ -203,25 +221,45 @@ void TransformationGUI_ProjectionDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if (send == myGroup->PushButton1) { + globalSelection(); // close local contexts, if any + + if (send == myGroup->PushButton1) // what to project + { myEditCurrentArgument = myGroup->LineEdit1; myGroup->PushButton2->setDown(false); myGroup->LineEdit2->setEnabled(false); - TColStd_MapOfInteger aMap; - aMap.Add( GEOM_POINT ); - aMap.Add( GEOM_EDGE ); - aMap.Add( GEOM_WIRE ); - globalSelection( aMap ); + switch ( getConstructorId() ) { + case PROJ_ON_FACE: { + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_POINT ); + aMap.Add( GEOM_EDGE ); + aMap.Add( GEOM_WIRE ); + globalSelection( aMap ); + break; + } + case PROJ_ON_WIRE: + case PROJ_ON_EDGE: { + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); + break; + } + default:; + } } - else if (send == myGroup->PushButton2) { + else if (send == myGroup->PushButton2) // where to project + { myEditCurrentArgument = myGroup->LineEdit2; myGroup->PushButton1->setDown(false); myGroup->LineEdit1->setEnabled(false); - globalSelection( GEOM_FACE ); + switch ( getConstructorId() ) { + case PROJ_ON_FACE: localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE); break; + case PROJ_ON_WIRE: localSelection(GEOM::GEOM_Object::_nil(), TopAbs_WIRE); break; + case PROJ_ON_EDGE: localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); break; + default:; + } } // enable line edit @@ -229,6 +267,8 @@ void TransformationGUI_ProjectionDlg::SetEditCurrentArgument() myEditCurrentArgument->setFocus(); // after setFocus(), because it will be setDown(false) when loses focus send->setDown(true); + + SelectionIntoArgument(); } //================================================================================= @@ -281,9 +321,51 @@ bool TransformationGUI_ProjectionDlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation()); - anObj = anOper->ProjectShapeCopy(myObject1.get(), myObject2.get()); + anObj = anOper->ProjectShapeCopy( myObject1.get(), myObject2.get() ); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); return true; } + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void TransformationGUI_ProjectionDlg::ConstructorsClicked( int constructorId ) +{ + myObject1.nullify(); + myObject2.nullify(); + myGroup->LineEdit1->setText( "" ); + myGroup->LineEdit2->setText( "" ); + + switch ( constructorId ) { + case PROJ_ON_FACE: + mainFrame()->GroupConstructors->setTitle(tr("GEOM_PROJECTION_ON_FACE")); + myGroup->TextLabel1->setText(tr("GEOM_PROJ_ON_FACE_SOURCE")); + myGroup->TextLabel2->setText(tr("GEOM_PROJ_ON_FACE_TARGET")); + break; + case PROJ_ON_EDGE: + mainFrame()->GroupConstructors->setTitle(tr("GEOM_PROJECTION_ON_EDGE")); + myGroup->TextLabel1->setText(tr("GEOM_PROJ_ON_EDGE_SOURCE")); + myGroup->TextLabel2->setText(tr("GEOM_PROJ_ON_EDGE_TARGET")); + break; + case PROJ_ON_WIRE: + mainFrame()->GroupConstructors->setTitle(tr("GEOM_PROJECTION_ON_WIRE")); + myGroup->TextLabel1->setText(tr("GEOM_PROJ_ON_WIRE_SOURCE")); + myGroup->TextLabel2->setText(tr("GEOM_PROJ_ON_WIRE_TARGET")); + break; + default:; + } + myGroup->PushButton1->click(); +} + +//================================================================================= +// function : addSubshapeToStudy +// purpose : virtual method to add new SubObjects if local selection +//================================================================================= +void TransformationGUI_ProjectionDlg::addSubshapesToStudy() +{ + GEOMBase::PublishSubObject( myObject1.get() ); + GEOMBase::PublishSubObject( myObject2.get() ); +} diff --git a/src/TransformationGUI/TransformationGUI_ProjectionDlg.h b/src/TransformationGUI/TransformationGUI_ProjectionDlg.h index b20e110c8..3b09bba84 100644 --- a/src/TransformationGUI/TransformationGUI_ProjectionDlg.h +++ b/src/TransformationGUI/TransformationGUI_ProjectionDlg.h @@ -49,6 +49,7 @@ protected: virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual bool isValid (QString&); virtual bool execute (ObjectList&); + virtual void addSubshapesToStudy(); private: void Init(); @@ -66,6 +67,7 @@ private slots: void SetEditCurrentArgument(); void SelectionIntoArgument(); void ActivateThisDialog(); + void ConstructorsClicked( int constructorId ); }; #endif // TRANSFORMATIONGUI_PROJECTIONDLG_H