#include <TColStd_MapOfInteger.hxx>
+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
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);
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()));
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);
}
return false;
initName();
- // activate selection and connect selection manager
- myGroup->PushButton1->click();
+ ConstructorsClicked( getConstructorId() );
+
return true;
}
{
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);
if (myEditCurrentArgument == myGroup->LineEdit1) myObject1.nullify();
else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2.nullify();
}
+ processPreview();
}
//=================================================================================
{
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
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
+
+ SelectionIntoArgument();
}
//=================================================================================
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() );
+}