Eliminate useless GetSubShape() lines in the python dump

This commit is contained in:
vsr 2011-01-10 10:50:44 +00:00
parent 68aba60ffd
commit 0514da352f
65 changed files with 2223 additions and 3330 deletions

View File

@ -159,7 +159,9 @@ void BasicGUI_ArcDlg::Init()
/* init variables */ /* init variables */
myEditCurrentArgument = Group3Pnts->LineEdit1; myEditCurrentArgument = Group3Pnts->LineEdit1;
myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); myPoint1.nullify();
myPoint2.nullify();
myPoint3.nullify();
Group3Pnts2->CheckButton1->setChecked( false ); Group3Pnts2->CheckButton1->setChecked( false );
Group3Pnts->PushButton1->setDown(true); Group3Pnts->PushButton1->setDown(true);
@ -176,28 +178,16 @@ void BasicGUI_ArcDlg::Init()
connect( Group3Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group3Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group3Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3Pnts->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3Pnts->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3Pnts2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group3Pnts2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group3Pnts2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts2->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group3Pnts2->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3Pnts2->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3Pnts2->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3Pnts2->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( ReverseSense() ) ); connect( Group3Pnts2->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( ReverseSense() ) );
connect( Group3Pnts3->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group3Pnts3->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts3->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group3Pnts3->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts3->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group3Pnts3->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts3->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3Pnts3->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3Pnts3->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) ); this, SLOT( SelectionIntoArgument() ) );
@ -249,116 +239,80 @@ void BasicGUI_ArcDlg::SelectionIntoArgument()
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1) {
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1.nullify();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2.nullify();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3.nullify();
return;
break; break;
case 1: case 1:
if ( myEditCurrentArgument == Group3Pnts2->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); if ( myEditCurrentArgument == Group3Pnts2->LineEdit1 ) myPoint1.nullify();
else if ( myEditCurrentArgument == Group3Pnts2->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts2->LineEdit2 ) myPoint2.nullify();
else if ( myEditCurrentArgument == Group3Pnts2->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts2->LineEdit3 ) myPoint3.nullify();
return;
break; break;
case 2: case 2:
if ( myEditCurrentArgument == Group3Pnts3->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); if ( myEditCurrentArgument == Group3Pnts3->LineEdit1 ) myPoint1.nullify();
else if ( myEditCurrentArgument == Group3Pnts3->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts3->LineEdit2 ) myPoint2.nullify();
else if ( myEditCurrentArgument == Group3Pnts3->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts3->LineEdit3 ) myPoint3.nullify();
return; break;
default:
break; break;
} }
return;
} }
// nbSel == 1
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( !CORBA::is_nil( aSelectedObject ) ) {
QString aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX );
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
{ QString aName = GEOMBase::GetName( aSelectedObject.get() );
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) // Local Selection
{
int anIndex = aMap(1);
aName += QString(":vertex_%1").arg(anIndex);
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if ( aFindedObject->_is_nil() ) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
}
else
aSelectedObject = aFindedObject; // get Object from study
}
else // Global Selection
{
if (aShape.ShapeType() != TopAbs_VERTEX) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
if (!aSelectedObject->_is_nil()) { // clear selection if something selected
globalSelection();
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
}
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0: case 0:
if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) { if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) if ( myPoint1 && !myPoint2 )
Group3Pnts->PushButton2->click(); Group3Pnts->PushButton2->click();
} }
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) { else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
if ( !myPoint2->_is_nil() && myPoint3->_is_nil() ) if ( myPoint2 && !myPoint3 )
Group3Pnts->PushButton3->click(); Group3Pnts->PushButton3->click();
} }
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) { else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
myPoint3 = aSelectedObject; myPoint3 = aSelectedObject;
if ( !myPoint3->_is_nil() && myPoint1->_is_nil() ) if ( myPoint3 && !myPoint1 )
Group3Pnts->PushButton1->click(); Group3Pnts->PushButton1->click();
} }
break; break;
case 1: case 1:
if ( myEditCurrentArgument == Group3Pnts2->LineEdit1 ) { if ( myEditCurrentArgument == Group3Pnts2->LineEdit1 ) {
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) if ( myPoint1 && !myPoint2 )
Group3Pnts2->PushButton2->click(); Group3Pnts2->PushButton2->click();
} }
else if ( myEditCurrentArgument == Group3Pnts2->LineEdit2 ) { else if ( myEditCurrentArgument == Group3Pnts2->LineEdit2 ) {
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
if ( !myPoint2->_is_nil() && myPoint3->_is_nil() ) if ( myPoint2 && !myPoint3 )
Group3Pnts2->PushButton3->click(); Group3Pnts2->PushButton3->click();
} }
else if ( myEditCurrentArgument == Group3Pnts2->LineEdit3 ) { else if ( myEditCurrentArgument == Group3Pnts2->LineEdit3 ) {
myPoint3 = aSelectedObject; myPoint3 = aSelectedObject;
if ( !myPoint3->_is_nil() && myPoint1->_is_nil() ) if ( myPoint3 && !myPoint1 )
Group3Pnts2->PushButton1->click(); Group3Pnts2->PushButton1->click();
} }
break; break;
case 2: case 2:
if ( myEditCurrentArgument == Group3Pnts3->LineEdit1 ) { if ( myEditCurrentArgument == Group3Pnts3->LineEdit1 ) {
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) if ( myPoint1 && !myPoint2 )
Group3Pnts3->PushButton2->click(); Group3Pnts3->PushButton2->click();
} }
else if ( myEditCurrentArgument == Group3Pnts3->LineEdit2 ) { else if ( myEditCurrentArgument == Group3Pnts3->LineEdit2 ) {
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
if ( !myPoint2->_is_nil() && myPoint3->_is_nil() ) if ( myPoint2 && !myPoint3 )
Group3Pnts3->PushButton3->click(); Group3Pnts3->PushButton3->click();
} }
else if ( myEditCurrentArgument == Group3Pnts3->LineEdit3 ) { else if ( myEditCurrentArgument == Group3Pnts3->LineEdit3 ) {
myPoint3 = aSelectedObject; myPoint3 = aSelectedObject;
if ( !myPoint3->_is_nil() && myPoint1->_is_nil() ) if ( myPoint3 && !myPoint1 )
Group3Pnts3->PushButton1->click(); Group3Pnts3->PushButton1->click();
} }
break; break;
@ -466,22 +420,6 @@ void BasicGUI_ArcDlg::SetEditCurrentArgument()
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void BasicGUI_ArcDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == Group3Pnts->LineEdit1 || send == Group3Pnts->LineEdit2 || send == Group3Pnts->LineEdit3 ||
send == Group3Pnts2->LineEdit1 || send == Group3Pnts2->LineEdit2 || send == Group3Pnts2->LineEdit3 ||
send == Group3Pnts3->LineEdit1 || send == Group3Pnts3->LineEdit2 || send == Group3Pnts3->LineEdit3 ) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -517,49 +455,15 @@ GEOM::GEOM_IOperations_ptr BasicGUI_ArcDlg::createOperation()
return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() ); return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() );
} }
//=================================================================================
// function : isEqual
// purpose : it may also be needed to check for min distance between gp_Pnt-s...
//=================================================================================
static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
{
return thePnt1->_is_equivalent( thePnt2 );
}
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool BasicGUI_ArcDlg::isValid( QString& msg ) bool BasicGUI_ArcDlg::isValid( QString& msg )
{ {
switch (getConstructorId()) { bool ok = myPoint1 && myPoint2 && myPoint3 &&
case 0: myPoint1 != myPoint2 && myPoint1 != myPoint3 && myPoint2 != myPoint3;
{ return ok;
if (Group3Pnts->LineEdit1->text().trimmed().isEmpty() ||
Group3Pnts->LineEdit2->text().trimmed().isEmpty() ||
Group3Pnts->LineEdit3->text().trimmed().isEmpty())
return false;
break;
}
case 1:
{
if (Group3Pnts2->LineEdit1->text().trimmed().isEmpty() ||
Group3Pnts2->LineEdit2->text().trimmed().isEmpty() ||
Group3Pnts2->LineEdit3->text().trimmed().isEmpty())
return false;
break;
}
case 2:
{
if (Group3Pnts3->LineEdit1->text().trimmed().isEmpty() ||
Group3Pnts3->LineEdit2->text().trimmed().isEmpty() ||
Group3Pnts3->LineEdit3->text().trimmed().isEmpty())
return false;
break;
}
}
return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() &&
!isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 );
} }
//================================================================================= //=================================================================================
@ -576,8 +480,8 @@ bool BasicGUI_ArcDlg::execute( ObjectList& objects )
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0: case 0:
{ {
if ( !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) ) { if ( myPoint1 && myPoint2 && myPoint3 ) {
anObj = anOper->MakeArc( myPoint1, myPoint2, myPoint3 ); anObj = anOper->MakeArc( myPoint1.get(), myPoint2.get(), myPoint3.get() );
res = true; res = true;
} }
break; break;
@ -585,16 +489,16 @@ bool BasicGUI_ArcDlg::execute( ObjectList& objects )
case 1: case 1:
{ {
bool Sense = Group3Pnts2->CheckButton1->isChecked(); bool Sense = Group3Pnts2->CheckButton1->isChecked();
if ( !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) ) { if ( myPoint1 && myPoint2 && myPoint3 ) {
anObj = anOper->MakeArcCenter( myPoint1, myPoint2, myPoint3, Sense ); anObj = anOper->MakeArcCenter( myPoint1.get(), myPoint2.get(), myPoint3.get(), Sense );
res = true; res = true;
} }
break; break;
} }
case 2: case 2:
{ {
if ( !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) ) { if ( myPoint1 && myPoint2 && myPoint3 ) {
anObj = anOper->MakeArcOfEllipse( myPoint1, myPoint2, myPoint3 ); anObj = anOper->MakeArcOfEllipse( myPoint1.get(), myPoint2.get(), myPoint3.get() );
res = true; res = true;
} }
break; break;
@ -614,12 +518,13 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId )
{ {
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
myPoint1.nullify();
myPoint2.nullify();
myPoint3.nullify();
switch ( constructorId ) { switch ( constructorId ) {
case 0: case 0:
{ {
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes
Group3Pnts->show(); Group3Pnts->show();
Group3Pnts2->hide(); Group3Pnts2->hide();
Group3Pnts3->hide(); Group3Pnts3->hide();
@ -632,16 +537,12 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId )
Group3Pnts->LineEdit1->setEnabled(true); Group3Pnts->LineEdit1->setEnabled(true);
Group3Pnts->LineEdit2->setEnabled(false); Group3Pnts->LineEdit2->setEnabled(false);
Group3Pnts->LineEdit3->setEnabled(false); Group3Pnts->LineEdit3->setEnabled(false);
myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
myEditCurrentArgument = Group3Pnts->LineEdit1; myEditCurrentArgument = Group3Pnts->LineEdit1;
break; break;
} }
case 1: case 1:
{ {
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes
Group3Pnts->hide(); Group3Pnts->hide();
Group3Pnts2->show(); Group3Pnts2->show();
Group3Pnts3->hide(); Group3Pnts3->hide();
@ -654,16 +555,12 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId )
Group3Pnts2->LineEdit1->setEnabled(true); Group3Pnts2->LineEdit1->setEnabled(true);
Group3Pnts2->LineEdit2->setEnabled(false); Group3Pnts2->LineEdit2->setEnabled(false);
Group3Pnts2->LineEdit3->setEnabled(false); Group3Pnts2->LineEdit3->setEnabled(false);
myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
myEditCurrentArgument = Group3Pnts2->LineEdit1; myEditCurrentArgument = Group3Pnts2->LineEdit1;
break; break;
} }
case 2: case 2:
{ {
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes
Group3Pnts->hide(); Group3Pnts->hide();
Group3Pnts2->hide(); Group3Pnts2->hide();
Group3Pnts3->show(); Group3Pnts3->show();
@ -676,13 +573,15 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId )
Group3Pnts3->LineEdit1->setEnabled(true); Group3Pnts3->LineEdit1->setEnabled(true);
Group3Pnts3->LineEdit2->setEnabled(false); Group3Pnts3->LineEdit2->setEnabled(false);
Group3Pnts3->LineEdit3->setEnabled(false); Group3Pnts3->LineEdit3->setEnabled(false);
myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
myEditCurrentArgument = Group3Pnts3->LineEdit1; myEditCurrentArgument = Group3Pnts3->LineEdit1;
break; break;
} }
} }
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes
qApp->processEvents(); qApp->processEvents();
updateGeometry(); updateGeometry();
resize( minimumSizeHint() ); resize( minimumSizeHint() );
@ -691,7 +590,6 @@ void BasicGUI_ArcDlg::ConstructorsClicked( int constructorId )
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) ); this, SLOT( SelectionIntoArgument() ) );
if ( CORBA::is_nil( myPoint1 ) )
SelectionIntoArgument(); SelectionIntoArgument();
displayPreview(); displayPreview();
@ -712,24 +610,15 @@ void BasicGUI_ArcDlg::ReverseSense()
//================================================================================= //=================================================================================
void BasicGUI_ArcDlg::addSubshapesToStudy() void BasicGUI_ArcDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0: case 0:
objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
break;
case 1: case 1:
objMap[Group3Pnts2->LineEdit1->text()] = myPoint1;
objMap[Group3Pnts2->LineEdit2->text()] = myPoint2;
objMap[Group3Pnts2->LineEdit3->text()] = myPoint3;
break;
case 2: case 2:
objMap[Group3Pnts3->LineEdit1->text()] = myPoint1; GEOMBase::PublishSubObject( myPoint1.get() );
objMap[Group3Pnts3->LineEdit2->text()] = myPoint2; GEOMBase::PublishSubObject( myPoint2.get() );
objMap[Group3Pnts3->LineEdit3->text()] = myPoint3; GEOMBase::PublishSubObject( myPoint3.get() );
break;
default:
break; break;
} }
addSubshapesToFather( objMap );
} }

View File

@ -27,7 +27,8 @@
#ifndef BASICGUI_ARCDLG_H #ifndef BASICGUI_ARCDLG_H
#define BASICGUI_ARCDLG_H #define BASICGUI_ARCDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_3Sel; class DlgRef_3Sel;
class DlgRef_3Sel1Check; class DlgRef_3Sel1Check;
@ -56,7 +57,7 @@ private:
void enterEvent( QEvent* ); void enterEvent( QEvent* );
private: private:
GEOM::GEOM_Object_var myPoint1, myPoint2, myPoint3; GEOM::GeomObjPtr myPoint1, myPoint2, myPoint3;
DlgRef_3Sel* Group3Pnts; DlgRef_3Sel* Group3Pnts;
DlgRef_3Sel1Check* Group3Pnts2; DlgRef_3Sel1Check* Group3Pnts2;
@ -68,7 +69,6 @@ private slots:
void ActivateThisDialog(); void ActivateThisDialog();
void ConstructorsClicked( int ); void ConstructorsClicked( int );
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ReverseSense(); void ReverseSense();

View File

@ -150,9 +150,14 @@ void BasicGUI_CircleDlg::Init()
/* init variables */ /* init variables */
myEditCurrentArgument = GroupPntVecR->LineEdit1; myEditCurrentArgument = GroupPntVecR->LineEdit1;
myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); myPoint.nullify();
myDir.nullify();
// myGeomGUI->SetState( 0 ); myPoint1.nullify();
myPoint2.nullify();
myPoint3.nullify();
myPoint4.nullify();
myPoint5.nullify();
myPoint6.nullify();
/* Get setting of step value from file configuration */ /* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
@ -181,9 +186,6 @@ void BasicGUI_CircleDlg::Init()
connect( GroupCenter2Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupCenter2Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupCenter2Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupCenter2Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPntVecR->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPntVecR->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPntVecR->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT(ValueChangedInSpinBox() ) ); connect( GroupPntVecR->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT(ValueChangedInSpinBox() ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
@ -212,7 +214,14 @@ void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId )
{ {
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0); disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); myPoint.nullify();
myDir.nullify();
myPoint1.nullify();
myPoint2.nullify();
myPoint3.nullify();
myPoint4.nullify();
myPoint5.nullify();
myPoint6.nullify();
switch ( constructorId ) { switch ( constructorId ) {
case 0: case 0:
@ -320,104 +329,64 @@ void BasicGUI_CircleDlg::SelectionIntoArgument()
aSelMgr->selectedObjects( aList ); aSelMgr->selectedObjects( aList );
if ( aList.Extent() != 1 ) { if ( aList.Extent() != 1 ) {
if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil(); if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint.nullify();
else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir.nullify();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1.nullify();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2.nullify();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3.nullify();
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) myPoint4 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) myPoint4.nullify();
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) myPoint5 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) myPoint5.nullify();
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) myPoint6 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) myPoint6.nullify();
return; return;
} }
// nbSel == 1 TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) ?
Handle(SALOME_InteractiveObject) anIO = aList.First(); TopAbs_EDGE : TopAbs_VERTEX;
GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO );
if ( !CORBA::is_nil( aSelectedObject ) ) {
QString aName = GEOMBase::GetName( aSelectedObject );
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 )
aNeedType = TopAbs_EDGE;
// If selected Vertex or Edge on the some Shape Get selection Subshape
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
TColStd_IndexedMapOfInteger aMap; QString aName = GEOMBase::GetName( aSelectedObject.get() );
aSelMgr->GetIndexes(anIO, aMap);
if ( aMap.Extent() == 1 ) { // Local Selection
int anIndex = aMap(1);
if ( aNeedType == TopAbs_EDGE )
aName += QString( ":edge_%1" ).arg( anIndex );
else
aName += QString( ":vertex_%1" ).arg( anIndex );
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
if ( aFindedObject->_is_nil() ) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else { // Global Selection
if ( aShape.ShapeType() != aNeedType ) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
if (!aSelectedObject->_is_nil()) { // clear selection if something selected
globalSelection();
localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
}
if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) { if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) {
myPoint = aSelectedObject; myPoint = aSelectedObject;
if ( !myPoint->_is_nil() && myDir->_is_nil() ) if ( myPoint && !myDir )
GroupPntVecR->PushButton2->click(); GroupPntVecR->PushButton2->click();
} }
else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) { else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
myDir = aSelectedObject; myDir = aSelectedObject;
if ( !myDir->_is_nil() && myPoint->_is_nil() ) if ( myDir && !myPoint )
GroupPntVecR->PushButton1->click(); GroupPntVecR->PushButton1->click();
} }
else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) { else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) if ( myPoint1 && !myPoint2 )
Group3Pnts->PushButton2->click(); Group3Pnts->PushButton2->click();
} }
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) { else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
if ( !myPoint2->_is_nil() && myPoint3->_is_nil() ) if ( myPoint2 && !myPoint3 )
Group3Pnts->PushButton3->click(); Group3Pnts->PushButton3->click();
} }
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) { else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
myPoint3 = aSelectedObject; myPoint3 = aSelectedObject;
if ( !myPoint3->_is_nil() && myPoint1->_is_nil() ) if ( myPoint3 && !myPoint1 )
Group3Pnts->PushButton1->click(); Group3Pnts->PushButton1->click();
} }
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) { else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) {
myPoint4 = aSelectedObject; myPoint4 = aSelectedObject;
if ( !myPoint4->_is_nil() && myPoint5->_is_nil() ) if ( myPoint4 && !myPoint5 )
GroupCenter2Pnts->PushButton2->click(); GroupCenter2Pnts->PushButton2->click();
} }
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) { else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) {
myPoint5 = aSelectedObject; myPoint5 = aSelectedObject;
if ( !myPoint5->_is_nil() && myPoint6->_is_nil() ) if ( myPoint5 && !myPoint6 )
GroupCenter2Pnts->PushButton3->click(); GroupCenter2Pnts->PushButton3->click();
} }
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) { else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) {
myPoint6 = aSelectedObject; myPoint6 = aSelectedObject;
if ( !myPoint6->_is_nil() && myPoint4->_is_nil() ) if ( myPoint6 && !myPoint4 )
GroupCenter2Pnts->PushButton1->click(); GroupCenter2Pnts->PushButton1->click();
} }
} }
@ -499,14 +468,10 @@ void BasicGUI_CircleDlg::SetEditCurrentArgument()
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) { TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) ?
TopAbs_EDGE : TopAbs_VERTEX;
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
}
else {
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
}
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
// SelectionIntoArgument(); // SelectionIntoArgument();
@ -514,26 +479,6 @@ void BasicGUI_CircleDlg::SetEditCurrentArgument()
displayPreview(); displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void BasicGUI_CircleDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPntVecR->LineEdit1 ||
send == GroupPntVecR->LineEdit2 ||
send == Group3Pnts->LineEdit1 ||
send == Group3Pnts->LineEdit2 ||
send == Group3Pnts->LineEdit3 ||
send == GroupCenter2Pnts->LineEdit1 ||
send == GroupCenter2Pnts->LineEdit2 ||
send == GroupCenter2Pnts->LineEdit3 ) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
@ -566,7 +511,6 @@ void BasicGUI_CircleDlg::enterEvent( QEvent* )
//================================================================================= //=================================================================================
void BasicGUI_CircleDlg::DeactivateActiveDialog() void BasicGUI_CircleDlg::DeactivateActiveDialog()
{ {
// myGeomGUI->SetState( -1 );
GEOMBase_Skeleton::DeactivateActiveDialog(); GEOMBase_Skeleton::DeactivateActiveDialog();
} }
@ -602,36 +546,31 @@ GEOM::GEOM_IOperations_ptr BasicGUI_CircleDlg::createOperation()
return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() ); return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() );
} }
//=================================================================================
// function : isEqual
// purpose : it may also be needed to check for min distance between gp_Pnt-s...
//=================================================================================
static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
{
return thePnt1->_is_equivalent( thePnt2 );
}
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool BasicGUI_CircleDlg::isValid( QString& msg ) bool BasicGUI_CircleDlg::isValid( QString& msg )
{ {
const int id = getConstructorId(); bool ok = false;
if ( id == 0 ) { switch( getConstructorId() ) {
//return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0; case 0:
// nil point means origin of global CS // nil point means origin of global CS
// nil vector means Z axis // nil vector means Z axis
bool ok = GroupPntVecR->SpinBox_DX->isValid(msg, !IsPreview()); ok = GroupPntVecR->SpinBox_DX->isValid(msg, !IsPreview()) && getRadius() > 0;
return getRadius() > 0 && ok; break;
case 1:
ok = myPoint1 && myPoint2 && myPoint3 && myPoint1 != myPoint2 &&
myPoint1 != myPoint3 && myPoint2 != myPoint3;
break;
case 2:
ok = myPoint4 && myPoint5 && myPoint6 && myPoint4 != myPoint5 &&
myPoint5 != myPoint6 && myPoint4 != myPoint6;
break;
default:
break;
} }
else if ( id == 1 ) return ok;
return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() &&
!isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 );
else if ( id == 2 )
return !myPoint4->_is_nil() && !myPoint5->_is_nil() && !myPoint6->_is_nil() &&
!isEqual( myPoint4, myPoint5 ) && !isEqual( myPoint5, myPoint6 ) && !isEqual( myPoint4, myPoint6 );
return false;
} }
//================================================================================= //=================================================================================
@ -651,18 +590,18 @@ bool BasicGUI_CircleDlg::execute( ObjectList& objects )
{ {
QStringList aParameters; QStringList aParameters;
aParameters << GroupPntVecR->SpinBox_DX->text(); aParameters << GroupPntVecR->SpinBox_DX->text();
anObj = anOper->MakeCirclePntVecR( myPoint, myDir, getRadius() ); anObj = anOper->MakeCirclePntVecR( myPoint.get(), myDir.get(), getRadius() );
if ( !anObj->_is_nil() && !IsPreview() ) if ( !anObj->_is_nil() && !IsPreview() )
anObj->SetParameters(aParameters.join(":").toLatin1().constData()); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
res = true; res = true;
break; break;
} }
case 1 : case 1 :
anObj = anOper->MakeCircleThreePnt( myPoint1, myPoint2, myPoint3 ); anObj = anOper->MakeCircleThreePnt( myPoint1.get(), myPoint2.get(), myPoint3.get() );
res = true; res = true;
break; break;
case 2: case 2:
anObj = anOper->MakeCircleCenter2Pnt( myPoint4, myPoint5, myPoint6 ); anObj = anOper->MakeCircleCenter2Pnt( myPoint4.get(), myPoint5.get(), myPoint6.get() );
res = true; res = true;
break; break;
} }
@ -682,25 +621,22 @@ bool BasicGUI_CircleDlg::execute( ObjectList& objects )
//================================================================================= //=================================================================================
void BasicGUI_CircleDlg::addSubshapesToStudy() void BasicGUI_CircleDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0: case 0:
if (!CORBA::is_nil(myPoint)) GEOMBase::PublishSubObject( myPoint.get() );
objMap[GroupPntVecR->LineEdit1->text()] = myPoint; GEOMBase::PublishSubObject( myDir.get() );
if (!CORBA::is_nil(myDir))
objMap[GroupPntVecR->LineEdit2->text()] = myDir;
break; break;
case 1: case 1:
objMap[Group3Pnts->LineEdit1->text()] = myPoint1; GEOMBase::PublishSubObject( myPoint1.get() );
objMap[Group3Pnts->LineEdit2->text()] = myPoint2; GEOMBase::PublishSubObject( myPoint2.get() );
objMap[Group3Pnts->LineEdit3->text()] = myPoint3; GEOMBase::PublishSubObject( myPoint3.get() );
break; break;
case 2: case 2:
objMap[GroupCenter2Pnts->LineEdit1->text()] = myPoint4; GEOMBase::PublishSubObject( myPoint4.get() );
objMap[GroupCenter2Pnts->LineEdit2->text()] = myPoint5; GEOMBase::PublishSubObject( myPoint5.get() );
objMap[GroupCenter2Pnts->LineEdit3->text()] = myPoint6; GEOMBase::PublishSubObject( myPoint6.get() );
break;
default:
break; break;
} }
addSubshapesToFather( objMap );
} }

View File

@ -27,7 +27,8 @@
#ifndef BASICGUI_CIRCLEDLG_H #ifndef BASICGUI_CIRCLEDLG_H
#define BASICGUI_CIRCLEDLG_H #define BASICGUI_CIRCLEDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_3Sel; class DlgRef_3Sel;
class DlgRef_2Sel1Spin; class DlgRef_2Sel1Spin;
@ -58,7 +59,7 @@ private:
double getRadius() const; double getRadius() const;
private: private:
GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3, myPoint4, myPoint5, myPoint6; GEOM::GeomObjPtr myPoint, myDir, myPoint1, myPoint2, myPoint3, myPoint4, myPoint5, myPoint6;
DlgRef_2Sel1Spin* GroupPntVecR; DlgRef_2Sel1Spin* GroupPntVecR;
DlgRef_3Sel* Group3Pnts; DlgRef_3Sel* Group3Pnts;
@ -74,7 +75,6 @@ private slots:
void SelectionIntoArgument(); void SelectionIntoArgument();
void ConstructorsClicked( int ); void ConstructorsClicked( int );
void LineEditReturnPressed();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ValueChangedInSpinBox(); void ValueChangedInSpinBox();
void SetDoubleSpinBoxStep( double ); void SetDoubleSpinBoxStep( double );

View File

@ -112,8 +112,7 @@ void BasicGUI_CurveDlg::Init()
/* init variables */ /* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
myPoints = new GEOM::ListOfGO(); myPoints.clear();
myPoints->length( 0 );
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
@ -128,7 +127,6 @@ void BasicGUI_CurveDlg::Init()
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->CheckButton1,SIGNAL( toggled(bool) ), this, SLOT( CheckButtonToggled() ) ); connect( GroupPoints->CheckButton1,SIGNAL( toggled(bool) ), this, SLOT( CheckButtonToggled() ) );
@ -154,8 +152,7 @@ void BasicGUI_CurveDlg::ConstructorsClicked( int id )
else else
GroupPoints->CheckButton1->hide(); GroupPoints->CheckButton1->hide();
myPoints = new GEOM::ListOfGO(); myPoints.clear();
myPoints->length( 0 );
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
qApp->processEvents(); qApp->processEvents();
@ -177,20 +174,6 @@ void BasicGUI_CurveDlg::SetEditCurrentArgument()
SelectionIntoArgument(); SelectionIntoArgument();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void BasicGUI_CurveDlg::LineEditReturnPressed()
{
if ( sender() == GroupPoints->LineEdit1 )
{
myEditCurrentArgument = GroupPoints->LineEdit1;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : CheckButtonToggled() // function : CheckButtonToggled()
// purpose : // purpose :
@ -225,56 +208,29 @@ bool BasicGUI_CurveDlg::ClickOnApply()
return true; return true;
} }
//================================================================================= static void synchronize( QList<GEOM::GeomObjPtr>& left, QList<GEOM::GeomObjPtr>& right )
/*! function : isPointInList()
* purpose : Check is point (theObject) in the list \a thePoints.
* \author enk
* \retval -1, if point not in list, else 1 in list
*/
//=================================================================================
static int isPointInList( std::list<GEOM::GEOM_Object_var>& thePoints,
GEOM::GEOM_Object_var& theObject )
{ {
int len = thePoints.size(); // 1. remove items from the "left" list that are not in the "right" list
QMutableListIterator<GEOM::GeomObjPtr> it1( left );
if ( len < 1 ) { while ( it1.hasNext() ) {
return -1; GEOM::GeomObjPtr o1 = it1.next();
}
for ( std::list<GEOM::GEOM_Object_var>::iterator i = thePoints.begin(); i != thePoints.end(); i++ ) {
if ( std::string( (*i)->GetEntry() ) == std::string( theObject->GetEntry() ) ) {
return 1;
}
}
return -1;
}
//=================================================================================
/*! function : removeUnnecessaryPnt()
* purpose : Remove unnecessary points from list \a theOldPoints
* \author enk
* \li \a theOldPoints - ordered sequence with unnecessary point
* \li \a theNewPoints - not ordered sequence with necessary points
*/
//=================================================================================
static void removeUnnecessaryPnt( std::list<GEOM::GEOM_Object_var>& theOldPoints,
GEOM::ListOfGO_var& theNewPoints )
{
std::list<GEOM::GEOM_Object_var> objs_to_remove;
for ( std::list<GEOM::GEOM_Object_var>::iterator i = theOldPoints.begin(); i != theOldPoints.end(); i++ ) {
bool found = false; bool found = false;
for ( int j = 0; j < theNewPoints->length() && !found ; j++ ) { QMutableListIterator<GEOM::GeomObjPtr> it2( right );
if ( std::string( (*i)->GetEntry() ) == std::string( theNewPoints[j]->GetEntry() ) ) { while ( it2.hasNext() && !found )
found = true; found = o1 == it2.next();
if ( !found )
it1.remove();
} }
} // 2. add items from the "right" list that are not in the "left" list (to keep selection order)
if ( !found ) { it1 = right;
objs_to_remove.push_back( *i ); while ( it1.hasNext() ) {
//cout << "removed: " << (*i)->GetEntry() << endl; GEOM::GeomObjPtr o1 = it1.next();
} bool found = false;
} QMutableListIterator<GEOM::GeomObjPtr> it2( left );
for ( std::list<GEOM::GEOM_Object_var>::iterator i = objs_to_remove.begin(); i != objs_to_remove.end(); i++ ) { while ( it2.hasNext() && !found )
theOldPoints.remove( *i ); found = o1 == it2.next();
if ( !found )
left << o1;
} }
} }
@ -284,98 +240,12 @@ static void removeUnnecessaryPnt( std::list<GEOM::GEOM_Object_var>& theOldPoints
//================================================================================= //=================================================================================
void BasicGUI_CurveDlg::SelectionIntoArgument() void BasicGUI_CurveDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); QList<GEOM::GeomObjPtr> points = getSelected( TopAbs_VERTEX, -1 );
synchronize( myPoints, points );
SalomeApp_Application* app = myGeomGUI->getApp(); if ( !myPoints.isEmpty() )
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy()); GroupPoints->LineEdit1->setText( QString::number( myPoints.count() ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) );
_PTR(Study) aDStudy = appStudy->studyDS();
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
int anIndex;
TopoDS_Shape aShape;
TColStd_IndexedMapOfInteger aMapIndexes;
GEOM::GEOM_Object_var anObject;
std::list<GEOM::GEOM_Object_var> aList;
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
SALOME_ListIO selected;
aSelMgr->selectedObjects(selected, QString::null, false);
int IOC = selected.Extent();
// bool is_append = myPoints->length() < IOC; // if true - add point, else remove
// myPoints->length( IOC ); // this length may be greater than number of objects,
// that will actually be put into myPoints
for (SALOME_ListIteratorOfListIO anIt (selected); anIt.More(); anIt.Next()) {
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value() );
if (!CORBA::is_nil(aSelectedObject) ) {
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
aSelMgr->GetIndexes(anIt.Value(), aMapIndexes);
if (aMapIndexes.Extent() > 0) {
for (int ii = 1; ii <= aMapIndexes.Extent(); ii++) {
anIndex = aMapIndexes(ii);
QString aName = GEOMBase::GetName( aSelectedObject );
aName = aName + ":vertex_" + QString::number( anIndex );
anObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
//Find Object in study
_PTR(SObject) obj ( aDStudy->FindObjectID( anIt.Value()->getEntry() ) );
bool inStudy = false;
_PTR(ChildIterator) iit( aDStudy->NewChildIterator( obj ) );
for (; iit->More() && !inStudy; iit->Next()) {
_PTR(SObject) child( iit->Value() );
QString aChildName = child->GetName().c_str();
if ( aChildName == aName ) {
inStudy = true;
CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( iit->Value() );
anObject = GEOM::GEOM_Object::_narrow( corbaObj );
}
}
if ( !inStudy )
GeometryGUI::GetGeomGen()->AddInStudy( GeometryGUI::ClientStudyToStudy( aDStudy ),
anObject, aName.toLatin1().data(), aSelectedObject );
int pos = isPointInList( myOrderedSel, anObject );
if ( pos == -1 ) {
myOrderedSel.push_back( anObject );
}
// if (!inStudy)
aList.push_back(anObject);
}
}
else { // aMap.Extent() == 0
if ( aShape.ShapeType() == TopAbs_VERTEX ) {
int pos = isPointInList( myOrderedSel, aSelectedObject );
if ( pos == -1 )
myOrderedSel.push_back( aSelectedObject );
aList.push_back( aSelectedObject );
}
}
}
}
}
myPoints->length( aList.size() );
int k = 0;
for ( std::list<GEOM::GEOM_Object_var>::iterator j = aList.begin(); j != aList.end(); j++ )
myPoints[k++] = *j;
if ( IOC == 0 )
myOrderedSel.clear();
else else
removeUnnecessaryPnt( myOrderedSel, myPoints ); GroupPoints->LineEdit1->setText( "" );
// if ( myOrderedSel.size() == myPoints->length() ) {
myPoints->length( myOrderedSel.size() );
k = 0;
for ( std::list<GEOM::GEOM_Object_var>::iterator j = myOrderedSel.begin(); j != myOrderedSel.end(); j++ )
myPoints[k++] = *j;
// }
if ( myPoints->length() > 0 )
GroupPoints->LineEdit1->setText( QString::number( myPoints->length() ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) );
displayPreview(); displayPreview();
} }
@ -431,7 +301,7 @@ GEOM::GEOM_IOperations_ptr BasicGUI_CurveDlg::createOperation()
//================================================================================= //=================================================================================
bool BasicGUI_CurveDlg::isValid( QString& msg ) bool BasicGUI_CurveDlg::isValid( QString& msg )
{ {
return myPoints->length() > 1; return myPoints.count() > 1;
} }
//================================================================================= //=================================================================================
@ -446,17 +316,22 @@ bool BasicGUI_CurveDlg::execute( ObjectList& objects )
GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() ); GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() );
GEOM::ListOfGO_var points = new GEOM::ListOfGO();
points->length( myPoints.count() );
for ( int i = 0; i < myPoints.count(); i++ )
points[i] = myPoints[i].copy();
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0 : case 0 :
anObj = anOper->MakePolyline( myPoints ); anObj = anOper->MakePolyline( points.in() );
res = true; res = true;
break; break;
case 1 : case 1 :
anObj = anOper->MakeSplineBezier( myPoints ); anObj = anOper->MakeSplineBezier( points.in() );
res = true; res = true;
break; break;
case 2 : case 2 :
anObj = anOper->MakeSplineInterpolation( myPoints, GroupPoints->CheckButton1->isChecked() ); anObj = anOper->MakeSplineInterpolation( points.in(), GroupPoints->CheckButton1->isChecked() );
res = true; res = true;
break; break;
} }
@ -466,3 +341,13 @@ bool BasicGUI_CurveDlg::execute( ObjectList& objects )
return res; return res;
} }
//=================================================================================
// function : addSubshapeToStudy
// purpose : virtual method to add new SubObjects if local selection
//=================================================================================
void BasicGUI_CurveDlg::addSubshapesToStudy()
{
for ( int i = 0; i < myPoints.count(); i++ )
GEOMBase::PublishSubObject( myPoints[i].get() );
}

View File

@ -27,7 +27,8 @@
#ifndef BASICGUI_CURVEDLG_H #ifndef BASICGUI_CURVEDLG_H
#define BASICGUI_CURVEDLG_H #define BASICGUI_CURVEDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
#include <list> #include <list>
@ -50,6 +51,7 @@ protected:
virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& ); virtual bool isValid( QString& );
virtual bool execute( ObjectList& ); virtual bool execute( ObjectList& );
virtual void addSubshapesToStudy();
private: private:
void Init(); void Init();
@ -57,8 +59,7 @@ private:
private: private:
DlgRef_1Sel1Check* GroupPoints; DlgRef_1Sel1Check* GroupPoints;
GEOM::ListOfGO_var myPoints; QList<GEOM::GeomObjPtr> myPoints;
std::list<GEOM::GEOM_Object_var> myOrderedSel; //!< This list used for managing orderes selection
private slots: private slots:
void ClickOnOk(); void ClickOnOk();
@ -68,7 +69,6 @@ private slots:
void DeactivateActiveDialog(); void DeactivateActiveDialog();
void ConstructorsClicked( int ); void ConstructorsClicked( int );
void LineEditReturnPressed();
void CheckButtonToggled(); void CheckButtonToggled();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();

View File

@ -115,11 +115,11 @@ void BasicGUI_EllipseDlg::Init()
{ {
/* init variables */ /* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
GroupPoints->PushButton1->setDown(true); GroupPoints->PushButton1->setDown(true);
myPoint = myDir = myMajor = GEOM::GEOM_Object::_nil(); myPoint.nullify();
myDir.nullify();
myMajor.nullify();
/* Get setting of step value from file configuration */ /* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
@ -144,10 +144,6 @@ void BasicGUI_EllipseDlg::Init()
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupPoints->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupPoints->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupPoints->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
@ -158,6 +154,9 @@ void BasicGUI_EllipseDlg::Init()
initName( tr( "GEOM_ELLIPSE" ) ); initName( tr( "GEOM_ELLIPSE" ) );
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
resize( minimumSizeHint() ); resize( minimumSizeHint() );
SelectionIntoArgument(); SelectionIntoArgument();
displayPreview(); displayPreview();
@ -197,7 +196,9 @@ bool BasicGUI_EllipseDlg::ClickOnApply()
initName(); initName();
// reset // reset
myPoint = myDir = myMajor = GEOM::GEOM_Object::_nil(); myPoint.nullify();
myDir.nullify();
myMajor.nullify();
GroupPoints->LineEdit1->setText( "" ); GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" ); GroupPoints->LineEdit2->setText( "" );
GroupPoints->LineEdit3->setText( "" ); GroupPoints->LineEdit3->setText( "" );
@ -229,73 +230,33 @@ void BasicGUI_EllipseDlg::SelectionIntoArgument()
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = GEOM::GEOM_Object::_nil(); if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint.nullify();
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir.nullify();
else if (myEditCurrentArgument == GroupPoints->LineEdit3) myMajor = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == GroupPoints->LineEdit3) myMajor.nullify();
return; return;
} }
Handle(SALOME_InteractiveObject) anIO = aSelList.First(); TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO ); myEditCurrentArgument == GroupPoints->LineEdit3 ) ?
if (!CORBA::is_nil(aSelectedObject) ) { TopAbs_EDGE : TopAbs_VERTEX;
QString aName = GEOMBase::GetName(aSelectedObject); GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
// Get Selected object if selected subshape
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; QString aName = GEOMBase::GetName( aSelectedObject.get() );
if ( myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupPoints->LineEdit3 )
aNeedType = TopAbs_EDGE;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(anIO, aMap);
if (aMap.Extent() == 1) {
int anIndex = aMap(1);
if (aNeedType == TopAbs_EDGE)
aName += QString(":edge_%1").arg(anIndex);
else
aName += QString(":vertex_%1").arg(anIndex);
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if (aFindedObject->_is_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else { // Global Selection
if (aShape.ShapeType() != aNeedType) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
if (!aSelectedObject->_is_nil()) { // clear selection if something selected
globalSelection();
localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
}
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
myPoint = aSelectedObject; myPoint = aSelectedObject;
if ( !myPoint->_is_nil() && myDir->_is_nil() ) if ( myPoint && !myDir )
GroupPoints->PushButton2->click(); GroupPoints->PushButton2->click();
} }
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
myDir = aSelectedObject; myDir = aSelectedObject;
if ( !myDir->_is_nil() && myMajor->_is_nil() ) if ( myDir && !myMajor )
GroupPoints->PushButton3->click(); GroupPoints->PushButton3->click();
} }
else if ( myEditCurrentArgument == GroupPoints->LineEdit3 ) { else if ( myEditCurrentArgument == GroupPoints->LineEdit3 ) {
myMajor = aSelectedObject; myMajor = aSelectedObject;
if ( !myMajor->_is_nil() && myPoint->_is_nil() ) if ( myMajor && !myPoint )
GroupPoints->PushButton1->click(); GroupPoints->PushButton1->click();
} }
} }
@ -337,10 +298,10 @@ void BasicGUI_EllipseDlg::SetEditCurrentArgument()
GroupPoints->LineEdit3->setEnabled( true ); GroupPoints->LineEdit3->setEnabled( true );
} }
TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
myEditCurrentArgument == GroupPoints->LineEdit3 ) ?
TopAbs_EDGE : TopAbs_VERTEX;
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if ( myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupPoints->LineEdit3 )
aNeedType = TopAbs_EDGE;
localSelection( GEOM::GEOM_Object::_nil(), aNeedType ); localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
@ -349,21 +310,6 @@ void BasicGUI_EllipseDlg::SetEditCurrentArgument()
displayPreview(); displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void BasicGUI_EllipseDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2 ||
send == GroupPoints->LineEdit3 ) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
@ -382,7 +328,8 @@ void BasicGUI_EllipseDlg::ActivateThisDialog()
GroupPoints->LineEdit2->setText( "" ); GroupPoints->LineEdit2->setText( "" );
GroupPoints->LineEdit3->setText( "" ); GroupPoints->LineEdit3->setText( "" );
myPoint = myDir = GEOM::GEOM_Object::_nil(); myPoint.nullify();
myDir.nullify();
//globalSelection( GEOM_POINT ); //globalSelection( GEOM_POINT );
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
@ -432,18 +379,18 @@ GEOM::GEOM_IOperations_ptr BasicGUI_EllipseDlg::createOperation()
//================================================================================= //=================================================================================
bool BasicGUI_EllipseDlg::isValid( QString& msg ) bool BasicGUI_EllipseDlg::isValid( QString& msg )
{ {
// nil point means origin of global CS
// nil vector means Z axis
bool ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() );
if ( ok ) {
double aMajorR = GroupPoints->SpinBox_DX->value(); double aMajorR = GroupPoints->SpinBox_DX->value();
double aMinorR = GroupPoints->SpinBox_DY->value(); double aMinorR = GroupPoints->SpinBox_DY->value();
if ( aMajorR < aMinorR ) { if ( aMajorR < aMinorR ) {
msg = tr( "GEOM_ELLIPSE_ERROR_1" ); msg = tr( "GEOM_ELLIPSE_ERROR_1" );
return false; ok = false;
}
} }
//return !myPoint->_is_nil() && !myDir->_is_nil();
//nil point means origin of global CS
//nil vector means Z axis
bool ok = true;
ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
return ok; return ok;
} }
@ -461,9 +408,9 @@ bool BasicGUI_EllipseDlg::execute( ObjectList& objects )
aParameters<<GroupPoints->SpinBox_DY->text(); aParameters<<GroupPoints->SpinBox_DY->text();
GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() ); GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() );
GEOM::GEOM_Object_var anObj = myMajor->_is_nil() ? GEOM::GEOM_Object_var anObj = myMajor ?
anOper->MakeEllipse ( myPoint, myDir, aMajorR, aMinorR ) : anOper->MakeEllipseVec( myPoint.get(), myDir.get(), aMajorR, aMinorR, myMajor.get() ) :
anOper->MakeEllipseVec( myPoint, myDir, aMajorR, aMinorR, myMajor ); anOper->MakeEllipse ( myPoint.get(), myDir.get(), aMajorR, aMinorR );
if ( !anObj->_is_nil() ) { if ( !anObj->_is_nil() ) {
if ( !IsPreview() ) if ( !IsPreview() )
anObj->SetParameters(aParameters.join(":").toLatin1().constData()); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
@ -478,14 +425,7 @@ bool BasicGUI_EllipseDlg::execute( ObjectList& objects )
//================================================================================= //=================================================================================
void BasicGUI_EllipseDlg::addSubshapesToStudy() void BasicGUI_EllipseDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap; GEOMBase::PublishSubObject( myPoint.get() );
GEOMBase::PublishSubObject( myDir.get() );
if (!CORBA::is_nil(myPoint)) GEOMBase::PublishSubObject( myMajor.get() );
objMap[GroupPoints->LineEdit1->text()] = myPoint;
if (!CORBA::is_nil(myDir))
objMap[GroupPoints->LineEdit2->text()] = myDir;
if (!CORBA::is_nil(myMajor))
objMap[GroupPoints->LineEdit3->text()] = myMajor;
addSubshapesToFather( objMap );
} }

View File

@ -27,7 +27,8 @@
#ifndef BASICGUI_ELLIPSEDLG_H #ifndef BASICGUI_ELLIPSEDLG_H
#define BASICGUI_ELLIPSEDLG_H #define BASICGUI_ELLIPSEDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_3Sel2Spin; class DlgRef_3Sel2Spin;
@ -55,7 +56,7 @@ private:
void enterEvent( QEvent* ); void enterEvent( QEvent* );
private: private:
GEOM::GEOM_Object_var myPoint, myDir, myMajor; GEOM::GeomObjPtr myPoint, myDir, myMajor;
DlgRef_3Sel2Spin* GroupPoints; DlgRef_3Sel2Spin* GroupPoints;
@ -66,7 +67,6 @@ private slots:
void ActivateThisDialog(); void ActivateThisDialog();
void DeactivateActiveDialog(); void DeactivateActiveDialog();
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ValueChangedInSpinBox( double ); void ValueChangedInSpinBox( double );

View File

@ -120,11 +120,12 @@ void BasicGUI_LineDlg::Init()
{ {
/* init variables */ /* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); myPoint1.nullify();
globalSelection(); // close local contexts, if any myPoint2.nullify();
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); myFace1.nullify();
GroupPoints->PushButton1->setDown(true); myFace2.nullify();
GroupPoints->PushButton1->setDown(true);
/* signals and slots connections */ /* signals and slots connections */
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
@ -140,11 +141,6 @@ void BasicGUI_LineDlg::Init()
connect( GroupFaces->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupFaces->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupFaces->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupFaces->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupFaces->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupFaces->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) ); this, SLOT( SelectionIntoArgument() ) );
@ -190,14 +186,11 @@ void BasicGUI_LineDlg::ConstructorsClicked( int constructorId )
switch ( constructorId ) { switch ( constructorId ) {
case 0: case 0:
{ {
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
GroupPoints->LineEdit2->setText( "" ); GroupPoints->LineEdit2->setText( "" );
myPoint1 = GEOM::GEOM_Object::_nil(); myPoint1.nullify();
myPoint2 = GEOM::GEOM_Object::_nil(); myPoint2.nullify();
GroupPoints->PushButton1->setDown(true); GroupPoints->PushButton1->setDown(true);
GroupPoints->PushButton2->setDown(false); GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit1->setEnabled(true); GroupPoints->LineEdit1->setEnabled(true);
@ -208,13 +201,10 @@ void BasicGUI_LineDlg::ConstructorsClicked( int constructorId )
} }
case 1: case 1:
{ {
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
myEditCurrentArgument = GroupFaces->LineEdit1; myEditCurrentArgument = GroupFaces->LineEdit1;
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
myFace1 = GEOM::GEOM_Object::_nil(); myFace1.nullify();
myFace2 = GEOM::GEOM_Object::_nil(); myFace2.nullify();
GroupFaces->PushButton1->setDown(true); GroupFaces->PushButton1->setDown(true);
GroupFaces->PushButton2->setDown(false); GroupFaces->PushButton2->setDown(false);
GroupFaces->LineEdit1->setEnabled(true); GroupFaces->LineEdit1->setEnabled(true);
@ -225,6 +215,12 @@ void BasicGUI_LineDlg::ConstructorsClicked( int constructorId )
} }
} }
TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupFaces->LineEdit1 ||
myEditCurrentArgument == GroupFaces->LineEdit2 ) ?
TopAbs_FACE : TopAbs_VERTEX;
globalSelection(); // close local selection to clear it
localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
qApp->processEvents(); qApp->processEvents();
updateGeometry(); updateGeometry();
resize( minimumSizeHint() ); resize( minimumSizeHint() );
@ -244,77 +240,40 @@ void BasicGUI_LineDlg::SelectionIntoArgument()
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil(); if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1.nullify();
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2.nullify();
else if (myEditCurrentArgument == GroupFaces->LineEdit1) myFace1 = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == GroupFaces->LineEdit1) myFace1.nullify();
else if (myEditCurrentArgument == GroupFaces->LineEdit2) myFace2 = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == GroupFaces->LineEdit2) myFace2.nullify();
displayPreview(); displayPreview();
return; return;
} }
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupFaces->LineEdit1 ||
if ( !CORBA::is_nil( aSelectedObject ) ) { myEditCurrentArgument == GroupFaces->LineEdit2 ) ?
QString aName = GEOMBase::GetName( aSelectedObject ); TopAbs_FACE : TopAbs_VERTEX;
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
if ( myEditCurrentArgument == GroupFaces->LineEdit1 ||
myEditCurrentArgument == GroupFaces->LineEdit2 )
aNeedType = TopAbs_FACE;
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
TColStd_IndexedMapOfInteger aMap; QString aName = GEOMBase::GetName( aSelectedObject.get() );
aSelMgr->GetIndexes(aSelList.First(), aMap);
if ( aMap.Extent() == 1 ) { // Local Selection
int anIndex = aMap( 1 );
if ( aNeedType == TopAbs_FACE )
aName += QString( ":face_%1" ).arg( anIndex );
else
aName += QString( ":vertex_%1" ).arg( anIndex );
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
if ( aFindedObject->_is_nil() ) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else { // Global Selection
if ( aShape.ShapeType() != aNeedType ) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
if (!aSelectedObject->_is_nil()) { // clear selection if something selected
globalSelection();
localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
}
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) if ( myPoint1 && !myPoint2 )
GroupPoints->PushButton2->click(); GroupPoints->PushButton2->click();
} }
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
if ( !myPoint2->_is_nil() && myPoint1->_is_nil() ) if ( myPoint2 && !myPoint1 )
GroupPoints->PushButton1->click(); GroupPoints->PushButton1->click();
} }
else if ( myEditCurrentArgument == GroupFaces->LineEdit1 ) { else if ( myEditCurrentArgument == GroupFaces->LineEdit1 ) {
myFace1 = aSelectedObject; myFace1 = aSelectedObject;
if ( !myFace1->_is_nil() && myFace2->_is_nil() ) if ( myFace1 && !myFace2 )
GroupFaces->PushButton2->click(); GroupFaces->PushButton2->click();
} }
else if ( myEditCurrentArgument == GroupFaces->LineEdit2 ) { else if ( myEditCurrentArgument == GroupFaces->LineEdit2 ) {
myFace2 = aSelectedObject; myFace2 = aSelectedObject;
if ( !myFace2->_is_nil() && myFace1->_is_nil() ) if ( myFace2 && !myFace1 )
GroupFaces->PushButton1->click(); GroupFaces->PushButton1->click();
} }
} }
@ -322,7 +281,6 @@ void BasicGUI_LineDlg::SelectionIntoArgument()
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -355,10 +313,10 @@ void BasicGUI_LineDlg::SetEditCurrentArgument()
GroupFaces->LineEdit2->setEnabled(true); GroupFaces->LineEdit2->setEnabled(true);
} }
TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupFaces->LineEdit1 ||
myEditCurrentArgument == GroupFaces->LineEdit2 ) ?
TopAbs_FACE : TopAbs_VERTEX;
globalSelection(); // close local selection to clear it globalSelection(); // close local selection to clear it
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if ( myEditCurrentArgument == GroupFaces->LineEdit1 || myEditCurrentArgument == GroupFaces->LineEdit2 )
aNeedType = TopAbs_FACE;
localSelection( GEOM::GEOM_Object::_nil(), aNeedType ); localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
@ -367,23 +325,6 @@ void BasicGUI_LineDlg::SetEditCurrentArgument()
displayPreview(); displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void BasicGUI_LineDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 ) myEditCurrentArgument = GroupPoints->LineEdit1;
else if ( send == GroupPoints->LineEdit2 ) myEditCurrentArgument = GroupPoints->LineEdit2;
else if ( send == GroupFaces->LineEdit1 ) myEditCurrentArgument = GroupFaces->LineEdit1;
else if ( send == GroupFaces->LineEdit2 ) myEditCurrentArgument = GroupFaces->LineEdit2;
else return;
GEOMBase_Skeleton::LineEditReturnPressed();
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -431,12 +372,18 @@ GEOM::GEOM_IOperations_ptr BasicGUI_LineDlg::createOperation()
//================================================================================= //=================================================================================
bool BasicGUI_LineDlg::isValid( QString& msg ) bool BasicGUI_LineDlg::isValid( QString& msg )
{ {
const int id = getConstructorId(); bool ok = false;
if ( id == 0 ) switch ( getConstructorId() ) {
return !myPoint1->_is_nil() && !myPoint2->_is_nil(); case 0 :
else if ( id == 1 ) ok = myPoint1 && myPoint2;
return !myFace1->_is_nil() && !myFace2->_is_nil(); break;
return false; case 1:
ok = myFace1 && myFace2;
break;
default:
break;
}
return ok;
} }
//================================================================================= //=================================================================================
@ -450,11 +397,11 @@ bool BasicGUI_LineDlg::execute( ObjectList& objects )
GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() ); GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0 : case 0 :
anObj = anOper->MakeLineTwoPnt( myPoint1, myPoint2 ); anObj = anOper->MakeLineTwoPnt( myPoint1.get(), myPoint2.get() );
res = true; res = true;
break; break;
case 1 : case 1 :
anObj = anOper->MakeLineTwoFaces( myFace1, myFace2 ); anObj = anOper->MakeLineTwoFaces( myFace1.get(), myFace2.get() );
res = true; res = true;
break; break;
} }
@ -471,16 +418,16 @@ bool BasicGUI_LineDlg::execute( ObjectList& objects )
//================================================================================= //=================================================================================
void BasicGUI_LineDlg::addSubshapesToStudy() void BasicGUI_LineDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0 : case 0 :
objMap[GroupPoints->LineEdit1->text()] = myPoint1; GEOMBase::PublishSubObject( myPoint1.get() );
objMap[GroupPoints->LineEdit2->text()] = myPoint2; GEOMBase::PublishSubObject( myPoint2.get() );
break; break;
case 1 : case 1 :
objMap[GroupFaces->LineEdit1->text()] = myFace1; GEOMBase::PublishSubObject( myFace1.get() );
objMap[GroupFaces->LineEdit2->text()] = myFace2; GEOMBase::PublishSubObject( myFace2.get() );
break;
default:
break; break;
} }
addSubshapesToFather( objMap );
} }

View File

@ -27,7 +27,8 @@
#ifndef BASICGUI_LINEDLG_H #ifndef BASICGUI_LINEDLG_H
#define BASICGUI_LINEDLG_H #define BASICGUI_LINEDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel; class DlgRef_2Sel;
@ -55,10 +56,10 @@ private:
void enterEvent( QEvent* ); void enterEvent( QEvent* );
private: private:
GEOM::GEOM_Object_var myPoint1; GEOM::GeomObjPtr myPoint1;
GEOM::GEOM_Object_var myPoint2; GEOM::GeomObjPtr myPoint2;
GEOM::GEOM_Object_var myFace1; GEOM::GeomObjPtr myFace1;
GEOM::GEOM_Object_var myFace2; GEOM::GeomObjPtr myFace2;
DlgRef_2Sel* GroupPoints; DlgRef_2Sel* GroupPoints;
DlgRef_2Sel* GroupFaces; DlgRef_2Sel* GroupFaces;
@ -71,7 +72,6 @@ private slots:
void DeactivateActiveDialog(); void DeactivateActiveDialog();
void ConstructorsClicked( int ); void ConstructorsClicked( int );
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
}; };

View File

@ -168,7 +168,10 @@ BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg()
//================================================================================= //=================================================================================
void BasicGUI_MarkerDlg::Init() void BasicGUI_MarkerDlg::Init()
{ {
myShape = myPoint = myVectorX = myVectorY = GEOM::GEOM_Object::_nil(); myShape.nullify();
myPoint.nullify();
myVectorX.nullify();
myVectorY.nullify();
myBlockPreview = false; myBlockPreview = false;
myConstructorId = -1; myConstructorId = -1;
myEditCurrentArgument = Group1->LineEdit1; myEditCurrentArgument = Group1->LineEdit1;
@ -187,11 +190,6 @@ void BasicGUI_MarkerDlg::Init()
connect( Group2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group2->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( Group2->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group1->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group2->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group2->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) ); connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) );
connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
@ -259,7 +257,7 @@ void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
globalSelection( GEOM_ALLGEOM ); globalSelection( GEOM_ALLGEOM );
myEditCurrentArgument = Group1->LineEdit1; myEditCurrentArgument = Group1->LineEdit1;
Group1->LineEdit1->setText( "" ); Group1->LineEdit1->setText( "" );
myShape = GEOM::GEOM_Object::_nil(); myShape.nullify();
break; break;
} }
case 2: case 2:
@ -279,9 +277,9 @@ void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
Group2->LineEdit1->setEnabled( true ); Group2->LineEdit1->setEnabled( true );
Group2->LineEdit2->setEnabled( false ); Group2->LineEdit2->setEnabled( false );
Group2->LineEdit3->setEnabled( false ); Group2->LineEdit3->setEnabled( false );
myPoint = GEOM::GEOM_Object::_nil(); myPoint.nullify();
myVectorX = GEOM::GEOM_Object::_nil(); myVectorX.nullify();
myVectorY = GEOM::GEOM_Object::_nil(); myVectorY.nullify();
break; break;
} }
} }
@ -328,19 +326,10 @@ bool BasicGUI_MarkerDlg::onApply()
//================================================================================= //=================================================================================
void BasicGUI_MarkerDlg::onSelectionDone0() void BasicGUI_MarkerDlg::onSelectionDone0()
{ {
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_FACE );
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() == 1) {
Handle(SALOME_InteractiveObject) anIO = aSelList.First();
GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO );
if ( !aSelectedObj->_is_nil() ) {
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { if ( aSelectedObject && aSelectedObject->GetType() == GEOM_MARKER && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
// Existing LCS selected // Existing LCS selected
if ( aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE ) {
TopoDS_Face aFace = TopoDS::Face( aShape ); TopoDS_Face aFace = TopoDS::Face( aShape );
Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) ); Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
@ -361,32 +350,19 @@ void BasicGUI_MarkerDlg::onSelectionDone0()
myData[ DX2 ]->setValue( aYDir.X() ); myData[ DX2 ]->setValue( aYDir.X() );
myData[ DY2 ]->setValue( aYDir.Y() ); myData[ DY2 ]->setValue( aYDir.Y() );
myData[ DZ2 ]->setValue( aYDir.Z() ); myData[ DZ2 ]->setValue( aYDir.Z() );
aSelMgr->clearSelected();
} }
displayPreview();
return;
} }
else { aSelectedObject = getSelected( TopAbs_VERTEX );
TColStd_IndexedMapOfInteger aMap; if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
aSelMgr->GetIndexes( anIO, aMap );
if ( aMap.Extent() == 1 ) { // Local Selection
int anIndex = aMap( 1 );
TopTools_IndexedMapOfShape aShapes;
TopExp::MapShapes( aShape, aShapes );
aShape = aShapes.FindKey( anIndex );
aSelMgr->clearSelected(); // ???
}
if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
myData[ X ]->setValue( aPnt.X() ); myData[ X ]->setValue( aPnt.X() );
myData[ Y ]->setValue( aPnt.Y() ); myData[ Y ]->setValue( aPnt.Y() );
myData[ Z ]->setValue( aPnt.Z() ); myData[ Z ]->setValue( aPnt.Z() );
}
}
}
}
}
displayPreview(); displayPreview();
return;
}
} }
@ -401,91 +377,49 @@ void BasicGUI_MarkerDlg::onSelectionDone()
return; return;
} }
myEditCurrentArgument->setText( "" ); TopAbs_ShapeEnum aNeedType;
if ( getConstructorId() == 1 ) // by shape position
aNeedType = TopAbs_SHAPE;
else if ( getConstructorId() == 2 ) // by point and two vectors
aNeedType = myEditCurrentArgument == Group2->LineEdit1 ? TopAbs_VERTEX : TopAbs_EDGE;
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() == 1) {
Handle(SALOME_InteractiveObject) anIO = aSelList.First();
GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO );
if ( !CORBA::is_nil( aSelectedObj ) ) {
QString aName = GEOMBase::GetName( aSelectedObj );
if ( getConstructorId() == 1 ) { // by shape position
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
myShape = aSelectedObj; QString aName = GEOMBase::GetName( aSelectedObject.get() );
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
if ( getConstructorId() == 1 ) { // by shape position
myShape = aSelectedObject;
} }
else if ( getConstructorId() == 2 ) { // by point and two vectors else if ( getConstructorId() == 2 ) { // by point and two vectors
TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) {
TopAbs_ShapeEnum aNeedType = TopAbs_EDGE;
if ( myEditCurrentArgument == Group2->LineEdit1 )
aNeedType = TopAbs_VERTEX;
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes( anIO, aMap );
if ( aMap.Extent() == 1 ) { // Local Selection
int anIndex = aMap( 1 );
if ( aNeedType == TopAbs_EDGE )
aName += QString( ":edge_%1" ).arg( anIndex );
else
aName += QString( ":vertex_%1" ).arg( anIndex );
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObj, aName );
if ( aFindedObject->_is_nil() ) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
aSelectedObj = aShapesOp->GetSubShape( aSelectedObj, anIndex );
}
else {
aSelectedObj = aFindedObject; // get Object from study
}
}
else { // Global Selection
if ( aShape.ShapeType() != aNeedType ) {
aSelectedObj = GEOM::GEOM_Object::_nil();
aName = "";
}
}
if ( myEditCurrentArgument == Group2->LineEdit1 ) { if ( myEditCurrentArgument == Group2->LineEdit1 ) {
myPoint = aSelectedObj; myPoint = aSelectedObject;
myEditCurrentArgument->setText( aName ); if (myPoint && !myVectorX)
if (!myPoint->_is_nil() && Group2->LineEdit2->text() == "")
Group2->PushButton2->click(); Group2->PushButton2->click();
} }
else if (myEditCurrentArgument == Group2->LineEdit2) { else if (myEditCurrentArgument == Group2->LineEdit2) {
myVectorX = aSelectedObj; myVectorX = aSelectedObject;
myEditCurrentArgument->setText( aName ); if (myVectorX && !myVectorY)
if (!myVectorX->_is_nil() && Group2->LineEdit3->text() == "")
Group2->PushButton3->click(); Group2->PushButton3->click();
} }
else if ( myEditCurrentArgument == Group2->LineEdit3 ) { else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
myVectorY = aSelectedObj; myVectorY = aSelectedObject;
myEditCurrentArgument->setText( aName ); if (myVectorY && !myPoint)
if (!myVectorX->_is_nil() && Group2->LineEdit1->text() == "")
Group2->PushButton1->click(); Group2->PushButton1->click();
} }
} }
} }
}
}
else { else {
if ( getConstructorId() == 1 ) { if ( getConstructorId() == 1 ) {
myShape = GEOM::GEOM_Object::_nil(); myShape.nullify();
} else if ( getConstructorId() == 2 ) { }
else if ( getConstructorId() == 2 ) {
if ( myEditCurrentArgument == Group2->LineEdit1 ) if ( myEditCurrentArgument == Group2->LineEdit1 )
myPoint = GEOM::GEOM_Object::_nil(); myPoint.nullify();
else if ( myEditCurrentArgument == Group2->LineEdit2 ) else if ( myEditCurrentArgument == Group2->LineEdit2 )
myVectorX = GEOM::GEOM_Object::_nil(); myVectorX.nullify();
else if ( myEditCurrentArgument == Group2->LineEdit3 ) else if ( myEditCurrentArgument == Group2->LineEdit3 )
myVectorY = GEOM::GEOM_Object::_nil(); myVectorY.nullify();
} }
} }
@ -538,18 +472,6 @@ void BasicGUI_MarkerDlg::SetEditCurrentArgument()
onSelectionDone(); onSelectionDone();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void BasicGUI_MarkerDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
//================================================================================= //=================================================================================
// function : onActivate() // function : onActivate()
// purpose : // purpose :
@ -597,31 +519,33 @@ GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
//================================================================================= //=================================================================================
bool BasicGUI_MarkerDlg::isValid( QString& msg ) bool BasicGUI_MarkerDlg::isValid( QString& msg )
{ {
const int id = getConstructorId(); bool ok = false;
switch ( id ) { switch ( getConstructorId() ) {
case 0: { case 0: {
gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ), gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ),
v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() ); v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
bool isOk = false;
// we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution() // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
// Vectors shouldn't be checked for being orthogonal here! // Vectors shouldn't be checked for being orthogonal here!
if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) { if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
isOk = !v1.IsParallel( v2, Precision::Angular() ); ok = !v1.IsParallel( v2, Precision::Angular() );
if ( !isOk ) if ( !ok )
msg += tr( "VEC_PARALLEL" ); msg += tr( "VEC_PARALLEL" );
} }
bool ok = true; for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end() && ok; ++anIter )
for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
ok = anIter.value()->isValid( msg, !IsPreview()) && ok; ok = anIter.value()->isValid( msg, !IsPreview()) && ok;
return isOk && ok; break;
} }
case 1: case 1:
return !myShape->_is_nil(); ok = myShape;
break;
case 2: case 2:
return !myPoint->_is_nil() && !myVectorX->_is_nil() && !myVectorY->_is_nil(); ok = myPoint && myVectorX && myVectorY;
break;
default:
break;
} }
return false; return ok;
} }
//================================================================================= //=================================================================================
@ -650,9 +574,9 @@ bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
aParameters<<myData[ DY2 ]->text(); aParameters<<myData[ DY2 ]->text();
aParameters<<myData[ DZ2 ]->text(); aParameters<<myData[ DZ2 ]->text();
} else if (id == 1) { } else if (id == 1) {
anObj = anOper->MakeMarkerFromShape( myShape ); anObj = anOper->MakeMarkerFromShape( myShape.get() );
} else if (id == 2) { } else if (id == 2) {
anObj = anOper->MakeMarkerPntTwoVec( myPoint, myVectorX, myVectorY ); anObj = anOper->MakeMarkerPntTwoVec( myPoint.get(), myVectorX.get(), myVectorY.get() );
} }
if ( !anObj->_is_nil() ) { if ( !anObj->_is_nil() ) {
@ -664,6 +588,29 @@ bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
return true; return true;
} }
//=================================================================================
// function : addSubshapeToStudy
// purpose : virtual method to add new SubObjects if local selection
//=================================================================================
void BasicGUI_MarkerDlg::addSubshapesToStudy()
{
switch ( getConstructorId() ) {
case 0 :
break;
case 1 :
GEOMBase::PublishSubObject( myShape.get() );
break;
case 2:
GEOMBase::PublishSubObject( myPoint.get() );
GEOMBase::PublishSubObject( myVectorX.get() );
GEOMBase::PublishSubObject( myVectorY.get() );
break;
default:
break;
}
}
//================================================================================= //=================================================================================
// function : onValueChanged // function : onValueChanged
// purpose : // purpose :

View File

@ -27,7 +27,8 @@
#ifndef BASICGUI_MARKERDLG_H #ifndef BASICGUI_MARKERDLG_H
#define BASICGUI_MARKERDLG_H #define BASICGUI_MARKERDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
#include <QMap> #include <QMap>
@ -57,15 +58,16 @@ protected:
const bool = true, const bool = true,
const bool = true, const bool = true,
const double = -1 ); const double = -1 );
virtual void addSubshapesToStudy();
private: private:
void enterEvent( QEvent* ); void enterEvent( QEvent* );
void onSelectionDone0(); void onSelectionDone0();
GEOM::GEOM_Object_var myShape; GEOM::GeomObjPtr myShape;
GEOM::GEOM_Object_var myPoint; GEOM::GeomObjPtr myPoint;
GEOM::GEOM_Object_var myVectorX; GEOM::GeomObjPtr myVectorX;
GEOM::GEOM_Object_var myVectorY; GEOM::GeomObjPtr myVectorY;
private slots: private slots:
void onOk(); void onOk();
@ -75,7 +77,6 @@ private slots:
void onSelectionDone(); void onSelectionDone();
void onValueChanged( double ); void onValueChanged( double );
void ConstructorsClicked( int ); void ConstructorsClicked( int );
void LineEditReturnPressed();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
private: private:

View File

@ -137,6 +137,7 @@ BasicGUI_PlaneDlg::BasicGUI_PlaneDlg( GeometryGUI* theGeometryGUI, QWidget* pare
GroupLCS->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) ); GroupLCS->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) );
GroupLCS->RadioButton2->setText( tr( "GEOM_WPLANE_OYZ" ) ); GroupLCS->RadioButton2->setText( tr( "GEOM_WPLANE_OYZ" ) );
GroupLCS->RadioButton3->setText( tr( "GEOM_WPLANE_OZX" ) ); GroupLCS->RadioButton3->setText( tr( "GEOM_WPLANE_OZX" ) );
GroupLCS->LineEdit1->setReadOnly( true );
GroupLCS->PushButton1->setIcon( image3 ); GroupLCS->PushButton1->setIcon( image3 );
GroupLCS->PushButton1->setDown( true ); GroupLCS->PushButton1->setDown( true );
@ -173,7 +174,15 @@ void BasicGUI_PlaneDlg::Init()
/* init variables */ /* init variables */
myEditCurrentArgument = GroupPntDir->LineEdit1; myEditCurrentArgument = GroupPntDir->LineEdit1;
myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil(); myPoint.nullify();
myDir.nullify();
myPoint1.nullify();
myPoint2.nullify();
myPoint3.nullify();
myFace.nullify();
myLCS.nullify();
myVec1.nullify();
myVec2.nullify();
// myGeomGUI->SetState( 0 ); // myGeomGUI->SetState( 0 );
myOriginType = 1; myOriginType = 1;
@ -218,15 +227,6 @@ void BasicGUI_PlaneDlg::Init()
connect( GroupLCS->RadioButton2, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) ); connect( GroupLCS->RadioButton2, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
connect( GroupLCS->RadioButton3, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) ); connect( GroupLCS->RadioButton3, SIGNAL( clicked() ), this, SLOT( GroupClicked() ) );
connect( GroupPntDir->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPntDir->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3Pnts->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3Pnts->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3Pnts->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupFace->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group2Vec->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group2Vec->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPntDir->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupPntDir->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( Group3Pnts->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( Group3Pnts->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupFace->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupFace->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
@ -262,7 +262,15 @@ void BasicGUI_PlaneDlg::SetDoubleSpinBoxStep( double step )
void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId ) void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId )
{ {
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil(); myPoint.nullify();
myDir.nullify();
myPoint1.nullify();
myPoint2.nullify();
myPoint3.nullify();
myFace.nullify();
myLCS.nullify();
myVec1.nullify();
myVec2.nullify();
switch ( constructorId ) { switch ( constructorId ) {
case 0: /* plane from a point and a direction (vector, edge...) */ case 0: /* plane from a point and a direction (vector, edge...) */
@ -428,115 +436,70 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument()
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1) {
if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil(); if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint.nullify();
else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir.nullify();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1.nullify();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2.nullify();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3.nullify();
else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace.nullify();
else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) myVec1 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) myVec1.nullify();
else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) myVec2 = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) myVec2.nullify();
else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) myLCS = GEOM::GEOM_Object::_nil(); else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) myLCS.nullify();
displayPreview(); displayPreview();
return; return;
} }
// nbSel == 1 TopAbs_ShapeEnum aNeedType;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( !CORBA::is_nil( aSelectedObject ) ) {
QString aName = GEOMBase::GetName( aSelectedObject );
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || myEditCurrentArgument == Group2Vec->LineEdit1 || myEditCurrentArgument == Group2Vec->LineEdit2) if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || myEditCurrentArgument == Group2Vec->LineEdit1 || myEditCurrentArgument == Group2Vec->LineEdit2)
aNeedType = TopAbs_EDGE; aNeedType = TopAbs_EDGE;
else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
aNeedType = TopAbs_FACE; aNeedType = TopAbs_FACE;
else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
aNeedType = TopAbs_FACE; aNeedType = TopAbs_FACE;
else
aNeedType = TopAbs_VERTEX;
GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
TColStd_IndexedMapOfInteger aMap; QString aName = GEOMBase::GetName( aSelectedObject.get() );
aSelMgr->GetIndexes(aSelList.First(), aMap);
if ( aMap.Extent() == 1 ) { // Local Selection
int anIndex = aMap( 1 );
if ( aNeedType == TopAbs_EDGE )
aName += QString( ":edge_%1" ).arg( anIndex );
else if (aNeedType == TopAbs_FACE)
aName += QString( ":face_%1" ).arg( anIndex );
else
aName += QString( ":vertex_%1" ).arg( anIndex );
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
if ( aFindedObject->_is_nil() ) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else { // Global Selection
if ( aShape.ShapeType() != aNeedType ) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
/* if (!aSelectedObject->_is_nil()) { // clear selection if something selected
globalSelection();
if ( myEditCurrentArgument == GroupFace->LineEdit1 ) {
TColStd_MapOfInteger aMap;
aMap.Add( GEOM_PLANE );
aMap.Add( GEOM_MARKER );
globalSelection( aMap );
}
else
localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
}*/
if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) { if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) {
myPoint = aSelectedObject; myPoint = aSelectedObject;
if ( !myPoint->_is_nil() && myDir->_is_nil() ) if ( myPoint && !myDir )
GroupPntDir->PushButton2->click(); GroupPntDir->PushButton2->click();
} }
else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) { else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
myDir = aSelectedObject; myDir = aSelectedObject;
if ( !myDir->_is_nil() && myPoint->_is_nil() ) if ( myDir && !myPoint )
GroupPntDir->PushButton1->click(); GroupPntDir->PushButton1->click();
} }
else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) { else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) if ( myPoint1 && !myPoint2 )
Group3Pnts->PushButton2->click(); Group3Pnts->PushButton2->click();
} }
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) { else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
if ( !myPoint2->_is_nil() && myPoint3->_is_nil() ) if ( myPoint2 && !myPoint3 )
Group3Pnts->PushButton3->click(); Group3Pnts->PushButton3->click();
} }
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) { else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
myPoint3 = aSelectedObject; myPoint3 = aSelectedObject;
if ( !myPoint3->_is_nil() && myPoint1->_is_nil() ) if ( myPoint3 && !myPoint1 )
Group3Pnts->PushButton1->click(); Group3Pnts->PushButton1->click();
} }
else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
myFace = aSelectedObject; myFace = aSelectedObject;
else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) { else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) {
myVec1 = aSelectedObject; myVec1 = aSelectedObject;
if ( !myVec1->_is_nil() && myVec2->_is_nil() ) if ( myVec1 && !myVec2 )
Group2Vec->PushButton2->click(); Group2Vec->PushButton2->click();
} else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) { } else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) {
myVec2 = aSelectedObject; myVec2 = aSelectedObject;
if ( !myVec2->_is_nil() && myVec1->_is_nil() ) if ( myVec2 && !myVec1 )
Group2Vec->PushButton1->click(); Group2Vec->PushButton1->click();
} else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) } else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
myLCS = aSelectedObject; myLCS = aSelectedObject;
} }
displayPreview(); displayPreview();
@ -631,28 +594,6 @@ void BasicGUI_PlaneDlg::SetEditCurrentArgument()
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void BasicGUI_PlaneDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPntDir->LineEdit1 ||
send == GroupPntDir->LineEdit2 ||
send == Group3Pnts->LineEdit1 ||
send == Group3Pnts->LineEdit2 ||
send == Group3Pnts->LineEdit3 ||
send == GroupFace->LineEdit1 ||
send == Group2Vec->LineEdit1 ||
send == Group2Vec->LineEdit2 ||
send == GroupLCS->LineEdit1 ) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -736,48 +677,42 @@ GEOM::GEOM_IOperations_ptr BasicGUI_PlaneDlg::createOperation()
return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() ); return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
} }
//=================================================================================
// function : isEqual
// purpose : it may also be needed to check for min distance between gp_Pnt-s...
//=================================================================================
static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
{
return thePnt1->_is_equivalent( thePnt2 );
}
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool BasicGUI_PlaneDlg::isValid( QString& msg ) bool BasicGUI_PlaneDlg::isValid( QString& msg )
{ {
const int id = getConstructorId(); bool ok = false;
if ( getSize() <= 0 ) { if ( getSize() <= 0 ) {
msg = QString( "Please, enter size greater than 0." ); msg = QString( "Please, enter size greater than 0." );
return false;
} }
else {
if ( id == 0 ) { switch ( getConstructorId() ) {
bool ok = GroupPntDir->SpinBox_DX->isValid( msg, !IsPreview() ); case 0:
return !CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir ) && ok; ok = GroupPntDir->SpinBox_DX->isValid( msg, !IsPreview() ) && myPoint && myDir;
break;
case 1:
ok = Group3Pnts->SpinBox_DX->isValid( msg, !IsPreview() ) &&
myPoint1 && myPoint2 && myPoint3 &&
myPoint1 != myPoint2 && myPoint1 != myPoint3 && myPoint2 != myPoint3;
break;
case 2:
ok = GroupFace->SpinBox_DX->isValid( msg, !IsPreview() ) && myFace;
break;
case 3:
ok = Group2Vec->SpinBox_DX->isValid( msg, !IsPreview() ) &&
myVec1 && myVec2 && myVec1 != myVec2;
break;
case 4:
ok = GroupLCS->SpinBox_DX->isValid( msg, !IsPreview() );
break;
default:
break;
} }
else if ( id == 1 ) {
bool ok = Group3Pnts->SpinBox_DX->isValid( msg, !IsPreview() );
return !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) &&
!isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ) && ok;
} }
else if ( id == 2 ) {
bool ok = GroupFace->SpinBox_DX->isValid( msg, !IsPreview() );
return !CORBA::is_nil( myFace ) && ok;
} else if ( id == 3 ) {
bool ok = Group2Vec->SpinBox_DX->isValid( msg, !IsPreview() );
return !CORBA::is_nil( myVec1 ) && !CORBA::is_nil( myVec2 ) && !isEqual( myVec1, myVec2 ) && ok;
} else if ( id == 4 ) {
bool ok = GroupLCS->SpinBox_DX->isValid( msg, !IsPreview() );
return ok; return ok;
} }
return false;
}
//================================================================================= //=================================================================================
// function : execute // function : execute
@ -793,23 +728,23 @@ bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0 : case 0 :
anObj = anOper->MakePlanePntVec( myPoint, myDir, getSize() ); anObj = anOper->MakePlanePntVec( myPoint.get(), myDir.get(), getSize() );
res = true; res = true;
break; break;
case 1 : case 1 :
anObj = anOper->MakePlaneThreePnt( myPoint1, myPoint2, myPoint3, getSize() ); anObj = anOper->MakePlaneThreePnt( myPoint1.get(), myPoint2.get(), myPoint3.get(), getSize() );
res = true; res = true;
break; break;
case 2 : case 2 :
anObj = anOper->MakePlaneFace( myFace, getSize() ); anObj = anOper->MakePlaneFace( myFace.get(), getSize() );
res = true; res = true;
break; break;
case 3 : case 3 :
anObj = anOper->MakePlane2Vec( myVec1, myVec2, getSize() ); anObj = anOper->MakePlane2Vec( myVec1.get(), myVec2.get(), getSize() );
res = true; res = true;
break; break;
case 4 : case 4 :
anObj = anOper->MakePlaneLCS( myLCS, getSize(), myOriginType ); anObj = anOper->MakePlaneLCS( myLCS.get(), getSize(), myOriginType );
res = true; res = true;
break; break;
} }
@ -827,25 +762,27 @@ bool BasicGUI_PlaneDlg::execute( ObjectList& objects )
//================================================================================= //=================================================================================
void BasicGUI_PlaneDlg::addSubshapesToStudy() void BasicGUI_PlaneDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0: case 0:
objMap[GroupPntDir->LineEdit1->text()] = myPoint; GEOMBase::PublishSubObject( myPoint.get() );
objMap[GroupPntDir->LineEdit2->text()] = myDir; GEOMBase::PublishSubObject( myDir.get() );
break; break;
case 1: case 1:
objMap[Group3Pnts->LineEdit1->text()] = myPoint1; GEOMBase::PublishSubObject( myPoint1.get() );
objMap[Group3Pnts->LineEdit2->text()] = myPoint2; GEOMBase::PublishSubObject( myPoint2.get() );
objMap[Group3Pnts->LineEdit3->text()] = myPoint3; GEOMBase::PublishSubObject( myPoint3.get() );
break; break;
case 2: case 2:
objMap[GroupFace->LineEdit1->text()] = myFace; GEOMBase::PublishSubObject( myFace.get() );
break; break;
case 3: case 3:
objMap[Group2Vec->LineEdit1->text()] = myVec1; GEOMBase::PublishSubObject( myVec1.get() );
objMap[Group2Vec->LineEdit2->text()] = myVec2; GEOMBase::PublishSubObject( myVec2.get() );
break;
case 4:
GEOMBase::PublishSubObject( myLCS.get() );
break;
default:
break; break;
} }
addSubshapesToFather( objMap );
} }

View File

@ -27,7 +27,8 @@
#ifndef BASICGUI_PLANEDLG_H #ifndef BASICGUI_PLANEDLG_H
#define BASICGUI_PLANEDLG_H #define BASICGUI_PLANEDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel1Spin; class DlgRef_1Sel1Spin;
class DlgRef_2Sel1Spin; class DlgRef_2Sel1Spin;
@ -61,7 +62,7 @@ private:
int myOriginType; int myOriginType;
private: private:
GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3, myFace, myVec1, myVec2, myLCS; GEOM::GeomObjPtr myPoint, myDir, myPoint1, myPoint2, myPoint3, myFace, myVec1, myVec2, myLCS;
DlgRef_2Sel1Spin* GroupPntDir; DlgRef_2Sel1Spin* GroupPntDir;
DlgRef_3Sel1Spin* Group3Pnts; DlgRef_3Sel1Spin* Group3Pnts;
@ -77,7 +78,6 @@ private slots:
void DeactivateActiveDialog(); void DeactivateActiveDialog();
void SelectionIntoArgument(); void SelectionIntoArgument();
void LineEditReturnPressed();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ConstructorsClicked( int ); void ConstructorsClicked( int );
void ValueChangedInSpinBox( double ); void ValueChangedInSpinBox( double );

View File

@ -68,6 +68,8 @@
#define SPACING 6 #define SPACING 6
#define MARGIN 9 #define MARGIN 9
enum { SelectEdge, SelectWire };
//================================================================================= //=================================================================================
// class : BasicGUI_PointDlg() // class : BasicGUI_PointDlg()
// purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the // purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the
@ -150,8 +152,8 @@ BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* pare
myBtnPopup = new QMenu(this); myBtnPopup = new QMenu(this);
QIcon ico_line = QIcon( image6 ); QIcon ico_line = QIcon( image6 );
QIcon ico_wire = QIcon( image7 ); QIcon ico_wire = QIcon( image7 );
myActions[myBtnPopup->addAction( ico_line, tr( "GEOM_EDGE" ) )] = 0; myActions[myBtnPopup->addAction( ico_line, tr( "GEOM_EDGE" ) )] = SelectEdge;
myActions[myBtnPopup->addAction( ico_wire, tr( "GEOM_WIRE" ) )] = 1; myActions[myBtnPopup->addAction( ico_wire, tr( "GEOM_WIRE" ) )] = SelectWire;
GroupLineIntersection = new DlgRef_2Sel( centralWidget() ); GroupLineIntersection = new DlgRef_2Sel( centralWidget() );
GroupLineIntersection->GroupBox1->setTitle( tr( "GEOM_LINE_INTERSECTION" ) ); GroupLineIntersection->GroupBox1->setTitle( tr( "GEOM_LINE_INTERSECTION" ) );
@ -228,8 +230,11 @@ void BasicGUI_PointDlg::Init()
GroupLineIntersection->LineEdit1->setEnabled( true ); GroupLineIntersection->LineEdit1->setEnabled( true );
GroupLineIntersection->LineEdit2->setEnabled( false ); GroupLineIntersection->LineEdit2->setEnabled( false );
myEdge = GEOM::GEOM_Object::_nil(); myEdge.nullify();
myRefPoint = GEOM::GEOM_Object::_nil(); myFace.nullify();
myRefPoint.nullify();
myLine1.nullify();
myLine2.nullify();
myNeedType = TopAbs_VERTEX; myNeedType = TopAbs_VERTEX;
myEditCurrentArgument = 0; myEditCurrentArgument = 0;
@ -273,17 +278,13 @@ void BasicGUI_PointDlg::Init()
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
connect( myParamCoord, SIGNAL( buttonClicked( int ) ), this, SLOT( ClickParamCoord( int ) ) ); connect( myParamCoord, SIGNAL( buttonClicked( int ) ), this, SLOT( ClickParamCoord( int ) ) );
connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupOnCurve->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupOnSurface->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupOnSurface->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupOnSurface->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( myBtnPopup, SIGNAL( triggered( QAction* ) ), SLOT( onBtnPopup( QAction* ) ) );
connect( GroupLineIntersection->PushButton1, SIGNAL( pressed() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupLineIntersection->PushButton1, SIGNAL( pressed() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupLineIntersection->PushButton2, SIGNAL( pressed() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupLineIntersection->PushButton2, SIGNAL( pressed() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupLineIntersection->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupLineIntersection->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( myBtnPopup, SIGNAL( triggered( QAction* ) ), this, SLOT( onBtnPopup( QAction* ) ) );
connect( GroupOnCurve->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupOnCurve->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupOnSurface->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupOnSurface->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
@ -333,7 +334,8 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
case GEOM_POINT_XYZ: case GEOM_POINT_XYZ:
{ {
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); myNeedType = TopAbs_VERTEX;
localSelection( GEOM::GEOM_Object::_nil(), myNeedType );
GroupRefPoint->hide(); GroupRefPoint->hide();
GroupOnCurve->hide(); GroupOnCurve->hide();
@ -347,11 +349,12 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
case GEOM_POINT_REF: case GEOM_POINT_REF:
{ {
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); myNeedType = TopAbs_VERTEX;
localSelection( GEOM::GEOM_Object::_nil(), myNeedType );
myEditCurrentArgument = GroupRefPoint->LineEdit1; myEditCurrentArgument = GroupRefPoint->LineEdit1;
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
myRefPoint = GEOM::GEOM_Object::_nil(); myRefPoint.nullify();
GroupRefPoint->PushButton1->setDown(true); GroupRefPoint->PushButton1->setDown(true);
myParamGroup->hide(); myParamGroup->hide();
GroupXYZ->hide(); GroupXYZ->hide();
@ -365,11 +368,12 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
case GEOM_POINT_EDGE: case GEOM_POINT_EDGE:
{ {
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); myNeedType = TopAbs_EDGE;
localSelection( GEOM::GEOM_Object::_nil(), myNeedType );
myEditCurrentArgument = GroupOnCurve->LineEdit1; myEditCurrentArgument = GroupOnCurve->LineEdit1;
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
myEdge = GEOM::GEOM_Object::_nil(); myEdge.nullify();
GroupOnCurve->PushButton1->setDown(true); GroupOnCurve->PushButton1->setDown(true);
GroupRefPoint->hide(); GroupRefPoint->hide();
GroupLineIntersection->hide(); GroupLineIntersection->hide();
@ -385,16 +389,16 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
case GEOM_POINT_INTINT: case GEOM_POINT_INTINT:
{ {
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
myNeedType = TopAbs_EDGE; myNeedType = TopAbs_EDGE;
localSelection( GEOM::GEOM_Object::_nil(), myNeedType );
myEditCurrentArgument = GroupLineIntersection->LineEdit1; myEditCurrentArgument = GroupLineIntersection->LineEdit1;
GroupLineIntersection->LineEdit1->setText( "" ); GroupLineIntersection->LineEdit1->setText( "" );
GroupLineIntersection->LineEdit2->setText( "" ); GroupLineIntersection->LineEdit2->setText( "" );
GroupLineIntersection->LineEdit1->setEnabled( true ); GroupLineIntersection->LineEdit1->setEnabled( true );
GroupLineIntersection->LineEdit2->setEnabled( false ); GroupLineIntersection->LineEdit2->setEnabled( false );
myLine1 = GEOM::GEOM_Object::_nil(); myLine1.nullify();
myLine2 = GEOM::GEOM_Object::_nil(); myLine2.nullify();
GroupLineIntersection->PushButton1->setDown(true); GroupLineIntersection->PushButton1->setDown(true);
GroupLineIntersection->PushButton2->setDown(false); GroupLineIntersection->PushButton2->setDown(false);
myParamGroup->hide(); myParamGroup->hide();
@ -409,11 +413,12 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
case GEOM_POINT_SURF: case GEOM_POINT_SURF:
{ {
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); myNeedType = TopAbs_FACE;
localSelection( GEOM::GEOM_Object::_nil(), myNeedType );
myEditCurrentArgument = GroupOnSurface->LineEdit1; myEditCurrentArgument = GroupOnSurface->LineEdit1;
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
myFace = GEOM::GEOM_Object::_nil(); myFace.nullify();
GroupOnSurface->PushButton1->setDown(true); GroupOnSurface->PushButton1->setDown(true);
GroupRefPoint->hide(); GroupRefPoint->hide();
GroupOnCurve->hide(); GroupOnCurve->hide();
@ -479,72 +484,22 @@ void BasicGUI_PointDlg::SelectionIntoArgument()
myX->setText( "" ); myX->setText( "" );
myY->setText( "" ); myY->setText( "" );
myZ->setText( "" ); myZ->setText( "" );
myRefPoint = myEdge = myFace = GEOM::GEOM_Object::_nil(); myRefPoint.nullify();
myEdge.nullify();
myFace.nullify();
} else if ( id == GEOM_POINT_INTINT ) { } else if ( id == GEOM_POINT_INTINT ) {
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 )
myLine1 = GEOM::GEOM_Object::_nil(); myLine1.nullify();
else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 )
myLine2 = GEOM::GEOM_Object::_nil(); myLine2.nullify();
} }
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); GEOM::GeomObjPtr aSelectedObject = getSelected( myNeedType );
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() == 1) {
Handle(SALOME_InteractiveObject) anIO = aSelList.First();
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO );
if ( !CORBA::is_nil( aSelectedObject ) ) {
QString aName = GEOMBase::GetName(aSelectedObject);
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
if ( id == GEOM_POINT_XYZ || id == GEOM_POINT_REF) QString aName = GEOMBase::GetName( aSelectedObject.get() );
myNeedType = TopAbs_VERTEX;
else if ( id == GEOM_POINT_EDGE )
myNeedType = TopAbs_EDGE;
else if ( id == GEOM_POINT_SURF )
myNeedType = TopAbs_FACE;
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(anIO, aMap);
if ( aMap.Extent() == 1 ) { // Local Selection
int anIndex = aMap( 1 );
if ( myNeedType == TopAbs_FACE )
aName += QString( ":face_%1" ).arg( anIndex );
else if ( myNeedType == TopAbs_WIRE )
aName += QString( ":wire_%1" ).arg( anIndex );
else if ( myNeedType == TopAbs_EDGE )
aName += QString( ":edge_%1" ).arg( anIndex );
else if ( myNeedType == TopAbs_VERTEX )
aName += QString( ":vertex_%1" ).arg( anIndex );
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if ( aFindedObject->_is_nil() ) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp =
getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE );
}
else { // Global Selection
if ( aShape.ShapeType() != myNeedType ) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
if ( id == GEOM_POINT_XYZ ) return;
}
}
}
if ( aShape.IsNull() || aShape.ShapeType() != myNeedType)
return;
myBusy = true; myBusy = true;
if ( id == GEOM_POINT_XYZ ) { if ( id == GEOM_POINT_XYZ ) {
gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
GroupXYZ->SpinBox_DX->setValue( aPnt.X() ); GroupXYZ->SpinBox_DX->setValue( aPnt.X() );
@ -563,7 +518,7 @@ void BasicGUI_PointDlg::SelectionIntoArgument()
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) { if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) {
myLine1 = aSelectedObject; myLine1 = aSelectedObject;
if ( !myLine1->_is_nil() && myLine2->_is_nil() ) { if ( myLine1 && !myLine2 ) {
GroupLineIntersection->PushButton2->setMenu( 0 ); GroupLineIntersection->PushButton2->setMenu( 0 );
GroupLineIntersection->PushButton2->click(); GroupLineIntersection->PushButton2->click();
GroupLineIntersection->PushButton2->setDown(true); GroupLineIntersection->PushButton2->setDown(true);
@ -572,7 +527,7 @@ void BasicGUI_PointDlg::SelectionIntoArgument()
} }
else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) { else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) {
myLine2 = aSelectedObject; myLine2 = aSelectedObject;
if ( !myLine2->_is_nil() && myLine1->_is_nil() ) { if ( myLine2 && !myLine1 ) {
GroupLineIntersection->PushButton1->setMenu( 0 ); GroupLineIntersection->PushButton1->setMenu( 0 );
GroupLineIntersection->PushButton1->click(); GroupLineIntersection->PushButton1->click();
GroupLineIntersection->PushButton1->setDown(true); GroupLineIntersection->PushButton1->setDown(true);
@ -580,36 +535,17 @@ void BasicGUI_PointDlg::SelectionIntoArgument()
} }
} }
} }
else if ( id == GEOM_POINT_SURF ) else if ( id == GEOM_POINT_SURF ) {
{
myFace = aSelectedObject; myFace = aSelectedObject;
GroupOnSurface->LineEdit1->setText( aName ); GroupOnSurface->LineEdit1->setText( aName );
} }
myBusy = false; myBusy = false;
} }
}
displayPreview(); displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void BasicGUI_PointDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupRefPoint->LineEdit1 ||
send == GroupOnCurve->LineEdit1 ||
send == GroupLineIntersection->LineEdit1 ||
send == GroupLineIntersection->LineEdit2 ) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -775,49 +711,45 @@ GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation()
//================================================================================= //=================================================================================
bool BasicGUI_PointDlg::isValid( QString& msg ) bool BasicGUI_PointDlg::isValid( QString& msg )
{ {
const int id = getConstructorId(); bool ok = false;
if ( id == GEOM_POINT_XYZ ) { switch ( getConstructorId() ) {
bool ok = true; case GEOM_POINT_XYZ :
ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) &&
ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) &&
ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() );
return ok; break;
} case GEOM_POINT_REF:
else if ( id == GEOM_POINT_REF ) { ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) &&
bool ok = true; GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) &&
ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; GroupRefPoint->SpinBox_DZ->isValid( msg, !IsPreview() ) &&
ok = GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; myRefPoint;
ok = GroupRefPoint->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; break;
case GEOM_POINT_EDGE:
return !myRefPoint->_is_nil() && ok;
}
else if ( id == GEOM_POINT_EDGE ) {
bool ok = true;
if ( myParamCoord->checkedId() == PARAM_VALUE || myParamCoord->checkedId() == LENGTH_VALUE ) if ( myParamCoord->checkedId() == PARAM_VALUE || myParamCoord->checkedId() == LENGTH_VALUE )
ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() ); ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
else { else
ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) &&
ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) &&
ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() );
ok = myEdge && ok;
break;
case GEOM_POINT_INTINT:
ok = myLine1 && myLine2;
break;
case GEOM_POINT_SURF:
if ( myParamCoord->checkedId() == PARAM_VALUE )
ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) &&
GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() );
else
ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) &&
GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) &&
GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() );
ok = myFace && ok;
break;
default:
break;
} }
return !myEdge->_is_nil() && ok; return ok;
}
else if ( id == GEOM_POINT_INTINT )
return ( !myLine1->_is_nil() && !myLine2->_is_nil() );
else if ( id == GEOM_POINT_SURF ) {
bool ok = true;
if ( myParamCoord->checkedId() == PARAM_VALUE ) {
ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
ok = GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
}
else {
ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
}
return !myFace->_is_nil() && ok;
}
return false;
} }
//================================================================================= //=================================================================================
@ -858,19 +790,19 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects )
aParameters << GroupRefPoint->SpinBox_DY->text(); aParameters << GroupRefPoint->SpinBox_DY->text();
aParameters << GroupRefPoint->SpinBox_DZ->text(); aParameters << GroupRefPoint->SpinBox_DZ->text();
anObj = anOper->MakePointWithReference( myRefPoint, dx, dy, dz ); anObj = anOper->MakePointWithReference( myRefPoint.get(), dx, dy, dz );
res = true; res = true;
break; break;
} }
case GEOM_POINT_EDGE : case GEOM_POINT_EDGE :
{ {
if ( myParamCoord->checkedId() == PARAM_VALUE ) { if ( myParamCoord->checkedId() == PARAM_VALUE ) {
anObj = anOper->MakePointOnCurve( myEdge, getParameter() ); anObj = anOper->MakePointOnCurve( myEdge.get(), getParameter() );
aParameters<<GroupOnCurve->SpinBox_DX->text(); aParameters<<GroupOnCurve->SpinBox_DX->text();
} }
else if ( myParamCoord->checkedId() == LENGTH_VALUE ) { else if ( myParamCoord->checkedId() == LENGTH_VALUE ) {
bool reversed = GroupOnCurve->CheckButton1->isChecked(); bool reversed = GroupOnCurve->CheckButton1->isChecked();
anObj = anOper->MakePointOnCurveByLength( myEdge, getParameter(), reversed ); anObj = anOper->MakePointOnCurveByLength( myEdge.get(), getParameter(), reversed );
aParameters<<GroupOnCurve->SpinBox_DX->text(); aParameters<<GroupOnCurve->SpinBox_DX->text();
aParameters<<QString::number( reversed ); aParameters<<QString::number( reversed );
@ -884,13 +816,13 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects )
aParameters << GroupXYZ->SpinBox_DY->text(); aParameters << GroupXYZ->SpinBox_DY->text();
aParameters << GroupXYZ->SpinBox_DZ->text(); aParameters << GroupXYZ->SpinBox_DZ->text();
anObj = anOper->MakePointOnCurveByCoord( myEdge, x, y, z ); anObj = anOper->MakePointOnCurveByCoord( myEdge.get(), x, y, z );
} }
res = true; res = true;
break; break;
} }
case GEOM_POINT_INTINT : case GEOM_POINT_INTINT :
anObj = anOper->MakePointOnLinesIntersection( myLine1, myLine2 ); anObj = anOper->MakePointOnLinesIntersection( myLine1.get(), myLine2.get() );
if ( !anObj->_is_nil() ) { if ( !anObj->_is_nil() ) {
QString aName = getNewObjectName(); QString aName = getNewObjectName();
if ( anObj->GetShapeType() == GEOM::COMPOUND && aName.startsWith("Vertex") ) if ( anObj->GetShapeType() == GEOM::COMPOUND && aName.startsWith("Vertex") )
@ -903,7 +835,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects )
case GEOM_POINT_SURF : case GEOM_POINT_SURF :
{ {
if ( myParamCoord->checkedId() == PARAM_VALUE ) { if ( myParamCoord->checkedId() == PARAM_VALUE ) {
anObj = anOper->MakePointOnSurface( myFace, getUParameter(), getVParameter() ); anObj = anOper->MakePointOnSurface( myFace.get(), getUParameter(), getVParameter() );
aParameters<<GroupOnSurface->SpinBox_DX->text(); aParameters<<GroupOnSurface->SpinBox_DX->text();
aParameters<<GroupOnSurface->SpinBox_DY->text(); aParameters<<GroupOnSurface->SpinBox_DY->text();
} else { } else {
@ -915,7 +847,7 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects )
aParameters << GroupXYZ->SpinBox_DY->text(); aParameters << GroupXYZ->SpinBox_DY->text();
aParameters << GroupXYZ->SpinBox_DZ->text(); aParameters << GroupXYZ->SpinBox_DZ->text();
anObj = anOper->MakePointOnSurfaceByCoord( myFace, x, y, z ); anObj = anOper->MakePointOnSurfaceByCoord( myFace.get(), x, y, z );
} }
res = true; res = true;
break; break;
@ -961,26 +893,23 @@ bool BasicGUI_PointDlg::execute( ObjectList& objects )
//================================================================================= //=================================================================================
void BasicGUI_PointDlg::addSubshapesToStudy() void BasicGUI_PointDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case GEOM_POINT_XYZ:
break;
case GEOM_POINT_REF: case GEOM_POINT_REF:
objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint; GEOMBase::PublishSubObject( myRefPoint.get() );
break; break;
case GEOM_POINT_EDGE: case GEOM_POINT_EDGE:
objMap[GroupOnCurve->LineEdit1->text()] = myEdge; GEOMBase::PublishSubObject( myEdge.get() );
break; break;
case GEOM_POINT_INTINT: case GEOM_POINT_INTINT:
objMap[GroupLineIntersection->LineEdit1->text()] = myLine1; GEOMBase::PublishSubObject( myLine1.get() );
objMap[GroupLineIntersection->LineEdit2->text()] = myLine2; GEOMBase::PublishSubObject( myLine2.get() );
break; break;
case GEOM_POINT_SURF: case GEOM_POINT_SURF:
objMap[GroupOnSurface->LineEdit1->text()] = myFace; GEOMBase::PublishSubObject( myFace.get() );
break;
default:
break; break;
} }
addSubshapesToFather( objMap );
} }
//================================================================================= //=================================================================================
@ -1041,14 +970,8 @@ void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
//================================================================================= //=================================================================================
void BasicGUI_PointDlg::onBtnPopup( QAction* a ) void BasicGUI_PointDlg::onBtnPopup( QAction* a )
{ {
int index = myActions[a];
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
QString type; myNeedType = myActions[a] == SelectEdge ? TopAbs_EDGE : TopAbs_WIRE;
if ( index == 0 )
myNeedType = TopAbs_EDGE;
else
myNeedType = TopAbs_WIRE;
localSelection( GEOM::GEOM_Object::_nil(), myNeedType ); localSelection( GEOM::GEOM_Object::_nil(), myNeedType );
} }

View File

@ -27,7 +27,8 @@
#ifndef BASICGUI_POINTDLG_H #ifndef BASICGUI_POINTDLG_H
#define BASICGUI_POINTDLG_H #define BASICGUI_POINTDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
#include <QMap> #include <QMap>
class DlgRef_1Sel1Spin1Check; class DlgRef_1Sel1Spin1Check;
@ -76,11 +77,11 @@ private:
void updateParamCoord(bool theIsUpdate); void updateParamCoord(bool theIsUpdate);
private: private:
GEOM::GEOM_Object_var myEdge; GEOM::GeomObjPtr myEdge;
GEOM::GEOM_Object_var myFace; GEOM::GeomObjPtr myFace;
GEOM::GEOM_Object_var myRefPoint; GEOM::GeomObjPtr myRefPoint;
GEOM::GEOM_Object_var myLine1; GEOM::GeomObjPtr myLine1;
GEOM::GEOM_Object_var myLine2; GEOM::GeomObjPtr myLine2;
bool myBusy; bool myBusy;
@ -108,7 +109,6 @@ private slots:
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void DeactivateActiveDialog(); void DeactivateActiveDialog();
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ConstructorsClicked( int ); void ConstructorsClicked( int );

View File

@ -119,8 +119,8 @@ void BasicGUI_VectorDlg::Init()
/* init variables */ /* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
myPoint1 = GEOM::GEOM_Object::_nil(); myPoint1.nullify();
myPoint2 = GEOM::GEOM_Object::_nil(); myPoint2.nullify();
/* Get setting of step value from file configuration */ /* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
@ -150,9 +150,6 @@ void BasicGUI_VectorDlg::Init()
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupDimensions->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupDimensions->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupDimensions->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupDimensions->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupDimensions->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupDimensions->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
@ -189,8 +186,8 @@ void BasicGUI_VectorDlg::SetDoubleSpinBoxStep( double step )
void BasicGUI_VectorDlg::ConstructorsClicked( int constructorId ) void BasicGUI_VectorDlg::ConstructorsClicked( int constructorId )
{ {
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
myPoint1 = GEOM::GEOM_Object::_nil(); myPoint1.nullify();
myPoint2 = GEOM::GEOM_Object::_nil(); myPoint2.nullify();
switch ( constructorId ) { switch ( constructorId ) {
case 0: case 0:
@ -279,59 +276,25 @@ void BasicGUI_VectorDlg::SelectionIntoArgument()
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPoints->LineEdit1) if (myEditCurrentArgument == GroupPoints->LineEdit1)
myPoint1 = GEOM::GEOM_Object::_nil(); myPoint1.nullify();
else if (myEditCurrentArgument == GroupPoints->LineEdit2) else if (myEditCurrentArgument == GroupPoints->LineEdit2)
myPoint2 = GEOM::GEOM_Object::_nil(); myPoint2.nullify();
return; return;
} }
// nbSel == 1 GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX );
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if (!CORBA::is_nil(aSelectedObject) ) {
QString aName = GEOMBase::GetName(aSelectedObject);
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) { if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
TColStd_IndexedMapOfInteger aMap; QString aName = GEOMBase::GetName( aSelectedObject.get() );
aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) { // Local Selection
int anIndex = aMap(1);
aName += QString(":vertex_%1").arg(anIndex);
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if (aFindedObject->_is_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else { // Global Selection
if (aShape.ShapeType() != TopAbs_VERTEX) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
if (!aSelectedObject->_is_nil()) { // clear selection if something selected
globalSelection();
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
}
if (myEditCurrentArgument == GroupPoints->LineEdit1) { if (myEditCurrentArgument == GroupPoints->LineEdit1) {
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
if (!myPoint1->_is_nil() && myPoint2->_is_nil()) if (myPoint1 && !myPoint2)
GroupPoints->PushButton2->click(); GroupPoints->PushButton2->click();
} }
else if (myEditCurrentArgument == GroupPoints->LineEdit2) { else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
if (!myPoint2->_is_nil() && myPoint1->_is_nil()) if (myPoint2 && !myPoint1)
GroupPoints->PushButton1->click(); GroupPoints->PushButton1->click();
} }
} }
@ -367,20 +330,6 @@ void BasicGUI_VectorDlg::SetEditCurrentArgument()
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void BasicGUI_VectorDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 ) myEditCurrentArgument = GroupPoints->LineEdit1;
else if ( send == GroupPoints->LineEdit2 ) myEditCurrentArgument = GroupPoints->LineEdit2;
else return;
GEOMBase_Skeleton::LineEditReturnPressed();
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -454,17 +403,16 @@ GEOM::GEOM_IOperations_ptr BasicGUI_VectorDlg::createOperation()
//================================================================================= //=================================================================================
bool BasicGUI_VectorDlg::isValid( QString& msg ) bool BasicGUI_VectorDlg::isValid( QString& msg )
{ {
bool ok = false;
if(getConstructorId() == 0) if(getConstructorId() == 0)
return !myPoint1->_is_nil() && !myPoint2->_is_nil(); ok = myPoint1 && myPoint2;
else if(getConstructorId() == 1) else if(getConstructorId() == 1)
{ {
bool ok = true; ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) &&
ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() );
ok = GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
return ok;
} }
return false; return ok;
} }
//================================================================================= //=================================================================================
@ -482,7 +430,7 @@ bool BasicGUI_VectorDlg::execute( ObjectList& objects )
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0 : case 0 :
{ {
anObj = anOper->MakeVectorTwoPnt( myPoint1, myPoint2 ); anObj = anOper->MakeVectorTwoPnt( myPoint1.get(), myPoint2.get() );
res = true; res = true;
break; break;
} }
@ -518,15 +466,8 @@ bool BasicGUI_VectorDlg::execute( ObjectList& objects )
//================================================================================= //=================================================================================
void BasicGUI_VectorDlg::addSubshapesToStudy() void BasicGUI_VectorDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap; if ( getConstructorId() == 0 ) {
GEOMBase::PublishSubObject( myPoint1.get() );
switch ( getConstructorId() ) { GEOMBase::PublishSubObject( myPoint2.get() );
case 0:
objMap[GroupPoints->LineEdit1->text()] = myPoint1;
objMap[GroupPoints->LineEdit2->text()] = myPoint2;
break;
case 1:
return;
} }
addSubshapesToFather( objMap );
} }

View File

@ -27,7 +27,8 @@
#ifndef BASICGUI_VECTORDLG_H #ifndef BASICGUI_VECTORDLG_H
#define BASICGUI_VECTORDLG_H #define BASICGUI_VECTORDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel; class DlgRef_2Sel;
class DlgRef_3Spin1Check; class DlgRef_3Spin1Check;
@ -55,8 +56,8 @@ private:
void Init(); void Init();
void enterEvent( QEvent* ); void enterEvent( QEvent* );
GEOM::GEOM_Object_var myPoint1; GEOM::GeomObjPtr myPoint1;
GEOM::GEOM_Object_var myPoint2; GEOM::GeomObjPtr myPoint2;
DlgRef_2Sel* GroupPoints; DlgRef_2Sel* GroupPoints;
DlgRef_3Spin1Check* GroupDimensions; DlgRef_3Spin1Check* GroupDimensions;
@ -68,7 +69,6 @@ private slots:
void ActivateThisDialog(); void ActivateThisDialog();
void DeactivateActiveDialog(); void DeactivateActiveDialog();
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ConstructorsClicked( int ); void ConstructorsClicked( int );

View File

@ -160,8 +160,12 @@ void BlocksGUI_BlockDlg::ConstructorsClicked (int constructorId)
myConstructorId = constructorId; myConstructorId = constructorId;
// init fields // init fields
myFace1 = myFace2 = GEOM::GEOM_Object::_nil(); myFace1.nullify();
myFace3 = myFace4 = myFace5 = myFace6 = myFace1; myFace2.nullify();
myFace3.nullify();
myFace4.nullify();
myFace5.nullify();
myFace6.nullify();
switch (constructorId) { switch (constructorId) {
case 0: case 0:
@ -228,104 +232,79 @@ bool BlocksGUI_BlockDlg::ClickOnApply()
void BlocksGUI_BlockDlg::SelectionIntoArgument() void BlocksGUI_BlockDlg::SelectionIntoArgument()
{ {
erasePreview(); erasePreview();
myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_FACE );
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == Group2F->LineEdit1) myFace1 = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == Group2F->LineEdit2) myFace2 = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == Group6F->LineEdit1) myFace1 = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == Group6F->LineEdit2) myFace2 = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == Group6F->LineEdit3) myFace3 = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == Group6F->LineEdit4) myFace4 = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == Group6F->LineEdit5) myFace5 = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == Group6F->LineEdit6) myFace6 = GEOM::GEOM_Object::_nil();
return;
}
// nbSel == 1
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( CORBA::is_nil(aSelectedObject) )
return;
QString aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
{ QString aName = GEOMBase::GetName( aSelectedObject.get() );
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) // Local Selection
{
int anIndex = aMap(1);
aName += QString(":face_%1").arg(anIndex);
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if (aFindedObject->_is_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else // Global Selection
{
if (aShape.ShapeType() != TopAbs_FACE) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
if ( myEditCurrentArgument == Group2F->LineEdit1 ) { if ( myEditCurrentArgument == Group2F->LineEdit1 ) {
myFace1 = aSelectedObject; myFace1 = aSelectedObject;
if (!myFace1->_is_nil() && myFace2->_is_nil()) if (!myFace2) Group2F->PushButton2->click();
Group2F->PushButton2->click();
} }
else if ( myEditCurrentArgument == Group2F->LineEdit2 ) { else if ( myEditCurrentArgument == Group2F->LineEdit2 ) {
myFace2 = aSelectedObject; myFace2 = aSelectedObject;
if (!myFace2->_is_nil() && myFace1->_is_nil()) if (!myFace1) Group2F->PushButton1->click();
Group2F->PushButton1->click();
} }
else if ( myEditCurrentArgument == Group6F->LineEdit1 ) { else if ( myEditCurrentArgument == Group6F->LineEdit1 ) {
myFace1 = aSelectedObject; myFace1 = aSelectedObject;
if (!myFace1->_is_nil() && myFace2->_is_nil()) if (!myFace2) Group6F->PushButton2->click();
Group6F->PushButton2->click(); else if (!myFace3) Group6F->PushButton3->click();
else if (!myFace4) Group6F->PushButton4->click();
else if (!myFace5) Group6F->PushButton5->click();
else if (!myFace6) Group6F->PushButton6->click();
} }
else if ( myEditCurrentArgument == Group6F->LineEdit2 ) { else if ( myEditCurrentArgument == Group6F->LineEdit2 ) {
myFace2 = aSelectedObject; myFace2 = aSelectedObject;
if (!myFace2->_is_nil() && myFace3->_is_nil()) if (!myFace3) Group6F->PushButton3->click();
Group6F->PushButton3->click(); else if (!myFace4) Group6F->PushButton4->click();
else if (!myFace5) Group6F->PushButton5->click();
else if (!myFace6) Group6F->PushButton6->click();
else if (!myFace1) Group6F->PushButton1->click();
} }
else if ( myEditCurrentArgument == Group6F->LineEdit3 ) { else if ( myEditCurrentArgument == Group6F->LineEdit3 ) {
myFace3 = aSelectedObject; myFace3 = aSelectedObject;
if (!myFace3->_is_nil() && myFace4->_is_nil()) if (!myFace4) Group6F->PushButton4->click();
Group6F->PushButton4->click(); else if (!myFace5) Group6F->PushButton5->click();
else if (!myFace6) Group6F->PushButton6->click();
else if (!myFace1) Group6F->PushButton1->click();
else if (!myFace2) Group6F->PushButton2->click();
} }
else if ( myEditCurrentArgument == Group6F->LineEdit4 ) { else if ( myEditCurrentArgument == Group6F->LineEdit4 ) {
myFace4 = aSelectedObject; myFace4 = aSelectedObject;
if (!myFace4->_is_nil() && myFace5->_is_nil()) if (!myFace5) Group6F->PushButton5->click();
Group6F->PushButton5->click(); else if (!myFace6) Group6F->PushButton6->click();
else if (!myFace1) Group6F->PushButton1->click();
else if (!myFace2) Group6F->PushButton2->click();
else if (!myFace3) Group6F->PushButton3->click();
} }
else if ( myEditCurrentArgument == Group6F->LineEdit5 ) { else if ( myEditCurrentArgument == Group6F->LineEdit5 ) {
myFace5 = aSelectedObject; myFace5 = aSelectedObject;
if (!myFace5->_is_nil() && myFace6->_is_nil()) if (!myFace6) Group6F->PushButton6->click();
Group6F->PushButton6->click(); else if (!myFace1) Group6F->PushButton1->click();
else if (!myFace2) Group6F->PushButton2->click();
else if (!myFace3) Group6F->PushButton3->click();
else if (!myFace4) Group6F->PushButton4->click();
} }
else if ( myEditCurrentArgument == Group6F->LineEdit6 ) { else if ( myEditCurrentArgument == Group6F->LineEdit6 ) {
myFace6 = aSelectedObject; myFace6 = aSelectedObject;
if (!myFace6->_is_nil() && myFace1->_is_nil()) if (!myFace1) Group6F->PushButton1->click();
Group6F->PushButton1->click(); else if (!myFace2) Group6F->PushButton2->click();
else if (!myFace3) Group6F->PushButton3->click();
else if (!myFace4) Group6F->PushButton4->click();
else if (!myFace5) Group6F->PushButton5->click();
}
}
else {
if (myEditCurrentArgument == Group2F->LineEdit1) myFace1.nullify();
else if (myEditCurrentArgument == Group2F->LineEdit2) myFace2.nullify();
else if (myEditCurrentArgument == Group6F->LineEdit1) myFace1.nullify();
else if (myEditCurrentArgument == Group6F->LineEdit2) myFace2.nullify();
else if (myEditCurrentArgument == Group6F->LineEdit3) myFace3.nullify();
else if (myEditCurrentArgument == Group6F->LineEdit4) myFace4.nullify();
else if (myEditCurrentArgument == Group6F->LineEdit5) myFace5.nullify();
else if (myEditCurrentArgument == Group6F->LineEdit6) myFace6.nullify();
myEditCurrentArgument->setText( "" );
} }
displayPreview(); displayPreview();
@ -454,12 +433,10 @@ bool BlocksGUI_BlockDlg::isValid (QString&)
bool ok = false; bool ok = false;
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
ok = !(myFace1->_is_nil() || myFace2->_is_nil()); ok = myFace1 && myFace2;
break; break;
case 1: case 1:
ok = !(myFace1->_is_nil() || myFace2->_is_nil() || ok = myFace1 && myFace2 && myFace3 && myFace4 && myFace5 && myFace6;
myFace3->_is_nil() || myFace4->_is_nil() ||
myFace5->_is_nil() || myFace6->_is_nil());
break; break;
default: default:
break; break;
@ -481,16 +458,14 @@ bool BlocksGUI_BlockDlg::execute (ObjectList& objects)
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
if (!CORBA::is_nil(myFace1) && !CORBA::is_nil(myFace2)) { if ( myFace1 && myFace2 ) {
anObj = anOper->MakeHexa2Faces(myFace1, myFace2); anObj = anOper->MakeHexa2Faces(myFace1.get(), myFace2.get());
res = true; res = true;
} }
break; break;
case 1: case 1:
if (!CORBA::is_nil(myFace1) && !CORBA::is_nil(myFace2) && if ( myFace1 && myFace2 && myFace3 && myFace4 && myFace5 && myFace6 ) {
!CORBA::is_nil(myFace3) && !CORBA::is_nil(myFace4) && anObj = anOper->MakeHexa(myFace1.get(), myFace2.get(), myFace3.get(), myFace4.get(), myFace5.get(), myFace6.get());
!CORBA::is_nil(myFace5) && !CORBA::is_nil(myFace6)) {
anObj = anOper->MakeHexa(myFace1, myFace2, myFace3, myFace4, myFace5, myFace6);
res = true; res = true;
} }
break; break;
@ -508,21 +483,20 @@ bool BlocksGUI_BlockDlg::execute (ObjectList& objects)
//================================================================================= //=================================================================================
void BlocksGUI_BlockDlg::addSubshapesToStudy() void BlocksGUI_BlockDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
objMap[Group2F->LineEdit1->text()] = myFace1; GEOMBase::PublishSubObject( myFace1.get() );
objMap[Group2F->LineEdit2->text()] = myFace2; GEOMBase::PublishSubObject( myFace2.get() );
break; break;
case 1: case 1:
objMap[Group6F->LineEdit1->text()] = myFace1; GEOMBase::PublishSubObject( myFace1.get() );
objMap[Group6F->LineEdit2->text()] = myFace2; GEOMBase::PublishSubObject( myFace2.get() );
objMap[Group6F->LineEdit3->text()] = myFace3; GEOMBase::PublishSubObject( myFace3.get() );
objMap[Group6F->LineEdit4->text()] = myFace4; GEOMBase::PublishSubObject( myFace4.get() );
objMap[Group6F->LineEdit5->text()] = myFace5; GEOMBase::PublishSubObject( myFace5.get() );
objMap[Group6F->LineEdit6->text()] = myFace6; GEOMBase::PublishSubObject( myFace6.get() );
break;
default:
break; break;
} }
addSubshapesToFather(objMap);
} }

View File

@ -27,7 +27,8 @@
#ifndef BLOCKSGUI_BLOCKDLG_H #ifndef BLOCKSGUI_BLOCKDLG_H
#define BLOCKSGUI_BLOCKDLG_H #define BLOCKSGUI_BLOCKDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel; class DlgRef_2Sel;
class DlgRef_6Sel; class DlgRef_6Sel;
@ -58,8 +59,8 @@ private:
private: private:
int myConstructorId; int myConstructorId;
GEOM::GEOM_Object_var myFace1, myFace2; GEOM::GeomObjPtr myFace1, myFace2;
GEOM::GEOM_Object_var myFace3, myFace4, myFace5, myFace6; GEOM::GeomObjPtr myFace3, myFace4, myFace5, myFace6;
// to initialize the first selection field with a selected object on the dialog creation // to initialize the first selection field with a selected object on the dialog creation
bool myInitial; bool myInitial;

View File

@ -146,8 +146,10 @@ void BlocksGUI_QuadFaceDlg::ConstructorsClicked (int constructorId)
myConstructorId = constructorId; myConstructorId = constructorId;
// init fields // init fields
myShape1 = myShape2 = GEOM::GEOM_Object::_nil(); myShape1.nullify();
myShape3 = myShape4 = myShape1; myShape2.nullify();
myShape3.nullify();
myShape4.nullify();
// clear line edits // clear line edits
QMap<int, QLineEdit*>::iterator anIterLE; QMap<int, QLineEdit*>::iterator anIterLE;
@ -226,120 +228,105 @@ void BlocksGUI_QuadFaceDlg::SelectionIntoArgument()
} }
} }
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
TopAbs_ShapeEnum aType = TopAbs_EDGE; TopAbs_ShapeEnum aType = TopAbs_EDGE;
if (aCurrFocus == Vertex1 || aCurrFocus == Vertex2 || if (aCurrFocus == Vertex1 || aCurrFocus == Vertex2 ||
aCurrFocus == Vertex3 || aCurrFocus == Vertex4) aCurrFocus == Vertex3 || aCurrFocus == Vertex4)
aType = TopAbs_VERTEX; aType = TopAbs_VERTEX;
QString aName; GEOM::GeomObjPtr aSelectedObject = getSelected( aType );
GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_nil();
if (aSelList.Extent() == 1) {
anObj = GEOMBase::ConvertIOinGEOMObject(aSelList. First() );
if ( !anObj->_is_nil() ) {
aName = GEOMBase::GetName(anObj);
// Get Selected object if selected subshape
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (GEOMBase::GetShape(anObj, aShape, TopAbs_SHAPE) && !aShape.IsNull()) if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
{ QString aName = GEOMBase::GetName( aSelectedObject.get() );
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) // Local Selection
{
int anIndex = aMap(1);
if (aType == TopAbs_VERTEX)
aName += QString(":vertex_%1").arg(anIndex);
else
aName += QString(":edge_%1").arg(anIndex);
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(anObj, aName);
if (aFindedObject->_is_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
anObj = aShapesOp->GetSubShape(anObj, anIndex);
}
else
anObj = aFindedObject; // get Object from study
}
else // Global Selection
{
if (aShape.ShapeType() != aType) {
anObj = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
}
}
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
switch (aCurrFocus) { switch (aCurrFocus) {
// four vertices // four vertices
case Vertex1: case Vertex1:
myShape1 = anObj; myShape1 = aSelectedObject;
if (!myShape1->_is_nil() && myShape2->_is_nil()) if (!myShape2) mySelBtn[Vertex2]->click();
mySelBtn[Vertex2]->click(); else if (!myShape3) mySelBtn[Vertex3]->click();
else if (!myShape4) mySelBtn[Vertex4]->click();
break; break;
case Vertex2: case Vertex2:
myShape2 = anObj; myShape2 = aSelectedObject;
if (!myShape2->_is_nil() && myShape3->_is_nil()) if (!myShape3) mySelBtn[Vertex3]->click();
mySelBtn[Vertex3]->click(); else if (!myShape4) mySelBtn[Vertex4]->click();
else if (!myShape1) mySelBtn[Vertex1]->click();
break; break;
case Vertex3: case Vertex3:
myShape3 = anObj; myShape3 = aSelectedObject;
if (!myShape3->_is_nil() && myShape4->_is_nil()) if (!myShape4) mySelBtn[Vertex4]->click();
mySelBtn[Vertex4]->click(); else if (!myShape1) mySelBtn[Vertex1]->click();
else if (!myShape2) mySelBtn[Vertex2]->click();
break; break;
case Vertex4: case Vertex4:
myShape4 = anObj; myShape4 = aSelectedObject;
if (!myShape4->_is_nil() && myShape1->_is_nil()) if (!myShape1) mySelBtn[Vertex1]->click();
mySelBtn[Vertex1]->click(); else if (!myShape2) mySelBtn[Vertex2]->click();
else if (!myShape3) mySelBtn[Vertex3]->click();
break; break;
// two edges // two edges
case Edge12: case Edge12:
myShape1 = anObj; myShape1 = aSelectedObject;
if (!myShape1->_is_nil() && myShape2->_is_nil()) if (!myShape2) mySelBtn[Edge22]->click();
mySelBtn[Edge22]->click();
break; break;
case Edge22: case Edge22:
myShape2 = anObj; myShape2 = aSelectedObject;
if (!myShape2->_is_nil() && myShape1->_is_nil()) if (!myShape1) mySelBtn[Edge12]->click();
mySelBtn[Edge12]->click();
break; break;
// four edges // four edges
case Edge14: case Edge14:
myShape1 = anObj; myShape1 = aSelectedObject;
if (!myShape1->_is_nil() && myShape2->_is_nil()) if (!myShape2) mySelBtn[Edge24]->click();
mySelBtn[Edge24]->click(); else if (!myShape3) mySelBtn[Edge34]->click();
else if (!myShape4) mySelBtn[Edge44]->click();
break; break;
case Edge24: case Edge24:
myShape2 = anObj; myShape2 = aSelectedObject;
if (!myShape2->_is_nil() && myShape3->_is_nil()) if (!myShape3) mySelBtn[Edge34]->click();
mySelBtn[Edge34]->click(); else if (!myShape4) mySelBtn[Edge44]->click();
else if (!myShape1) mySelBtn[Edge14]->click();
break; break;
case Edge34: case Edge34:
myShape3 = anObj; myShape3 = aSelectedObject;
if (!myShape3->_is_nil() && myShape4->_is_nil()) if (!myShape4) mySelBtn[Edge44]->click();
mySelBtn[Edge44]->click(); else if (!myShape1) mySelBtn[Edge14]->click();
else if (!myShape2) mySelBtn[Edge24]->click();
break; break;
case Edge44: case Edge44:
myShape4 = anObj; myShape4 = aSelectedObject;
if (!myShape4->_is_nil() && myShape1->_is_nil()) if (!myShape1) mySelBtn[Edge14]->click();
mySelBtn[Edge14]->click(); else if (!myShape2) mySelBtn[Edge24]->click();
else if (!myShape3) mySelBtn[Edge34]->click();
break; break;
default: default:
break; break;
} }
}
else {
switch (aCurrFocus) {
case Vertex1:
case Edge12:
case Edge14:
myShape1.nullify();
break;
case Vertex2:
case Edge22:
case Edge24:
myShape2.nullify();
break;
case Vertex3:
case Edge34:
myShape3.nullify();
break;
case Vertex4:
case Edge44:
myShape4.nullify();
break;
default:
break;
}
myEditCurrentArgument->setText( "" );
}
displayPreview(); displayPreview();
} }
@ -506,15 +493,13 @@ bool BlocksGUI_QuadFaceDlg::isValid (QString&)
bool ok = false; bool ok = false;
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
ok = (!myShape1->_is_nil() && !myShape2->_is_nil() && ok = myShape1 && myShape2 && myShape3 && myShape4;
!myShape3->_is_nil() && !myShape4->_is_nil());
break; break;
case 1: case 1:
ok = (!myShape1->_is_nil() && !myShape2->_is_nil()); ok = myShape1 && myShape2;
break; break;
case 2: case 2:
ok = (!myShape1->_is_nil() && !myShape2->_is_nil() && ok = myShape1 && myShape2 && myShape3 && myShape4;
!myShape3->_is_nil() && !myShape4->_is_nil());
break; break;
default: default:
break; break;
@ -536,15 +521,15 @@ bool BlocksGUI_QuadFaceDlg::execute (ObjectList& objects)
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
anObj = anOper->MakeQuad4Vertices(myShape1, myShape2, myShape3, myShape4); anObj = anOper->MakeQuad4Vertices(myShape1.get(), myShape2.get(), myShape3.get(), myShape4.get());
res = true; res = true;
break; break;
case 1: case 1:
anObj = anOper->MakeQuad2Edges(myShape1, myShape2); anObj = anOper->MakeQuad2Edges(myShape1.get(), myShape2.get());
res = true; res = true;
break; break;
case 2: case 2:
anObj = anOper->MakeQuad(myShape1, myShape2, myShape3, myShape4); anObj = anOper->MakeQuad(myShape1.get(), myShape2.get(), myShape3.get(), myShape4.get());
res = true; res = true;
break; break;
default: default:
@ -563,25 +548,24 @@ bool BlocksGUI_QuadFaceDlg::execute (ObjectList& objects)
//================================================================================= //=================================================================================
void BlocksGUI_QuadFaceDlg::addSubshapesToStudy() void BlocksGUI_QuadFaceDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
objMap[mySelName[Vertex1]->text()] = myShape1; GEOMBase::PublishSubObject( myShape1.get() );
objMap[mySelName[Vertex2]->text()] = myShape2; GEOMBase::PublishSubObject( myShape2.get() );
objMap[mySelName[Vertex3]->text()] = myShape3; GEOMBase::PublishSubObject( myShape3.get() );
objMap[mySelName[Vertex4]->text()] = myShape4; GEOMBase::PublishSubObject( myShape4.get() );
break; break;
case 1: case 1:
objMap[mySelName[Edge12]->text()] = myShape1; GEOMBase::PublishSubObject( myShape1.get() );
objMap[mySelName[Edge22]->text()] = myShape2; GEOMBase::PublishSubObject( myShape2.get() );
break; break;
case 2: case 2:
objMap[mySelName[Edge14]->text()] = myShape1; GEOMBase::PublishSubObject( myShape1.get() );
objMap[mySelName[Edge24]->text()] = myShape2; GEOMBase::PublishSubObject( myShape2.get() );
objMap[mySelName[Edge34]->text()] = myShape3; GEOMBase::PublishSubObject( myShape3.get() );
objMap[mySelName[Edge44]->text()] = myShape4; GEOMBase::PublishSubObject( myShape4.get() );
break;
default:
break; break;
} }
addSubshapesToFather(objMap);
} }

View File

@ -27,7 +27,8 @@
#ifndef BLOCKSGUI_QUADFACEDLG_H #ifndef BLOCKSGUI_QUADFACEDLG_H
#define BLOCKSGUI_QUADFACEDLG_H #define BLOCKSGUI_QUADFACEDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
#include <QMap> #include <QMap>
@ -69,10 +70,10 @@ private:
private: private:
int myConstructorId; int myConstructorId;
GEOM::GEOM_Object_var myShape1; GEOM::GeomObjPtr myShape1;
GEOM::GEOM_Object_var myShape2; GEOM::GeomObjPtr myShape2;
GEOM::GEOM_Object_var myShape3; GEOM::GeomObjPtr myShape3;
GEOM::GEOM_Object_var myShape4; GEOM::GeomObjPtr myShape4;
// to initialize the first selection field with a selected object on the dialog creation // to initialize the first selection field with a selected object on the dialog creation
bool myInitial; bool myInitial;

View File

@ -135,15 +135,13 @@ void BooleanGUI_Dialog::Init()
myGroup->LineEdit1->setText(""); myGroup->LineEdit1->setText("");
myGroup->LineEdit2->setText(""); myGroup->LineEdit2->setText("");
myObject1 = myObject2 = GEOM::GEOM_Object::_nil(); myObject1.nullify();
myObject2.nullify();
// signals and slots connections // signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect(myGroup->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(myGroup->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(myGroup->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(myGroup->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(myGroup->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(myGroup->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
@ -198,21 +196,11 @@ void BooleanGUI_Dialog::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_SHAPE );
SALOME_ListIO aSelList; TopoDS_Shape aShape;
aSelMgr->selectedObjects(aSelList); if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
QString aName = GEOMBase::GetName( aSelectedObject.get() );
if (aSelList.Extent() != 1) { myEditCurrentArgument->setText( aName );
if (myEditCurrentArgument == myGroup->LineEdit1) myObject1 = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2 = GEOM::GEOM_Object::_nil();
return;
}
// nbSel == 1
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( GEOMBase::IsShape(aSelectedObject) )
{
myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
// clear selection // clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
@ -222,15 +210,19 @@ void BooleanGUI_Dialog::SelectionIntoArgument()
if (myEditCurrentArgument == myGroup->LineEdit1) { if (myEditCurrentArgument == myGroup->LineEdit1) {
myObject1 = aSelectedObject; myObject1 = aSelectedObject;
if (myObject2->_is_nil()) if (!myObject2)
myGroup->PushButton2->click(); myGroup->PushButton2->click();
} }
else if (myEditCurrentArgument == myGroup->LineEdit2) { else if (myEditCurrentArgument == myGroup->LineEdit2) {
myObject2 = aSelectedObject; myObject2 = aSelectedObject;
if (myObject1->_is_nil()) if (!myObject1)
myGroup->PushButton1->click(); myGroup->PushButton1->click();
} }
} }
else {
if (myEditCurrentArgument == myGroup->LineEdit1) myObject1.nullify();
else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2.nullify();
}
} }
//================================================================================= //=================================================================================
@ -261,19 +253,6 @@ void BooleanGUI_Dialog::SetEditCurrentArgument()
send->setDown(true); send->setDown(true);
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void BooleanGUI_Dialog::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if (send == myGroup->LineEdit1 || send == myGroup->LineEdit2) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -312,12 +291,7 @@ GEOM::GEOM_IOperations_ptr BooleanGUI_Dialog::createOperation()
//================================================================================= //=================================================================================
bool BooleanGUI_Dialog::isValid (QString&) bool BooleanGUI_Dialog::isValid (QString&)
{ {
//Handle(SALOME_InteractiveObject) IO = firstIObject(); return myObject1 && myObject2;
//GEOM::GEOM_Object_var anObject = GEOMBase::ConvertIOinGEOMObject( IO );
//if ( anObject->_is_nil() )
// return false;
return !CORBA::is_nil(myObject1) && !CORBA::is_nil(myObject2);
} }
//================================================================================= //=================================================================================
@ -329,7 +303,7 @@ bool BooleanGUI_Dialog::execute (ObjectList& objects)
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow(getOperation()); GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow(getOperation());
anObj = anOper->MakeBoolean(myObject1, myObject2, myOperation); anObj = anOper->MakeBoolean(myObject1.get(), myObject2.get(), myOperation);
if (!anObj->_is_nil()) if (!anObj->_is_nil())
objects.push_back(anObj._retn()); objects.push_back(anObj._retn());

View File

@ -27,7 +27,8 @@
#ifndef BOOLEANGUI_DIALOG_H #ifndef BOOLEANGUI_DIALOG_H
#define BOOLEANGUI_DIALOG_H #define BOOLEANGUI_DIALOG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel; class DlgRef_2Sel;
@ -58,8 +59,8 @@ private:
private: private:
int myOperation; int myOperation;
GEOM::GEOM_Object_var myObject1; GEOM::GeomObjPtr myObject1;
GEOM::GEOM_Object_var myObject2; GEOM::GeomObjPtr myObject2;
DlgRef_2Sel* myGroup; DlgRef_2Sel* myGroup;
@ -68,7 +69,6 @@ private slots:
bool ClickOnApply(); bool ClickOnApply();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void SelectionIntoArgument(); void SelectionIntoArgument();
void LineEditReturnPressed();
void ActivateThisDialog(); void ActivateThisDialog();
}; };

View File

@ -99,7 +99,7 @@ void BuildGUI_CompoundDlg::Init()
myEditCurrentArgument = GroupShapes->LineEdit1; myEditCurrentArgument = GroupShapes->LineEdit1;
GroupShapes->LineEdit1->setReadOnly( true ); GroupShapes->LineEdit1->setReadOnly( true );
myOkShapes = false; myShapes.clear();
mainFrame()->GroupBoxPublish->show(); mainFrame()->GroupBoxPublish->show();
@ -149,22 +149,13 @@ bool BuildGUI_CompoundDlg::ClickOnApply()
void BuildGUI_CompoundDlg::SelectionIntoArgument() void BuildGUI_CompoundDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
QString aString = ""; /* name of selection */
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); myShapes = getSelected( TopAbs_SHAPE, -1 );
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
myOkShapes = false; if ( !myShapes.isEmpty() ) {
int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true); QString aName = myShapes.count() > 1 ? QString( "%1_objects").arg( myShapes.count() ) : GEOMBase::GetName( myShapes[0].get() );
if ( nbSel == 0 ) myEditCurrentArgument->setText( aName );
return; }
if ( nbSel != 1 )
aString = QString( "%1_objects").arg( nbSel );
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myShapes, true);
myEditCurrentArgument->setText( aString );
myOkShapes = true;
} }
@ -223,7 +214,7 @@ GEOM::GEOM_IOperations_ptr BuildGUI_CompoundDlg::createOperation()
//================================================================================= //=================================================================================
bool BuildGUI_CompoundDlg::isValid( QString& ) bool BuildGUI_CompoundDlg::isValid( QString& )
{ {
return myOkShapes; return !myShapes.isEmpty();
} }
//================================================================================= //=================================================================================
@ -233,7 +224,13 @@ bool BuildGUI_CompoundDlg::isValid( QString& )
bool BuildGUI_CompoundDlg::execute( ObjectList& objects ) bool BuildGUI_CompoundDlg::execute( ObjectList& objects )
{ {
GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
GEOM::GEOM_Object_var anObj = anOper->MakeCompound( myShapes );
GEOM::ListOfGO_var objlist = new GEOM::ListOfGO();
objlist->length( myShapes.count() );
for ( int i = 0; i < myShapes.count(); i++ )
objlist[i] = myShapes[i].copy();
GEOM::GEOM_Object_var anObj = anOper->MakeCompound( objlist );
if ( !anObj->_is_nil() ) if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() ); objects.push_back( anObj._retn() );

View File

@ -27,7 +27,8 @@
#ifndef BUILDGUI_COMPOUNDDLG_H #ifndef BUILDGUI_COMPOUNDDLG_H
#define BUILDGUI_COMPOUNDDLG_H #define BUILDGUI_COMPOUNDDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel; class DlgRef_1Sel;
@ -55,8 +56,7 @@ private:
void enterEvent( QEvent* ); void enterEvent( QEvent* );
private: private:
GEOM::ListOfGO myShapes; QList<GEOM::GeomObjPtr> myShapes;
bool myOkShapes;
DlgRef_1Sel* GroupShapes; DlgRef_1Sel* GroupShapes;

View File

@ -119,7 +119,9 @@ BuildGUI_EdgeDlg::~BuildGUI_EdgeDlg()
void BuildGUI_EdgeDlg::Init() void BuildGUI_EdgeDlg::Init()
{ {
// init variables // init variables
myPoint1 = myPoint2 = myWire = GEOM::GEOM_Object::_nil(); myPoint1.nullify();
myPoint2.nullify();
myWire.nullify();
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton1->setDown(true); GroupPoints->PushButton1->setDown(true);
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
@ -138,10 +140,6 @@ void BuildGUI_EdgeDlg::Init()
connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupWire->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupWire->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupWire->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) ); this, SLOT( SelectionIntoArgument() ) );
@ -192,8 +190,8 @@ void BuildGUI_EdgeDlg::ConstructorsClicked( int constructorId )
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setText( "" ); GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" ); GroupPoints->LineEdit2->setText( "" );
myPoint1 = GEOM::GEOM_Object::_nil(); myPoint1.nullify();
myPoint2 = GEOM::GEOM_Object::_nil(); myPoint2.nullify();
GroupPoints->PushButton1->setDown(true); GroupPoints->PushButton1->setDown(true);
GroupPoints->PushButton2->setDown(false); GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit1->setEnabled(true); GroupPoints->LineEdit1->setEnabled(true);
@ -209,7 +207,7 @@ void BuildGUI_EdgeDlg::ConstructorsClicked( int constructorId )
myEditCurrentArgument = GroupWire->LineEdit1; myEditCurrentArgument = GroupWire->LineEdit1;
GroupWire->LineEdit1->setText(""); GroupWire->LineEdit1->setText("");
myWire = GEOM::GEOM_Object::_nil(); myWire.nullify();
GroupWire->PushButton1->setDown(true); GroupWire->PushButton1->setDown(true);
GroupWire->LineEdit1->setEnabled(true); GroupWire->LineEdit1->setEnabled(true);
GroupPoints->hide(); GroupPoints->hide();
@ -238,61 +236,31 @@ void BuildGUI_EdgeDlg::SelectionIntoArgument()
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil(); if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1.nullify();
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2.nullify();
else if (myEditCurrentArgument == GroupWire->LineEdit1) myWire = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == GroupWire->LineEdit1) myWire.nullify();
displayPreview(); displayPreview();
return; return;
} }
// nbSel == 1
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( !aSelectedObject->_is_nil() ) {
QString aName = GEOMBase::GetName( aSelectedObject );
TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupWire->LineEdit1 ? TopAbs_WIRE : TopAbs_VERTEX; TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupWire->LineEdit1 ? TopAbs_WIRE : TopAbs_VERTEX;
GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
TColStd_IndexedMapOfInteger aMap; QString aName = GEOMBase::GetName( aSelectedObject.get() );
aSelMgr->GetIndexes( aSelList.First(), aMap );
if ( aMap.Extent() == 1 ) { // Local Selection
int anIndex = aMap( 1 );
aName += ( aNeedType == TopAbs_WIRE ? QString( ":wire_%1" ).arg( anIndex ) : QString( ":vertex_%1" ).arg( anIndex ) );
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
if ( CORBA::is_nil( aFindedObject ) ) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else { // Global Selection
if ( aShape.ShapeType() != aNeedType ) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
if (!aSelectedObject->_is_nil()) { // clear selection if something selected
globalSelection(); globalSelection();
localSelection( GEOM::GEOM_Object::_nil(), aNeedType ); localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
}
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
if ( !myPoint1->_is_nil() && myPoint2->_is_nil() ) if ( myPoint1 && !myPoint2 )
GroupPoints->PushButton2->click(); GroupPoints->PushButton2->click();
} }
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
if ( !myPoint2->_is_nil() && myPoint1->_is_nil() ) if ( myPoint2 && !myPoint1 )
GroupPoints->PushButton1->click(); GroupPoints->PushButton1->click();
} }
else if ( myEditCurrentArgument == GroupWire->LineEdit1 ) { else if ( myEditCurrentArgument == GroupWire->LineEdit1 ) {
@ -332,19 +300,6 @@ void BuildGUI_EdgeDlg::SetEditCurrentArgument()
displayPreview(); displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void BuildGUI_EdgeDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if (send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2 || send == GroupWire->LineEdit1 ) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -385,13 +340,17 @@ GEOM::GEOM_IOperations_ptr BuildGUI_EdgeDlg::createOperation()
bool BuildGUI_EdgeDlg::isValid (QString& msg) bool BuildGUI_EdgeDlg::isValid (QString& msg)
{ {
bool ok = false; bool ok = false;
if ( getConstructorId() == 0 ) { switch ( getConstructorId() ) {
ok = !myPoint1->_is_nil() && !myPoint2->_is_nil(); case 0:
} ok = myPoint1 && myPoint2;
else { break;
ok = !myWire->_is_nil(); case 1:
ok = ok && GroupWire->SpinBox_DX->isValid( msg, !IsPreview() ); ok = GroupWire->SpinBox_DX->isValid( msg, !IsPreview() ) &&
ok = ok && GroupWire->SpinBox_DY->isValid( msg, !IsPreview() ); GroupWire->SpinBox_DY->isValid( msg, !IsPreview() ) &&
myWire;
break;
default:
break;
} }
return ok; return ok;
} }
@ -410,7 +369,7 @@ bool BuildGUI_EdgeDlg::execute (ObjectList& objects)
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0 : case 0 :
{ {
anObj = anOper->MakeEdge( myPoint1, myPoint2 ); anObj = anOper->MakeEdge( myPoint1.get(), myPoint2.get() );
res = true; res = true;
break; break;
} }
@ -423,7 +382,7 @@ bool BuildGUI_EdgeDlg::execute (ObjectList& objects)
aParameters << GroupWire->SpinBox_DX->text(); aParameters << GroupWire->SpinBox_DX->text();
aParameters << GroupWire->SpinBox_DY->text(); aParameters << GroupWire->SpinBox_DY->text();
anObj = anOper->MakeEdgeWire( myWire, aLinearTolerance, anAngularTolerance ); anObj = anOper->MakeEdgeWire( myWire.get(), aLinearTolerance, anAngularTolerance );
if ( !anObj->_is_nil() && !IsPreview() ) if ( !anObj->_is_nil() && !IsPreview() )
anObj->SetParameters( aParameters.join(":").toLatin1().constData() ); anObj->SetParameters( aParameters.join(":").toLatin1().constData() );
@ -444,15 +403,15 @@ bool BuildGUI_EdgeDlg::execute (ObjectList& objects)
//================================================================================= //=================================================================================
void BuildGUI_EdgeDlg::addSubshapesToStudy() void BuildGUI_EdgeDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0 : case 0 :
objMap[GroupPoints->LineEdit1->text()] = myPoint1; GEOMBase::PublishSubObject( myPoint1.get() );
objMap[GroupPoints->LineEdit2->text()] = myPoint2; GEOMBase::PublishSubObject( myPoint2.get() );
break; break;
case 1 : case 1 :
objMap[GroupWire->LineEdit1->text()] = myWire; GEOMBase::PublishSubObject( myWire.get() );
break;
default:
break; break;
} }
addSubshapesToFather( objMap );
} }

View File

@ -27,7 +27,8 @@
#ifndef BUILDGUI_EDGEDLG_H #ifndef BUILDGUI_EDGEDLG_H
#define BUILDGUI_EDGEDLG_H #define BUILDGUI_EDGEDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel2Spin; class DlgRef_1Sel2Spin;
class DlgRef_2Sel; class DlgRef_2Sel;
@ -56,8 +57,8 @@ private:
void enterEvent( QEvent* ); void enterEvent( QEvent* );
private: private:
GEOM::GEOM_Object_var myPoint1, myPoint2; /* Points containing the edge */ GEOM::GeomObjPtr myPoint1, myPoint2; /* Points containing the edge */
GEOM::GEOM_Object_var myWire; /* Wire */ GEOM::GeomObjPtr myWire; /* Wire */
DlgRef_2Sel* GroupPoints; DlgRef_2Sel* GroupPoints;
DlgRef_1Sel2Spin* GroupWire; DlgRef_1Sel2Spin* GroupWire;
@ -67,7 +68,6 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
}; };

View File

@ -101,6 +101,7 @@ void BuildGUI_FaceDlg::Init()
GroupWire->LineEdit1->setReadOnly( true ); GroupWire->LineEdit1->setReadOnly( true );
GroupWire->CheckButton1->setChecked( true ); GroupWire->CheckButton1->setChecked( true );
myWires.clear();
TColStd_MapOfInteger aMap; TColStd_MapOfInteger aMap;
aMap.Add( GEOM_EDGE ); aMap.Add( GEOM_EDGE );
@ -152,27 +153,16 @@ bool BuildGUI_FaceDlg::ClickOnApply()
void BuildGUI_FaceDlg::SelectionIntoArgument() void BuildGUI_FaceDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
QString aName;
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); QList<TopAbs_ShapeEnum> types;
SALOME_ListIO aSelList; types << TopAbs_EDGE << TopAbs_WIRE;
aSelMgr->selectedObjects(aSelList); myWires = getSelected( types, -1 );
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
if ( aNbSel < 1) {
myWires.length(0);
return;
}
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myWires);
if ( !myWires.length() )
return;
if ( aNbSel != 1 )
aName = tr( "%1_objects" ).arg( aNbSel );
if ( !myWires.isEmpty() ) {
QString aName = myWires.count() > 1 ? QString( "%1_objects").arg( myWires.count() ) : GEOMBase::GetName( myWires[0].get() );
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
} }
}
//================================================================================= //=================================================================================
@ -238,7 +228,7 @@ GEOM::GEOM_IOperations_ptr BuildGUI_FaceDlg::createOperation()
//================================================================================= //=================================================================================
bool BuildGUI_FaceDlg::isValid( QString& ) bool BuildGUI_FaceDlg::isValid( QString& )
{ {
return ( myWires.length() != 0 ); return !myWires.isEmpty();
} }
//================================================================================= //=================================================================================
@ -248,7 +238,13 @@ bool BuildGUI_FaceDlg::isValid( QString& )
bool BuildGUI_FaceDlg::execute( ObjectList& objects ) bool BuildGUI_FaceDlg::execute( ObjectList& objects )
{ {
GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
GEOM::GEOM_Object_var anObj = anOper->MakeFaceWires( myWires, GroupWire->CheckButton1->isChecked() );
GEOM::ListOfGO_var objlist = new GEOM::ListOfGO();
objlist->length( myWires.count() );
for ( int i = 0; i < myWires.count(); i++ )
objlist[i] = myWires[i].copy();
GEOM::GEOM_Object_var anObj = anOper->MakeFaceWires( objlist.in(), GroupWire->CheckButton1->isChecked() );
if ( !anObj->_is_nil() ) if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() ); objects.push_back( anObj._retn() );

View File

@ -27,7 +27,8 @@
#ifndef BUILDGUI_FACEDLG_H #ifndef BUILDGUI_FACEDLG_H
#define BUILDGUI_FACEDLG_H #define BUILDGUI_FACEDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel1Check; class DlgRef_1Sel1Check;
@ -54,7 +55,7 @@ private:
void enterEvent( QEvent* ); void enterEvent( QEvent* );
private: private:
GEOM::ListOfGO myWires; QList<GEOM::GeomObjPtr> myWires;
DlgRef_1Sel1Check* GroupWire; DlgRef_1Sel1Check* GroupWire;

View File

@ -101,7 +101,7 @@ void BuildGUI_ShellDlg::Init()
myEditCurrentArgument = GroupShell->LineEdit1; myEditCurrentArgument = GroupShell->LineEdit1;
GroupShell->LineEdit1->setReadOnly( true ); GroupShell->LineEdit1->setReadOnly( true );
myOkFacesAndShells = false; myFacesAndShells.clear();
TColStd_MapOfInteger aMap; TColStd_MapOfInteger aMap;
aMap.Add( GEOM_SHELL ); aMap.Add( GEOM_SHELL );
@ -158,25 +158,15 @@ bool BuildGUI_ShellDlg::ClickOnApply()
void BuildGUI_ShellDlg::SelectionIntoArgument() void BuildGUI_ShellDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
QString aString;
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); QList<TopAbs_ShapeEnum> types;
SALOME_ListIO aSelList; types << TopAbs_FACE << TopAbs_SHELL << TopAbs_COMPOUND;
aSelMgr->selectedObjects(aSelList); myFacesAndShells = getSelected( types, -1 );
myOkFacesAndShells = false; if ( !myFacesAndShells.isEmpty() ) {
int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true); QString aName = myFacesAndShells.count() > 1 ? QString( "%1_objects").arg( myFacesAndShells.count() ) : GEOMBase::GetName( myFacesAndShells[0].get() );
if ( nbSel == 0 ) myEditCurrentArgument->setText( aName );
return; }
if ( nbSel != 1 )
aString = QString( "%1_objects ").arg( nbSel );
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myFacesAndShells, true);
if ( !myFacesAndShells.length() )
return;
myEditCurrentArgument->setText( aString );
myOkFacesAndShells = true;
} }
@ -251,7 +241,7 @@ GEOM::GEOM_IOperations_ptr BuildGUI_ShellDlg::createOperation()
//================================================================================= //=================================================================================
bool BuildGUI_ShellDlg::isValid( QString& ) bool BuildGUI_ShellDlg::isValid( QString& )
{ {
return myOkFacesAndShells; return !myFacesAndShells.isEmpty();
} }
//================================================================================= //=================================================================================
@ -261,7 +251,13 @@ bool BuildGUI_ShellDlg::isValid( QString& )
bool BuildGUI_ShellDlg::execute( ObjectList& objects ) bool BuildGUI_ShellDlg::execute( ObjectList& objects )
{ {
GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
GEOM::GEOM_Object_var anObj = anOper->MakeShell( myFacesAndShells );
GEOM::ListOfGO_var objlist = new GEOM::ListOfGO();
objlist->length( myFacesAndShells.count() );
for ( int i = 0; i < myFacesAndShells.count(); i++ )
objlist[i] = myFacesAndShells[i].copy();
GEOM::GEOM_Object_var anObj = anOper->MakeShell( objlist.in() );
if ( !anObj->_is_nil() ) if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() ); objects.push_back( anObj._retn() );

View File

@ -27,7 +27,8 @@
#ifndef BUILDGUI_SHELLDLG_H #ifndef BUILDGUI_SHELLDLG_H
#define BUILDGUI_SHELLDLG_H #define BUILDGUI_SHELLDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel; class DlgRef_1Sel;
@ -54,8 +55,7 @@ private:
void enterEvent( QEvent* ); void enterEvent( QEvent* );
private: private:
GEOM::ListOfGO myFacesAndShells; QList<GEOM::GeomObjPtr> myFacesAndShells;
bool myOkFacesAndShells;/* to check when arguments is defined */
DlgRef_1Sel* GroupShell; DlgRef_1Sel* GroupShell;

View File

@ -102,7 +102,7 @@ void BuildGUI_SolidDlg::Init()
GroupSolid->LineEdit1->setReadOnly( true ); GroupSolid->LineEdit1->setReadOnly( true );
GroupSolid->CheckButton1->setChecked( true ); GroupSolid->CheckButton1->setChecked( true );
myOkShells = false; myShells.clear();
globalSelection( GEOM_SHELL ); globalSelection( GEOM_SHELL );
@ -137,17 +137,6 @@ void BuildGUI_SolidDlg::ClickOnOk()
//================================================================================= //=================================================================================
bool BuildGUI_SolidDlg::ClickOnApply() bool BuildGUI_SolidDlg::ClickOnApply()
{ {
for ( int i = 0, n = myShells.length(); i< n; i++ ) {
if ( !isClosed(i)) {
QString aName = GEOMBase::GetName( myShells[i] );
SUIT_MessageBox::warning( (QWidget*)SUIT_Session::session()->activeApplication()->desktop(),
QObject::tr("WRN_WARNING"),
QObject::tr("WRN_SHAPE_UNCLOSED").arg(aName) ,
QObject::tr("BUT_OK") );
return false;
}
}
if ( !onAccept() ) if ( !onAccept() )
return false; return false;
@ -163,25 +152,13 @@ bool BuildGUI_SolidDlg::ClickOnApply()
void BuildGUI_SolidDlg::SelectionIntoArgument() void BuildGUI_SolidDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
QString aString = "";
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); myShells = getSelected( TopAbs_SHELL, -1 );
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
myOkShells = false; if ( !myShells.isEmpty() ) {
int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString); QString aName = myShells.count() > 1 ? QString( "%1_objects").arg( myShells.count() ) : GEOMBase::GetName( myShells[0].get() );
if ( nbSel == 0 ) myEditCurrentArgument->setText( aName );
return; }
if ( nbSel != 1 )
aString = tr( "%1_objects" ).arg( nbSel );
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myShells);
if ( !myShells.length() )
return;
myEditCurrentArgument->setText( aString );
myOkShells = true;
} }
//================================================================================= //=================================================================================
@ -248,43 +225,51 @@ GEOM::GEOM_IOperations_ptr BuildGUI_SolidDlg::createOperation()
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool BuildGUI_SolidDlg::isValid( QString& ) bool BuildGUI_SolidDlg::isValid( QString& msg )
{ {
return myOkShells; bool ok = !myShells.isEmpty();
for ( int i = 0, n = myShells.count(); i < n && ok; i++ ) {
ok = isClosed( myShells[i].get() );
if ( !ok )
msg = QObject::tr("WRN_SHAPE_UNCLOSED").arg( GEOMBase::GetName( myShells[i].get() ) );
}
return ok;
} }
//================================================================================= //=================================================================================
// function : isClosed // function : isClosed
// purpose : Check the object 'i' in myShells list is closed or unclosed // purpose : Check the object 'i' in myShells list is closed or unclosed
//================================================================================= //=================================================================================
bool BuildGUI_SolidDlg::isClosed(int i) bool BuildGUI_SolidDlg::isClosed( GEOM::GEOM_Object_ptr shell )
{ {
GEOM::GEOM_Object_var aShape = myShells[i]; bool ok = false;
GEOM::GEOM_IKindOfShape::shape_kind aKind; GEOM::GEOM_IKindOfShape::shape_kind aKind;
GEOM::ListOfLong_var anInts; GEOM::ListOfLong_var anInts;
GEOM::ListOfDouble_var aDbls; GEOM::ListOfDouble_var aDbls;
if (aShape->_is_nil()) { if ( !CORBA::is_nil( shell ) ) {
MESSAGE ("Shape is NULL!!!"); GEOM::MeasureOpPtr anOp;
return false; anOp.take( myGeomGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() ) );
}
GEOM::GEOM_IMeasureOperations_var anOp = myGeomGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() );
// Detect kind of shape and parameters // Detect kind of shape and parameters
aKind = anOp->KindOfShape(aShape, anInts, aDbls); aKind = anOp->KindOfShape(shell, anInts, aDbls);
if ( !anOp->IsDone() ) { if ( anOp->IsDone() ) {
if ( anInts[0] == 1 )
ok = true;
else if ( anInts[0] == 2 )
ok = false;
}
else {
MESSAGE ("KindOfShape Operation is NOT DONE!!!"); MESSAGE ("KindOfShape Operation is NOT DONE!!!");
return false; }
}
else {
MESSAGE ("Shape is NULL!!!");
} }
if ( anInts[0] == 1 ) return ok;
return true;
else if ( anInts[0] == 2 )
return false;
return false;
} }
//================================================================================= //=================================================================================
@ -293,19 +278,22 @@ bool BuildGUI_SolidDlg::isClosed(int i)
//================================================================================= //=================================================================================
bool BuildGUI_SolidDlg::execute( ObjectList& objects ) bool BuildGUI_SolidDlg::execute( ObjectList& objects )
{ {
bool toCreateSingleSolid = GroupSolid->CheckButton1->isChecked();
GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
if ( toCreateSingleSolid ) { if ( GroupSolid->CheckButton1->isChecked() ) {
GEOM::GEOM_Object_var anObj = anOper->MakeSolidShells( myShells ); GEOM::ListOfGO_var objlist = new GEOM::ListOfGO();
objlist->length( myShells.count() );
for ( int i = 0; i < myShells.count(); i++ )
objlist[i] = myShells[i].copy();
GEOM::GEOM_Object_var anObj = anOper->MakeSolidShells( objlist.in() );
if ( !anObj->_is_nil() ) if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() ); objects.push_back( anObj._retn() );
} }
else { else {
for ( int i = 0, n = myShells.length(); i< n; i++ ) { for ( int i = 0, n = myShells.count(); i< n; i++ ) {
GEOM::GEOM_Object_var anObj = anOper->MakeSolidShell( myShells[ i ] ); GEOM::GEOM_Object_var anObj = anOper->MakeSolidShell( myShells[ i ].get() );
if ( !anObj->_is_nil() ) if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() ); objects.push_back( anObj._retn() );

View File

@ -27,7 +27,8 @@
#ifndef BUILDGUI_SOLIDDLG_H #ifndef BUILDGUI_SOLIDDLG_H
#define BUILDGUI_SOLIDDLG_H #define BUILDGUI_SOLIDDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel1Check; class DlgRef_1Sel1Check;
@ -51,13 +52,11 @@ protected:
private: private:
void Init(); void Init();
bool isClosed(int i); bool isClosed( GEOM::GEOM_Object_ptr shell );
void enterEvent( QEvent* ); void enterEvent( QEvent* );
private: private:
GEOM::ListOfGO myShells; QList<GEOM::GeomObjPtr> myShells;
bool myOkShells; /* to check when arguments is defined and
all shells are closed */
DlgRef_1Sel1Check* GroupSolid; DlgRef_1Sel1Check* GroupSolid;

View File

@ -119,7 +119,7 @@ void BuildGUI_WireDlg::Init()
GroupArgs->LineEdit1->setReadOnly( true ); GroupArgs->LineEdit1->setReadOnly( true );
GroupType->RadioButton1->setChecked(true); GroupType->RadioButton1->setChecked(true);
myOkEdgesAndWires = false; myEdgesAndWires.clear();
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
@ -158,14 +158,12 @@ void BuildGUI_WireDlg::ClickOnOk()
//================================================================================= //=================================================================================
bool BuildGUI_WireDlg::ClickOnApply() bool BuildGUI_WireDlg::ClickOnApply()
{ {
if ( !onAccept() || !myOkEdgesAndWires ) if ( !onAccept() )
return false; return false;
initName(); initName();
TypeButtonClicked(); TypeButtonClicked();
myMapToStudy.clear(); myEdgesAndWires.clear();
myEdgesAndWires.length(0);
myOkEdgesAndWires = false;
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
return true; return true;
} }
@ -196,82 +194,15 @@ void BuildGUI_WireDlg::TypeButtonClicked()
void BuildGUI_WireDlg::SelectionIntoArgument() void BuildGUI_WireDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
QString aString = ""; /* name of selection */
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); QList<TopAbs_ShapeEnum> types;
SALOME_ListIO aSelList; types << TopAbs_EDGE << TopAbs_WIRE;
aSelMgr->selectedObjects(aSelList); myEdgesAndWires = getSelected( types, -1 );
myOkEdgesAndWires = false; if ( !myEdgesAndWires.isEmpty() ) {
int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString); QString aName = myEdgesAndWires.count() > 1 ? QString( "%1_objects").arg( myEdgesAndWires.count() ) : GEOMBase::GetName( myEdgesAndWires[0].get() );
myEditCurrentArgument->setText( aName );
if ( nbSel == 0 ) {
myMapToStudy.clear();
return;
} }
TopAbs_ShapeEnum aNeedType = TopAbs_EDGE;
if (GroupType->RadioButton2->isChecked())
aNeedType = TopAbs_WIRE;
std::list<GEOM::GEOM_Object_var> aList; // subshapes list
TopoDS_Shape aShape;
for (SALOME_ListIteratorOfListIO anIt (aSelList); anIt.More(); anIt.Next()) {
TColStd_IndexedMapOfInteger aMap;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value() );
if ( !CORBA::is_nil(aSelectedObject) && GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
aSelMgr->GetIndexes( anIt.Value(), aMap );
if ( aMap.Extent() > 0 ) { // local selection
for (int ind = 1; ind <= aMap.Extent(); ind++) {
aString = aSelectedObject->GetName();
int anIndex = aMap(ind);
if ( aNeedType == TopAbs_EDGE )
aString += QString( ":edge_%1" ).arg( anIndex );
else
aString += QString( ":wire_%1" ).arg( anIndex );
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aString );
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
aList.push_back( aShapesOp->GetSubShape( aSelectedObject, anIndex ) );
myMapToStudy[aString] = aShapesOp->GetSubShape( aSelectedObject, anIndex );
}
else {
aList.push_back( aFindedObject ); // get Object from study
}
}
} else { // global selection
if ( aShape.ShapeType() == aNeedType ) {
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myEdgesAndWires);
} else {
aList.clear();
myEdgesAndWires.length(0);
}
}
}
}
// convert aList in listofgo
if ( aList.size() ) {
myEdgesAndWires.length( aList.size() );
int k = 0;
for ( std::list<GEOM::GEOM_Object_var>::iterator j = aList.begin(); j != aList.end(); j++ )
myEdgesAndWires[k++] = *j;
}
if ( myEdgesAndWires.length() > 1 )
aString = tr( "%1_objects" ).arg( myEdgesAndWires.length() );
if ( !myEdgesAndWires.length() ) {
aString = "";
myMapToStudy.clear();
}
myEditCurrentArgument->setText( aString );
myOkEdgesAndWires = true;
} }
@ -340,8 +271,7 @@ GEOM::GEOM_IOperations_ptr BuildGUI_WireDlg::createOperation()
//================================================================================= //=================================================================================
bool BuildGUI_WireDlg::isValid (QString& msg) bool BuildGUI_WireDlg::isValid (QString& msg)
{ {
bool ok = GroupArgs->SpinBox_DX->isValid(msg, !IsPreview()); return GroupArgs->SpinBox_DX->isValid(msg, !IsPreview()) && !myEdgesAndWires.isEmpty();
return myOkEdgesAndWires && ok;
} }
//================================================================================= //=================================================================================
@ -351,7 +281,13 @@ bool BuildGUI_WireDlg::isValid (QString& msg)
bool BuildGUI_WireDlg::execute (ObjectList& objects) bool BuildGUI_WireDlg::execute (ObjectList& objects)
{ {
GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
GEOM::GEOM_Object_var anObj = anOper->MakeWire(myEdgesAndWires, GroupArgs->SpinBox_DX->value());
GEOM::ListOfGO_var objlist = new GEOM::ListOfGO();
objlist->length( myEdgesAndWires.count() );
for ( int i = 0; i < myEdgesAndWires.count(); i++ )
objlist[i] = myEdgesAndWires[i].copy();
GEOM::GEOM_Object_var anObj = anOper->MakeWire(objlist.in(), GroupArgs->SpinBox_DX->value());
if (!anObj->_is_nil()) if (!anObj->_is_nil())
objects.push_back(anObj._retn()); objects.push_back(anObj._retn());
@ -365,5 +301,6 @@ bool BuildGUI_WireDlg::execute (ObjectList& objects)
//================================================================================= //=================================================================================
void BuildGUI_WireDlg::addSubshapesToStudy() void BuildGUI_WireDlg::addSubshapesToStudy()
{ {
addSubshapesToFather( myMapToStudy ); for ( int i = 0; i < myEdgesAndWires.count(); i++ )
GEOMBase::PublishSubObject( myEdgesAndWires[i].get() );
} }

View File

@ -27,7 +27,8 @@
#ifndef BUILDGUI_WIREDLG_H #ifndef BUILDGUI_WIREDLG_H
#define BUILDGUI_WIREDLG_H #define BUILDGUI_WIREDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel1Spin; class DlgRef_1Sel1Spin;
class DlgRef_3Radio; class DlgRef_3Radio;
@ -56,14 +57,11 @@ private:
void enterEvent( QEvent* ); void enterEvent( QEvent* );
private: private:
GEOM::ListOfGO myEdgesAndWires; QList<GEOM::GeomObjPtr> myEdgesAndWires;
bool myOkEdgesAndWires; /* to check when arguments is defined */
DlgRef_1Sel1Spin* GroupArgs; DlgRef_1Sel1Spin* GroupArgs;
DlgRef_3Radio* GroupType; DlgRef_3Radio* GroupType;
QMap<QString, GEOM::GEOM_Object_var> myMapToStudy;
private slots: private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();

View File

@ -774,6 +774,9 @@ QString GEOMBase::GetName( GEOM::GEOM_Object_ptr object )
{ {
QString name; QString name;
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() ); SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
if ( !CORBA::is_nil( object ) ) {
// 1. search if object is already published in the study
CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( object ); CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( object );
if ( study && strcmp( IOR.in(), "" ) != 0 ) { if ( study && strcmp( IOR.in(), "" ) != 0 ) {
_PTR(SObject) aSObj( study->studyDS()->FindObjectIOR( std::string( IOR.in() ) ) ); _PTR(SObject) aSObj( study->studyDS()->FindObjectIOR( std::string( IOR.in() ) ) );
@ -784,6 +787,25 @@ QString GEOMBase::GetName( GEOM::GEOM_Object_ptr object )
} }
} }
// 2. if object is not found in the study, try default name
if ( name.isEmpty() ) {
if ( object->IsMainShape() ) {
name = GetDefaultName( "geomObj" );
}
else {
GEOM::GEOM_Object_var mainShape = object->GetMainShape();
if ( !CORBA::is_nil( mainShape ) ) {
GEOM::ListOfLong_var indices = object->GetSubShapeIndices();
if ( indices->length() > 0 ) {
TopAbs_ShapeEnum type = (TopAbs_ShapeEnum)( object->GetShapeType() );
name = QString( "%1:%2_%3" ).arg( GetName( mainShape.in() ) )
.arg( TypeName( type ) ).arg( indices[0] );
}
}
}
}
}
return name; return name;
} }
@ -795,3 +817,72 @@ bool GEOMBase::IsShape( GEOM::GEOM_Object_ptr object )
{ {
return !object->_is_nil() && object->IsShape(); return !object->_is_nil() && object->IsShape();
} }
//=======================================================================
// function : TypeName()
// purpose : Get string representation for the shape type
//=======================================================================
QString GEOMBase::TypeName( TopAbs_ShapeEnum type )
{
QString name = "shape";
switch( type ) {
case TopAbs_COMPSOLID:
name = "compsolid"; break;
case TopAbs_COMPOUND:
name = "compound"; break;
case TopAbs_SOLID:
name = "solid"; break;
case TopAbs_SHELL:
name = "shell"; break;
case TopAbs_FACE:
name = "face"; break;
case TopAbs_WIRE:
name = "wire"; break;
case TopAbs_EDGE:
name = "edge"; break;
case TopAbs_VERTEX:
name = "vertex"; break;
default:
break;
}
return name;
}
//================================================================
// Function : GetEntry
// Purpose : Get study entry for the given object (if it is published)
//================================================================
QString GEOMBase::GetEntry( GEOM::GEOM_Object_ptr object )
{
QString entry;
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
if ( study && !CORBA::is_nil( object ) ) {
QString objIOR = GetIORFromObject( object );
if ( !objIOR.isEmpty() ) {
_PTR(SObject) SO( study->studyDS()->FindObjectIOR( objIOR.toLatin1().constData() ) );
if ( SO )
entry = SO->GetID().c_str();
}
}
return entry;
}
//================================================================
// Function : PublishSubObject
// Purpose : Publish sub-shape under the main object
//================================================================
void GEOMBase::PublishSubObject( GEOM::GEOM_Object_ptr object )
{
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
if ( study && !CORBA::is_nil( object ) ) {
_PTR(Study) studyDS = study->studyDS();
QString entry = GetEntry( object );
GEOM::GEOM_Object_var father = object->GetMainShape();
QString fatherEntry = GetEntry( father );
if ( entry.isEmpty() && !CORBA::is_nil( father ) && !fatherEntry.isEmpty() ) {
QString name = GetName( object );
GeometryGUI::GetGeomGen()->AddInStudy( GeometryGUI::ClientStudyToStudy( studyDS ),
object, name.toLatin1().data(), father.in() );
}
}
}

View File

@ -122,7 +122,17 @@ public :
/* Gets name of object */ /* Gets name of object */
static QString GetName( GEOM::GEOM_Object_ptr object ); static QString GetName( GEOM::GEOM_Object_ptr object );
/* Check if object has shape */
static bool IsShape( GEOM::GEOM_Object_ptr object ); static bool IsShape( GEOM::GEOM_Object_ptr object );
/* Get string representation of shape type */
static QString TypeName( TopAbs_ShapeEnum type );
/* Get study entry for the given object */
static QString GetEntry( GEOM::GEOM_Object_ptr object );
/* Publish sub-shape under the main object */
static void PublishSubObject( GEOM::GEOM_Object_ptr object );
}; };
#endif // GEOMBASE_H #endif // GEOMBASE_H

View File

@ -44,6 +44,7 @@
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <LightApp_DataOwner.h> #include <LightApp_DataOwner.h>
#include <SalomeApp_Tools.h> #include <SalomeApp_Tools.h>
#include <SALOME_ListIteratorOfListIO.hxx>
#include <SALOME_Prs.h> #include <SALOME_Prs.h>
@ -52,6 +53,7 @@
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
//To disable automatic genericobj management, the following line should be commented. //To disable automatic genericobj management, the following line should be commented.
//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
@ -982,11 +984,6 @@ QString GEOMBase_Helper::getPrefix( GEOM::GEOM_Object_ptr theObj ) const
if ( !myPrefix.isEmpty() || theObj->_is_nil() ) if ( !myPrefix.isEmpty() || theObj->_is_nil() )
return myPrefix; return myPrefix;
//TopoDS_Shape aShape;
//if ( !GEOMBase::GetShape( theObj, aShape ) )
// return "";
//
//long aType = aShape.ShapeType();
GEOM::shape_type aType = theObj->GetShapeType(); GEOM::shape_type aType = theObj->GetShapeType();
switch ( aType ) switch ( aType )
@ -1074,6 +1071,43 @@ GEOM::GEOM_Object_ptr GEOMBase_Helper::findObjectInFather (GEOM::GEOM_Object_ptr
return GEOM::GEOM_Object::_nil(); return GEOM::GEOM_Object::_nil();
} }
//================================================================
// Function : findObjectInFather
// Purpose : It should return an object if its founded in study or
// return Null object if the object is not founded
//================================================================
GEOM::GEOM_Object_ptr GEOMBase_Helper::findObjectInFather( GEOM::GEOM_Object_ptr theFather,
int theIndex )
{
GEOM::GEOM_Object_var object;
bool found = false;
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
if ( study ) {
_PTR(Study) studyDS = study->studyDS();
QString IOR = GEOMBase::GetIORFromObject( theFather );
_PTR(SObject) sobject( studyDS->FindObjectIOR( IOR.toLatin1().constData() ) );
if ( sobject ) {
_PTR(ChildIterator) it( studyDS->NewChildIterator( sobject ) );
for ( ; it->More() && !found; it->Next() ) {
GEOM::GEOM_Object_var cobject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( it->Value() ) );
if ( !CORBA::is_nil( cobject ) ) {
GEOM::ListOfLong_var indices = cobject->GetSubShapeIndices();
int length = indices->length();
for ( int i = 0; i < length && !found; i++ ) {
if ( indices[i] == theIndex ) {
object = cobject;
found = true;
}
}
}
}
}
}
return object._retn();
}
//================================================================ //================================================================
// Function : addSubshapesToStudy // Function : addSubshapesToStudy
// Purpose : Virtual method to add subshapes if needs // Purpose : Virtual method to add subshapes if needs
@ -1084,28 +1118,172 @@ void GEOMBase_Helper::addSubshapesToStudy()
} }
//================================================================ //================================================================
// Function : addSubshapesToFather // Function : getSelected
// Purpose : Method to add Father Subshapes to Study if it`s not exist // Purpose : Get selected object by specified type
//
// Returns valid object if only one object of the specified type is selected
// (no matter global or local selection is activated). If \a type is TopAbs_SHAPE,
// geometrical object of any valid type is expected.
//
// \param type type of the object to be obtained from selection
// \return selected geometrical object or nil object if selection is not satisfactory
//================================================================ //================================================================
void GEOMBase_Helper::addSubshapesToFather( QMap<QString, GEOM::GEOM_Object_var>& theMap ) GEOM::GeomObjPtr GEOMBase_Helper::getSelected( TopAbs_ShapeEnum type )
{ {
//GetStudyDS QList<TopAbs_ShapeEnum> types;
SalomeApp_Application* app = types << type;
dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); return getSelected( types );
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ); }
_PTR(Study) aDStudy = appStudy->studyDS();
for( QMap<QString, GEOM::GEOM_Object_var>::Iterator it = theMap.begin(); it != theMap.end(); it++ ) { //================================================================
GEOM::GEOM_Object_var aFatherObj = it.value()->GetMainShape(); // Function : getSelected
if ( !aFatherObj->_is_nil() ) { // Purpose : Get selected object by specified types
QString aFatherEntry = getEntry( aFatherObj ); //
if ( aFatherEntry != "") { // additional checking that object is valid 0020598 EDF 1191 // Returns valid object if only one object of the specified type is selected
GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aFatherObj, it.key().toLatin1().data() ); // (no matter global or local selection is activated). The list of allowed
//Add Object to study if its not exist // shape types is passed via \a types. If \a types includes TopAbs_SHAPE,
if ( aFindedObject->_is_nil() ) // geometrical object of any valid type is expected.
GeometryGUI::GetGeomGen()->AddInStudy(GeometryGUI::ClientStudyToStudy(aDStudy), //
it.value(), it.key().toLatin1().data(), aFatherObj ); // \param types list of allowed shape types for the objects to be obtained from selection
// \return selected geometrical object or nil object if selection is not satisfactory
//================================================================
GEOM::GeomObjPtr GEOMBase_Helper::getSelected( const QList<TopAbs_ShapeEnum>& types )
{
QList<GEOM::GeomObjPtr> selected = getSelected( types, 1 );
return selected.count() > 0 ? selected[0] : GEOM::GeomObjPtr();
}
//================================================================
// Function : getSelected
// Purpose : Get selected object(s) by specified type
//
// Returns list of selected objects if selection satisfies specifies selection options.
// (no matter global or local selection is activated). If \a type is TopAbs_SHAPE,
// geometrical objects of any valid type are expected.
//
// The \a type parameter specifies allowed type of the object(s) being selected.
// The \a count parameter specifies exact number of the objects to be retrieved from selection.
// The \a strict parameter specifies policy being applied to the selection.
// If \a count < 0, then any number of the selected objects is valid (including 0).
// In this case, if \a strict is \c true (default), all selected objects should satisfy
// the specified \a type.
// If \a count > 0, only specified number of the objects is retrieved from the selection.
// In this case, if \a strict is \c true (default), function returns empty list if total number of selected
// objects does not correspond to the \a count parameter. Otherwise (if \a strict is \c false),
// function returns valid list of objects if at least \a count objects satisfy specified \a type.
//
// \param type type of the object(s) to be obtained from selection
// \param count number of items to be retrieved from selection
// \param strict selection policy
// \return list of selected geometrical objects or empty list if selection is not satisfactory
//================================================================
QList<GEOM::GeomObjPtr> GEOMBase_Helper::getSelected( TopAbs_ShapeEnum type, int count, bool strict )
{
QList<TopAbs_ShapeEnum> types;
types << type;
return getSelected( types, count, strict );
}
static bool typeInList( TopAbs_ShapeEnum type, const QList<TopAbs_ShapeEnum>& types )
{
bool ok = false;
for ( int i = 0; i < types.count() && !ok; i++ )
ok = types[i] == TopAbs_SHAPE || types[i] == type;
return ok;
}
//================================================================
// Function : getSelected
// Purpose : Get selected objects by specified types
//
// Returns list of selected objects if selection satisfies specifies selection options.
// (no matter global or local selection is activated). If \a types includes TopAbs_SHAPE,
// geometrical objects of any valid type are expected.
//
// The \a types parameter specifies allowed types of the object(s) being selected.
// The \a count parameter specifies exact number of the objects to be retrieved from selection.
// The \a strict parameter specifies policy being applied to the selection.
// If \a count < 0, then any number of the selected objects is valid (including 0).
// In this case, if \a strict is \c true (default), all selected objects should satisfy
// the specified \a type.
// If \a count > 0, only specified number of the objects is retrieved from the selection.
// In this case, if \a strict is \c true (default), function returns empty list if total number of selected
// objects does not correspond to the \a count parameter. Otherwise (if \a strict is \c false),
// function returns valid list of objects if at least \a count objects satisfy specified \a type.
//
// \param types list of allowed shape types for the objects to be obtained from selection
// \param count number of items to be retrieved from selection
// \param strict selection policy
// \return list of selected geometrical objects or empty list if selection is not satisfactory
//================================================================
QList<GEOM::GeomObjPtr> GEOMBase_Helper::getSelected( const QList<TopAbs_ShapeEnum>& types, int count, bool strict )
{
SUIT_Session* session = SUIT_Session::session();
QList<GEOM::GeomObjPtr> result;
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
if ( app ) {
LightApp_SelectionMgr* selMgr = app->selectionMgr();
if ( selMgr ) {
SALOME_ListIO selected;
selMgr->selectedObjects( selected );
SALOME_ListIteratorOfListIO it( selected );
bool stopped = false;
for ( ; it.More() && !stopped; it.Next() ) {
Handle(SALOME_InteractiveObject) IO = it.Value();
GEOM::GeomObjPtr object = GEOMBase::ConvertIOinGEOMObject( IO );
if ( object ) {
TColStd_IndexedMapOfInteger subShapes;
selMgr->GetIndexes( IO, subShapes );
int nbSubShapes = subShapes.Extent();
if ( nbSubShapes == 0 ) {
// global selection
if ( typeInList( (TopAbs_ShapeEnum)(object->GetShapeType()), types ) ) {
result << object;
if ( count > 0 ) {
if ( strict && result.count() > count ) {
result.clear();
stopped = true;
}
else if ( !strict && result.count() == count )
stopped = true;
}
}
else if ( strict ) {
result.clear();
stopped = true;
}
}
else {
// local selection
for ( int i = 1; i <= nbSubShapes && !stopped; i++ ) {
int idx = subShapes( i );
GEOM::GeomObjPtr subShape = findObjectInFather( object.get(), idx );
if ( !subShape ) {
// sub-shape is not yet published in the study
GEOM::ShapesOpPtr shapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
subShape.take( shapesOp->GetSubShape( object.get(), idx ) ); // take ownership!
}
if ( typeInList( (TopAbs_ShapeEnum)(subShape->GetShapeType()), types ) ) {
result << subShape;
if ( count > 0 ) {
if ( strict && result.count() > count ) {
result.clear();
stopped = true;
}
else if ( !strict && result.count() == count )
stopped = true;
}
}
else if ( strict ) {
result.clear();
stopped = true;
} }
} }
} }
} }
}
}
}
return result;
}

View File

@ -28,6 +28,7 @@
#define GEOMBASE_HELPER_H #define GEOMBASE_HELPER_H
#include "GEOM_GEOMBase.hxx" #include "GEOM_GEOMBase.hxx"
#include "GEOM_GenericObjPtr.h"
#include <GEOM_Displayer.h> #include <GEOM_Displayer.h>
#include <SALOME_ListIO.hxx> #include <SALOME_ListIO.hxx>
@ -166,9 +167,13 @@ protected:
virtual void addSubshapesToStudy(); virtual void addSubshapesToStudy();
GEOM::GEOM_Object_ptr findObjectInFather( GEOM::GEOM_Object_ptr theFather, const QString& theName ); GEOM::GEOM_Object_ptr findObjectInFather( GEOM::GEOM_Object_ptr theFather, const QString& theName );
//This Metod to find SubObject in theFather Object by Name (theName) GEOM::GEOM_Object_ptr findObjectInFather( GEOM::GEOM_Object_ptr theFather, int theIndex );
// These methods are used to find published sub-object (sub-shape) in the parent object (main shape)
void addSubshapesToFather( QMap<QString, GEOM::GEOM_Object_var>& theMap ); GEOM::GeomObjPtr getSelected( TopAbs_ShapeEnum type );
GEOM::GeomObjPtr getSelected( const QList<TopAbs_ShapeEnum>& types );
QList<GEOM::GeomObjPtr> getSelected( TopAbs_ShapeEnum type, int count, bool strict = true );
QList<GEOM::GeomObjPtr> getSelected( const QList<TopAbs_ShapeEnum>& types, int count, bool strict = true );
void SetIsPreview(const bool thePreview) {isPreview = thePreview;} void SetIsPreview(const bool thePreview) {isPreview = thePreview;}
bool IsPreview() {return isPreview;} bool IsPreview() {return isPreview;}

View File

@ -0,0 +1,33 @@
// Copyright (C) 2007-2010 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
//
// File : GEOM_GenericObjPtr.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
#include "GEOM_GenericObjPtr.h"
namespace GEOM
{
template<> bool GenericObjPtr<GEOM::GEOM_Object>::isSame( GEOM::GEOM_Object_ptr theLeft, GEOM::GEOM_Object_ptr theRight )
{
return !CORBA::is_nil( theLeft ) && !CORBA::is_nil( theRight ) && theLeft->IsSame( theRight );
}
}

View File

@ -0,0 +1,234 @@
// Copyright (C) 2007-2010 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
//
// File : GEOM_GenericObjPtr.h
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
#ifndef GEOM_GenericObjPtr_H
#define GEOM_GenericObjPtr_H
#include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(GEOM_Gen)
namespace GEOM
{
/*!
\class GenericObjPtr
\brief A smart pointer for the SALOME GenericObj interface.
This class can be used in conjunction with the references to the CORBA objects which
interfaces are inherited from the SALOME::GenericObj CORBA interface.
The smart pointer class automatically invokes Register() / Destroy() functions of th
interface in order to prevent memory leaks and other such problems caused by improper
usage of the CORBA references.
Smart pointers can be easily copied, stored within class as data members, passed to the
functions requiring native CORBA reference as parameters, etc.
Usage:
- If you want to assign the smart pointer to the CORBA _var type variable, use copy()
function to make a copy of the stored CORBA object. Otherwise you might cause Segmentation
Fault error.
- To pass the smart pointer to the function that requires CORBA _ptr type parameter,
use get() function.
- If you want to take an ownership on the CORBA object, use take() function.
In case of SALOME Generic object this is useful when some function returns newly created
object that should be removed by the caller as soon as the object is no more required.
For example, function GetSubShape() of the GEOM_IShapesOperation interface always creates
new servant object and returns new object reference to it. If the object is not published
in the study, it has to be destroyed and the coresponding servant should be deleted.
Examples:
\code
typedef GEOM::GenericObjPtr<MyInterface> MyIPtr;
void MyInterface_ptr foo();
void MyInterface_ptr bar( MyInterface_ptr p );
MyIPtr v1; // create empty (nil) pointer
MyIPtr v2 = foo(); // get some CORBA reference and store it within the smart pointer
v1 = v2; // copy smart pointer (reference counter is incremented)
v2 = bar( v1.get() ); // pass smart pointer to the function
MyInterface_var var = v2.copy(); // initialize _var variable with the smart pointer contents
v1.take( foo() ); // take ownership on the newly created object
\endcode
*/
template <typename TInterface> class GenericObjPtr
{
typedef typename TInterface::_var_type TInterfaceVar;
typedef typename TInterface::_ptr_type TInterfacePtr;
private:
TInterfaceVar myObject;
private:
//! Increment counter for the object.
void Register()
{
if ( !CORBA::is_nil( this->myObject ) )
this->myObject->Register();
}
//! Decrement counter for the object.
void Destroy()
{
if ( !CORBA::is_nil( this->myObject ) ) {
this->myObject->Destroy();
this->myObject = TInterface::_nil();
}
}
public:
//! Initialize pointer to nil generic object reference.
GenericObjPtr()
{}
//! Initialize pointer to the given generic object reference.
GenericObjPtr( TInterfacePtr theObject )
{
this->myObject = TInterface::_duplicate( theObject );
this->Register();
}
//! Initialize pointer with a new reference to the same object referenced by given pointer.
GenericObjPtr( const GenericObjPtr& thePointer )
{
this->myObject = thePointer.myObject;
this->Register();
}
//! Destroy pointer and remove the reference to the object.
~GenericObjPtr()
{
this->Destroy();
}
//! Assign object to reference and remove reference to an old object.
GenericObjPtr& operator=( TInterfacePtr theObject )
{
this->Destroy();
this->myObject = TInterface::_duplicate( theObject );
this->Register();
return *this;
}
//! Assign object to reference and remove reference to an old object.
GenericObjPtr& operator=( const GenericObjPtr& thePointer )
{
this->Destroy();
this->myObject = thePointer.myObject;
this->Register();
return *this;
}
static bool isSame( TInterfacePtr theLeft, TInterfacePtr theRight )
{
return theLeft->_is_equivalent( theRight );
}
//! Check equivalence
bool operator==( TInterfacePtr theObject )
{
return isSame( this->myObject, theObject );
}
//! Check equivalence
bool operator==( const GenericObjPtr& thePointer )
{
return isSame( this->myObject, thePointer.get() );;
}
//! Check difference
bool operator!=( TInterfacePtr theObject )
{
return !isSame( this->myObject, theObject );
}
//! Check difference
bool operator!=( const GenericObjPtr& thePointer )
{
return !isSame( this->myObject, thePointer.get() );;
}
//! Provides normal pointer target member access using operator ->.
TInterfacePtr operator->() const
{
return this->get();
}
//! Check validity of the pointer.
operator bool() const
{
return !this->isNull();
}
//! Initialize pointer to the given generic object reference and take ownership on it.
void take( TInterfacePtr theObject )
{
this->Destroy();
this->myObject = TInterface::_duplicate( theObject );
}
//! Get the contained object.
TInterfacePtr get() const
{
return this->myObject;
}
//! Make the copy of the contained object and return it (caller becomes owner of the CORBA reference).
TInterfacePtr copy() const
{
return TInterface::_duplicate( this->myObject );
}
//! Check if pointer is null.
bool isNull() const
{
return CORBA::is_nil( this->myObject );
}
//! Nullify pointer.
void nullify()
{
this->Destroy();
}
};
typedef GenericObjPtr<GEOM::GEOM_Object> GeomObjPtr;
typedef GenericObjPtr<GEOM::GEOM_IBasicOperations> BasicOpPtr;
typedef GenericObjPtr<GEOM::GEOM_ITransformOperations> TransformOpPtr;
typedef GenericObjPtr<GEOM::GEOM_I3DPrimOperations> I3DPrimOpPtr;
typedef GenericObjPtr<GEOM::GEOM_IShapesOperations> ShapesOpPtr;
typedef GenericObjPtr<GEOM::GEOM_IBlocksOperations> BlocksOpPtr;
typedef GenericObjPtr<GEOM::GEOM_IBooleanOperations> BooleanOpPtr;
typedef GenericObjPtr<GEOM::GEOM_ICurvesOperations> CurvesOpPtr;
typedef GenericObjPtr<GEOM::GEOM_ILocalOperations> LocalOpPtr;
typedef GenericObjPtr<GEOM::GEOM_IHealingOperations> HealingOpPtr;
typedef GenericObjPtr<GEOM::GEOM_IInsertOperations> InsertOpPtr;
typedef GenericObjPtr<GEOM::GEOM_IMeasureOperations> MeasureOpPtr;
typedef GenericObjPtr<GEOM::GEOM_IGroupOperations> GroupOpPtr;
typedef GenericObjPtr<GEOM::GEOM_IAdvancedOperations> AdvancedOpPtr;
template<> bool GenericObjPtr<GEOM::GEOM_Object>::isSame( GEOM::GEOM_Object_ptr theLeft, GEOM::GEOM_Object_ptr theRight );
}
#endif // GEOM_GenericObjPtr_H

View File

@ -33,13 +33,15 @@ salomeinclude_HEADERS = \
GEOMBase_Skeleton.h \ GEOMBase_Skeleton.h \
GEOMBase_Helper.h \ GEOMBase_Helper.h \
GEOM_Operation.h \ GEOM_Operation.h \
GEOM_GEOMBase.hxx GEOM_GEOMBase.hxx \
GEOM_GenericObjPtr.h
dist_libGEOMBase_la_SOURCES = \ dist_libGEOMBase_la_SOURCES = \
GEOMBase.cxx \ GEOMBase.cxx \
GEOMBase_Skeleton.cxx \ GEOMBase_Skeleton.cxx \
GEOMBase_Helper.cxx \ GEOMBase_Helper.cxx \
GEOM_Operation.cxx GEOM_Operation.cxx \
GEOM_GenericObjPtr.cxx
MOC_FILES = \ MOC_FILES = \
GEOMBase_Skeleton_moc.cxx GEOMBase_Skeleton_moc.cxx

View File

@ -105,15 +105,6 @@ void GenerationGUI_FillingDlg::Init()
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly( true );
myMinDeg = 2;
myMaxDeg = 5;
myTol3D = 0.0001;
myTol2D = 0.0001;
myNbIter = 0;
myMethod = 0;
myIsApprox = false;
myOkCompound = false;
globalSelection( GEOM_COMPOUND ); globalSelection( GEOM_COMPOUND );
int SpecificStep1 = 1; int SpecificStep1 = 1;
@ -125,11 +116,11 @@ void GenerationGUI_FillingDlg::Init()
initSpinBox( GroupPoints->SpinBox4, 1, MAX_NUMBER, SpecificStep1 ); initSpinBox( GroupPoints->SpinBox4, 1, MAX_NUMBER, SpecificStep1 );
initSpinBox( GroupPoints->SpinBox5, 0.00001, 10000.0, SpecificStep2, "len_tol_precision" ); initSpinBox( GroupPoints->SpinBox5, 0.00001, 10000.0, SpecificStep2, "len_tol_precision" );
GroupPoints->SpinBox1->setValue( myMinDeg ); GroupPoints->SpinBox1->setValue( 2 );
GroupPoints->SpinBox2->setValue( myTol2D ); GroupPoints->SpinBox2->setValue( 0.0001 );
GroupPoints->SpinBox3->setValue( myNbIter ); GroupPoints->SpinBox3->setValue( 0 );
GroupPoints->SpinBox4->setValue( myMaxDeg ); GroupPoints->SpinBox4->setValue( 5 );
GroupPoints->SpinBox5->setValue( myTol3D ); GroupPoints->SpinBox5->setValue( 0.0001 );
GroupPoints->ComboBox1->addItem(tr("GEOM_FILLING_DEFAULT")); GroupPoints->ComboBox1->addItem(tr("GEOM_FILLING_DEFAULT"));
GroupPoints->ComboBox1->addItem(tr("GEOM_FILLING_USEORI")); GroupPoints->ComboBox1->addItem(tr("GEOM_FILLING_USEORI"));
@ -140,7 +131,6 @@ void GenerationGUI_FillingDlg::Init()
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(MethodChanged())); connect( GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(MethodChanged()));
@ -208,37 +198,19 @@ void GenerationGUI_FillingDlg::SelectionIntoArgument()
erasePreview(); erasePreview();
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPoints->LineEdit1)
myOkCompound = false;
return;
}
// nbSel == 1
GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( CORBA::is_nil( aSelectedObject ) )
return;
if (myEditCurrentArgument == GroupPoints->LineEdit1) { if (myEditCurrentArgument == GroupPoints->LineEdit1) {
TopoDS_Shape S; myCompound = getSelected( TopAbs_COMPOUND );
myOkCompound = false; if ( myCompound ) {
if ( myCompound->GetMaxShapeType() < GEOM::WIRE || myCompound->GetMinShapeType() > GEOM::EDGE ) {
if (GEOMBase::GetShape(aSelectedObject, S) && S.ShapeType() == TopAbs_COMPOUND) { myCompound.nullify();
// myCompound should be a compound of edges }
for (TopoDS_Iterator it (S); it.More(); it.Next()) else {
if ( it.Value().ShapeType() != TopAbs_EDGE && QString aName = GEOMBase::GetName( myCompound.get() );
it.Value().ShapeType() != TopAbs_WIRE ) myEditCurrentArgument->setText( aName );
return; }
myCompound = aSelectedObject;
myOkCompound = true;
} }
} }
myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
displayPreview(); displayPreview();
} }
@ -260,20 +232,6 @@ void GenerationGUI_FillingDlg::SetEditCurrentArgument()
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GenerationGUI_FillingDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 ) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -305,19 +263,6 @@ void GenerationGUI_FillingDlg::enterEvent( QEvent* )
//================================================================================= //=================================================================================
void GenerationGUI_FillingDlg::ValueChangedInSpinBox( double newValue ) void GenerationGUI_FillingDlg::ValueChangedInSpinBox( double newValue )
{ {
QObject* send = (QObject*)sender();
if ( send == GroupPoints->SpinBox1 )
myMinDeg = int( newValue );
else if ( send == GroupPoints->SpinBox2 )
myTol2D = newValue;
else if ( send == GroupPoints->SpinBox3 )
myNbIter = int(newValue);
else if ( send == GroupPoints->SpinBox4 )
myMaxDeg = int(newValue);
else if ( send == GroupPoints->SpinBox5 )
myTol3D = newValue;
displayPreview(); displayPreview();
} }
@ -327,7 +272,6 @@ void GenerationGUI_FillingDlg::ValueChangedInSpinBox( double newValue )
//================================================================================= //=================================================================================
void GenerationGUI_FillingDlg::MethodChanged() void GenerationGUI_FillingDlg::MethodChanged()
{ {
myMethod = GroupPoints->ComboBox1->currentIndex();
displayPreview(); displayPreview();
} }
@ -337,7 +281,6 @@ void GenerationGUI_FillingDlg::MethodChanged()
//================================================================================= //=================================================================================
void GenerationGUI_FillingDlg::ApproxChanged() void GenerationGUI_FillingDlg::ApproxChanged()
{ {
myIsApprox = GroupPoints->CheckBox1->isChecked();
displayPreview(); displayPreview();
} }
@ -357,14 +300,13 @@ GEOM::GEOM_IOperations_ptr GenerationGUI_FillingDlg::createOperation()
//================================================================================= //=================================================================================
bool GenerationGUI_FillingDlg::isValid( QString& msg ) bool GenerationGUI_FillingDlg::isValid( QString& msg )
{ {
bool ok = true; bool ok = GroupPoints->SpinBox1->isValid( msg, !IsPreview() ) &&
ok = GroupPoints->SpinBox1->isValid( msg, !IsPreview() ) && ok; GroupPoints->SpinBox2->isValid( msg, !IsPreview() ) &&
ok = GroupPoints->SpinBox2->isValid( msg, !IsPreview() ) && ok; GroupPoints->SpinBox3->isValid( msg, !IsPreview() ) &&
ok = GroupPoints->SpinBox3->isValid( msg, !IsPreview() ) && ok; GroupPoints->SpinBox4->isValid( msg, !IsPreview() ) &&
ok = GroupPoints->SpinBox4->isValid( msg, !IsPreview() ) && ok; GroupPoints->SpinBox5->isValid( msg, !IsPreview() ) &&
ok = GroupPoints->SpinBox5->isValid( msg, !IsPreview() ) && ok; myCompound;
return ok;
return myOkCompound > 0 && ok;
} }
//================================================================================= //=================================================================================
@ -386,8 +328,14 @@ bool GenerationGUI_FillingDlg::execute( ObjectList& objects )
} }
GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object_var anObj =
anOper->MakeFilling( myCompound, myMinDeg, myMaxDeg, myTol2D, myTol3D, anOper->MakeFilling( myCompound.get(),
myNbIter, aMethod, myIsApprox ); GroupPoints->SpinBox1->value(),
GroupPoints->SpinBox4->value(),
GroupPoints->SpinBox2->value(),
GroupPoints->SpinBox5->value(),
GroupPoints->SpinBox3->value(),
aMethod,
GroupPoints->CheckBox1->isChecked() );
if ( !anObj->_is_nil() ) if ( !anObj->_is_nil() )
{ {
if ( !IsPreview() ) if ( !IsPreview() )

View File

@ -27,7 +27,8 @@
#ifndef GENERATIONGUI_FILLINGDLG_H #ifndef GENERATIONGUI_FILLINGDLG_H
#define GENERATIONGUI_FILLINGDLG_H #define GENERATIONGUI_FILLINGDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel5Spin1Check; class DlgRef_1Sel5Spin1Check;
@ -54,23 +55,13 @@ private:
void enterEvent( QEvent* ); void enterEvent( QEvent* );
private: private:
GEOM::GEOM_Object_var myCompound; /* compound of curves */ GEOM::GeomObjPtr myCompound; /* compound of curves */
Standard_Integer myMinDeg;
Standard_Integer myMaxDeg;
Standard_Real myTol3D;
Standard_Real myTol2D;
Standard_Integer myNbIter;
bool myIsApprox;
int myMethod;
bool myOkCompound; /* to check when curv. compound is defined */
DlgRef_1Sel5Spin1Check* GroupPoints; DlgRef_1Sel5Spin1Check* GroupPoints;
private slots: private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ValueChangedInSpinBox( double ); void ValueChangedInSpinBox( double );

View File

@ -114,8 +114,8 @@ void GenerationGUI_PipeDlg::Init()
GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText(""); GroupPoints->LineEdit2->setText("");
GroupPoints->LineEdit3->setText(""); GroupPoints->LineEdit3->setText("");
myPath = myVec = GEOM::GEOM_Object::_nil(); myPath.nullify();
myOkBase = myOkPath = myOkVec = false; myVec.nullify();
GroupPoints->CheckButton1->setEnabled(false); GroupPoints->CheckButton1->setEnabled(false);
@ -129,10 +129,6 @@ void GenerationGUI_PipeDlg::Init()
connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(SelectionTypeButtonClicked())); connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(SelectionTypeButtonClicked()));
initName(tr("GEOM_PIPE")); initName(tr("GEOM_PIPE"));
@ -155,27 +151,27 @@ void GenerationGUI_PipeDlg::ConstructorsClicked( int constructorId )
{ {
erasePreview(); erasePreview();
switch (constructorId) switch (constructorId) {
{
case 0: case 0:
{
GroupPoints->TextLabel3->hide(); GroupPoints->TextLabel3->hide();
GroupPoints->PushButton3->hide(); GroupPoints->PushButton3->hide();
GroupPoints->LineEdit3->hide(); GroupPoints->LineEdit3->hide();
GroupPoints->PushButton1->click();
break; break;
}
case 1: case 1:
{
GroupPoints->TextLabel3->show(); GroupPoints->TextLabel3->show();
GroupPoints->PushButton3->show(); GroupPoints->PushButton3->show();
GroupPoints->LineEdit3->show(); GroupPoints->LineEdit3->show();
break; break;
default:
break;
} }
}
qApp->processEvents(); qApp->processEvents();
updateGeometry(); updateGeometry();
resize(100,100); resize(100,100);
SelectionIntoArgument();
displayPreview(); displayPreview();
} }
@ -197,7 +193,7 @@ void GenerationGUI_PipeDlg::SelectionTypeButtonClicked()
} }
if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
myOkPath = false; myPath.nullify();
} }
displayPreview(); displayPreview();
} }
@ -237,109 +233,48 @@ void GenerationGUI_PipeDlg::SelectionIntoArgument()
{ {
erasePreview(); erasePreview();
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
if (myEditCurrentArgument == GroupPoints->LineEdit1) myOkBase = false;
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myOkPath = false;
else if (myEditCurrentArgument == GroupPoints->LineEdit3) myOkVec = false;
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() < 1)
return;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
QString aName = GEOMBase::GetName(aSelectedObject);
if ( aSelectedObject->_is_nil() )
return;
TopoDS_Shape S;
if (!GEOMBase::GetShape(aSelectedObject, S))
return;
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
myOkBase = false; myBaseObjects.clear();
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myBaseObjects, true); QList<GEOM::GeomObjPtr> objects = getSelected( TopAbs_SHAPE, -1 );
if (aSelList.Extent() > 1) for ( int i = 0; i < objects.count(); i++ ) {
aName = QString( "%1_objects").arg( aSelList.Extent() ); GEOM::shape_type stype = objects[i]->GetMaxShapeType();
GEOM::shape_type maxallowed = getConstructorId() == 1 ? GEOM::FACE : GEOM::SHELL;
if ( aSelList.Extent() > 0 ) { GEOM::shape_type minallowed = getConstructorId() == 1 ? GEOM::EDGE : GEOM::VERTEX;
// check base shapes if ( stype < maxallowed || stype > minallowed )
for (int i=0; i < myBaseObjects.length(); i++) { continue;
GEOMBase::GetShape(myBaseObjects[i], S); myBaseObjects << objects[i];
if (S.ShapeType() == TopAbs_COMPSOLID ||
/*S.ShapeType() == TopAbs_COMPOUND ||*/
S.ShapeType() == TopAbs_SOLID ||
S.ShapeType() == TopAbs_SHAPE)
return;
if ( getConstructorId() == 1 &&
(S.ShapeType() == TopAbs_SHELL ||
S.ShapeType() == TopAbs_VERTEX))
return;
} }
} if ( !myBaseObjects.isEmpty() ) {
QString aName = myBaseObjects.count() > 1 ? QString( "%1_objects").arg( myBaseObjects.count() ) : GEOMBase::GetName( myBaseObjects[0].get() );
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
myOkBase = true; }
} else if (myEditCurrentArgument == GroupPoints->LineEdit2 || }
myEditCurrentArgument == GroupPoints->LineEdit3) { else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myEditCurrentArgument == GroupPoints->LineEdit2 ? myOkPath = false : myOkVec = false; QList<TopAbs_ShapeEnum> types;
bool myOk = false; types << TopAbs_EDGE << TopAbs_WIRE;
myPath = getSelected( types );
if (myEditCurrentArgument == GroupPoints->LineEdit2 && !GroupPoints->CheckButton1->isChecked() ){ if ( myPath ) {
myPath = aSelectedObject; QString aName = GEOMBase::GetName( myPath.get() );
myOkPath = true;
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
} else { if ( getConstructorId() == 1 && !myVec )
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) {
int anIndex = aMap(1);
aName.append(":edge_" + QString::number(anIndex));
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if (aFindedObject->_is_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp =
getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
myOk = true;
} else { // get Object from study
aSelectedObject = aFindedObject;
myOk = true;
}
} else {
myOk = true;
if (S.ShapeType() != TopAbs_EDGE) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
myOk = false;
}
}
if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myPath = aSelectedObject;
myOkPath = myOk;
} else if (myEditCurrentArgument == GroupPoints->LineEdit3) {
myVec = aSelectedObject;
myOkVec = myOk;
}
myEditCurrentArgument->setText(aName);
if (myOkPath) {
if (!myOkBase)
GroupPoints->PushButton1->click();
else if (!myOkVec)
GroupPoints->PushButton3->click(); GroupPoints->PushButton3->click();
} else if (myOkVec) { else if ( myBaseObjects.isEmpty() )
if (!myOkBase)
GroupPoints->PushButton1->click(); GroupPoints->PushButton1->click();
else if (!myOkPath) }
}
else if (myEditCurrentArgument == GroupPoints->LineEdit3) {
myVec = getSelected( TopAbs_EDGE );
if ( myVec ) {
QString aName = GEOMBase::GetName( myVec.get() );
myEditCurrentArgument->setText( aName );
if ( myBaseObjects.isEmpty() )
GroupPoints->PushButton1->click();
else if ( !myPath )
GroupPoints->PushButton2->click(); GroupPoints->PushButton2->click();
} }
} }
}
displayPreview(); displayPreview();
} }
@ -395,26 +330,6 @@ void GenerationGUI_PipeDlg::SetEditCurrentArgument()
displayPreview(); displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GenerationGUI_PipeDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if (send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2 ||
send == GroupPoints->LineEdit3) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
if (send == GroupPoints->LineEdit2)
GroupPoints->CheckButton1->setEnabled(true);
else
GroupPoints->CheckButton1->setEnabled(false);
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -453,12 +368,18 @@ GEOM::GEOM_IOperations_ptr GenerationGUI_PipeDlg::createOperation()
//================================================================================= //=================================================================================
bool GenerationGUI_PipeDlg::isValid (QString&) bool GenerationGUI_PipeDlg::isValid (QString&)
{ {
bool ok = false;
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0 : case 0 :
return myOkBase && myOkPath; ok = !myBaseObjects.isEmpty() && myPath;
break;
case 1 : case 1 :
return myOkBase && myOkPath && myOkVec; ok = !myBaseObjects.isEmpty() && myPath && myVec;
break;
default:
break;
} }
return ok;
} }
//================================================================================= //=================================================================================
@ -467,18 +388,17 @@ bool GenerationGUI_PipeDlg::isValid (QString&)
//================================================================================= //=================================================================================
bool GenerationGUI_PipeDlg::execute (ObjectList& objects) bool GenerationGUI_PipeDlg::execute (ObjectList& objects)
{ {
GEOM::GEOM_Object_var anObj, aBase; GEOM::GEOM_Object_var anObj;
GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation()); GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
for (int i=0; i < myBaseObjects.length(); i++) { for (int i = 0; i < myBaseObjects.count(); i++) {
aBase = myBaseObjects[i];
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0 : case 0 :
anObj = anOper->MakePipe(aBase, myPath); anObj = anOper->MakePipe(myBaseObjects[i].get(), myPath.get());
break; break;
case 1 : case 1 :
anObj = anOper->MakePipeBiNormalAlongVector(aBase, myPath, myVec); anObj = anOper->MakePipeBiNormalAlongVector(myBaseObjects[i].get(), myPath.get(), myVec.get());
break; break;
} }
@ -494,11 +414,8 @@ bool GenerationGUI_PipeDlg::execute (ObjectList& objects)
//================================================================================= //=================================================================================
void GenerationGUI_PipeDlg::addSubshapesToStudy() void GenerationGUI_PipeDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap; GEOMBase::PublishSubObject( myPath.get() );
GEOMBase::PublishSubObject( myVec.get() );
objMap[GroupPoints->LineEdit2->text()] = myPath;
addSubshapesToFather(objMap);
} }
//================================================================================= //=================================================================================
@ -507,5 +424,5 @@ void GenerationGUI_PipeDlg::addSubshapesToStudy()
//================================================================================= //=================================================================================
bool GenerationGUI_PipeDlg::extractPrefix() const bool GenerationGUI_PipeDlg::extractPrefix() const
{ {
return myBaseObjects.length() > 1; return myBaseObjects.count() > 1;
} }

View File

@ -27,7 +27,8 @@
#ifndef GENERATIONGUI_PIPEDLG_H #ifndef GENERATIONGUI_PIPEDLG_H
#define GENERATIONGUI_PIPEDLG_H #define GENERATIONGUI_PIPEDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_3Sel1Check; class DlgRef_3Sel1Check;
@ -56,12 +57,9 @@ private:
void enterEvent( QEvent* ); void enterEvent( QEvent* );
private: private:
GEOM::ListOfGO myBaseObjects; /* Base shapes */ QList<GEOM::GeomObjPtr> myBaseObjects; /* Base shapes */
GEOM::GEOM_Object_var myPath; /* Shape, defining the path */ GEOM::GeomObjPtr myPath; /* Shape, defining the path */
GEOM::GEOM_Object_var myVec; /* Vector, defining the constant binormal direction */ GEOM::GeomObjPtr myVec; /* Vector, defining the constant binormal direction */
bool myOkBase;
bool myOkPath;
bool myOkVec; /* to check when arguments are defined */
DlgRef_3Sel1Check* GroupPoints; DlgRef_3Sel1Check* GroupPoints;
@ -69,7 +67,6 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ConstructorsClicked( int ); void ConstructorsClicked( int );

View File

@ -54,8 +54,7 @@
//================================================================================= //=================================================================================
GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWidget* parent, GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl) bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl), : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
myInitial(true)
{ {
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PRISM"))); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PRISM")));
@ -72,7 +71,6 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWi
mainFrame()->RadioButton3->setIcon(image3); mainFrame()->RadioButton3->setIcon(image3);
mainFrame()->RadioButton1->setChecked(true); mainFrame()->RadioButton1->setChecked(true);
myBothway = myBothway2 = myBothway3 = false;
GroupPoints = new DlgRef_2Sel1Spin2Check(centralWidget()); GroupPoints = new DlgRef_2Sel1Spin2Check(centralWidget());
GroupPoints->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV")); GroupPoints->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV"));
@ -84,7 +82,6 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWi
GroupPoints->LineEdit1->setReadOnly(true); GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly(true); GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->CheckButton1->setText(tr("GEOM_BOTHWAY")); GroupPoints->CheckButton1->setText(tr("GEOM_BOTHWAY"));
GroupPoints->CheckButton1->setChecked(myBothway);
GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE")); GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE"));
GroupPoints2 = new DlgRef_3Sel1Check(centralWidget()); GroupPoints2 = new DlgRef_3Sel1Check(centralWidget());
@ -96,7 +93,6 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWi
GroupPoints2->PushButton2->setIcon(image1); GroupPoints2->PushButton2->setIcon(image1);
GroupPoints2->PushButton3->setIcon(image1); GroupPoints2->PushButton3->setIcon(image1);
GroupPoints2->CheckButton1->setText(tr("GEOM_BOTHWAY")); GroupPoints2->CheckButton1->setText(tr("GEOM_BOTHWAY"));
GroupPoints2->CheckButton1->setChecked(myBothway2);
GroupPoints3 = new DlgRef_1Sel3Spin1Check(centralWidget()); GroupPoints3 = new DlgRef_1Sel3Spin1Check(centralWidget());
GroupPoints3->GroupBox1->setTitle(tr("GEOM_EXTRUSION_DXDYDZ")); GroupPoints3->GroupBox1->setTitle(tr("GEOM_EXTRUSION_DXDYDZ"));
@ -106,7 +102,6 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWi
GroupPoints3->TextLabel3->setText(tr("GEOM_DY")); GroupPoints3->TextLabel3->setText(tr("GEOM_DY"));
GroupPoints3->TextLabel4->setText(tr("GEOM_DZ")); GroupPoints3->TextLabel4->setText(tr("GEOM_DZ"));
GroupPoints3->CheckButton1->setText(tr("GEOM_BOTHWAY")); GroupPoints3->CheckButton1->setText(tr("GEOM_BOTHWAY"));
GroupPoints3->CheckButton1->setChecked(myBothway3);
QVBoxLayout* layout = new QVBoxLayout(centralWidget()); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6); layout->setMargin(0); layout->setSpacing(6);
@ -170,8 +165,10 @@ void GenerationGUI_PrismDlg::Init()
GroupPoints3->LineEdit1->setText(""); GroupPoints3->LineEdit1->setText("");
myPoint1 = myPoint2 = myVec = GEOM::GEOM_Object::_nil(); myBaseObjects.clear();
myOkBase = myOkVec = myOkPnt1 = myOkPnt2 = false; myPoint1.nullify();
myPoint2.nullify();
myVec.nullify();
// signals and slots connections // signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
@ -182,9 +179,6 @@ void GenerationGUI_PrismDlg::Init()
connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
@ -196,12 +190,7 @@ void GenerationGUI_PrismDlg::Init()
connect(GroupPoints2->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints2->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints2->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway())); connect(GroupPoints2->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
connect(GroupPoints2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints2->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints3->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints3->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints3->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints3->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints3->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupPoints3->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints3->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupPoints3->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints3->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
@ -230,49 +219,38 @@ void GenerationGUI_PrismDlg::SetDoubleSpinBoxStep (double step)
//================================================================================= //=================================================================================
void GenerationGUI_PrismDlg::ConstructorsClicked (int constructorId) void GenerationGUI_PrismDlg::ConstructorsClicked (int constructorId)
{ {
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
switch (constructorId) { switch (constructorId) {
case 0: case 0:
{
GroupPoints2->hide(); GroupPoints2->hide();
GroupPoints3->hide(); GroupPoints3->hide();
GroupPoints->show(); GroupPoints->show();
GroupPoints->LineEdit1->setText(GroupPoints2->LineEdit1->text()); // keep base
GroupPoints->LineEdit2->setText(""); GroupPoints->LineEdit2->setText("");
myVec = GEOM::GEOM_Object::_nil(); myVec.nullify();
myOkVec = false;
GroupPoints->PushButton1->click(); GroupPoints->PushButton1->click();
break; break;
}
case 1: case 1:
{
GroupPoints->hide(); GroupPoints->hide();
GroupPoints2->show(); GroupPoints2->show();
GroupPoints3->hide(); GroupPoints3->hide();
GroupPoints2->LineEdit1->setText(GroupPoints->LineEdit1->text()); // keep base
GroupPoints2->LineEdit2->setText(""); GroupPoints2->LineEdit2->setText("");
GroupPoints2->LineEdit3->setText(""); GroupPoints2->LineEdit3->setText("");
myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); myPoint1.nullify();
myOkPnt1 = myOkPnt2 = false; myPoint2.nullify();
GroupPoints2->PushButton1->click(); GroupPoints2->PushButton1->click();
break; break;
}
case 2: case 2:
{
GroupPoints->hide(); GroupPoints->hide();
GroupPoints2->hide(); GroupPoints2->hide();
GroupPoints3->show(); GroupPoints3->show();
GroupPoints3->LineEdit1->setText(GroupPoints->LineEdit1->text()); // keep base
GroupPoints3->PushButton1->click(); GroupPoints3->PushButton1->click();
break; break;
} default:
break;
} }
qApp->processEvents(); qApp->processEvents();
@ -317,148 +295,60 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument()
erasePreview(); erasePreview();
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
QString aBaseName = ""; /* name of base object selection */
int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aBaseName, true);
if (nbSel > 1)
aBaseName = QString( "%1_objects").arg( nbSel );
// Base Object(s) selected
if ( myEditCurrentArgument == GroupPoints->LineEdit1 || if ( myEditCurrentArgument == GroupPoints->LineEdit1 ||
myEditCurrentArgument == GroupPoints2->LineEdit1 || myEditCurrentArgument == GroupPoints2->LineEdit1 ||
getConstructorId() == 2 ) { myEditCurrentArgument == GroupPoints3->LineEdit1 ) {
myOkBase = false; myBaseObjects.clear();
if ( nbSel > 0 ) { QList<GEOM::GeomObjPtr> objects = getSelected( TopAbs_SHAPE, -1 );
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myBaseObjects, true); for ( int i = 0; i < objects.count(); i++ ) {
myEditCurrentArgument->setText( aBaseName ); GEOM::shape_type stype = objects[i]->GetMaxShapeType();
myOkBase = true; if ( stype < GEOM::SHELL || stype > GEOM::VERTEX )
continue;
myBaseObjects << objects[i];
} }
displayPreview(); if ( !myBaseObjects.isEmpty() ) {
return; QString aName = myBaseObjects.count() > 1 ? QString( "%1_objects").arg( myBaseObjects.count() ) : GEOMBase::GetName( myBaseObjects[0].get() );
} GroupPoints->LineEdit1->setText( aName );
GroupPoints2->LineEdit1->setText( aName );
if (getConstructorId() == 0) GroupPoints3->LineEdit1->setText( aName );
{
if (aSelList.Extent() < 1) {
if (myEditCurrentArgument == GroupPoints->LineEdit2)
myOkVec = false;
return;
}
GEOM::GEOM_Object_var aSelectedObject =
GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( CORBA::is_nil(aSelectedObject) )
return;
QString aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape
bool myOk = true;
TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
{
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) {
int anIndex = aMap(1);
aName.append(":edge_" + QString::number(anIndex));
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if (aFindedObject->_is_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp =
getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
} }
else { else {
aSelectedObject = aFindedObject; // get Object from study GroupPoints->LineEdit1->setText( "" );
GroupPoints2->LineEdit1->setText( "" );
GroupPoints3->LineEdit1->setText( "" );
} }
} }
else { // Global Selection else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
if (aShape.ShapeType() != TopAbs_EDGE && myEditCurrentArgument == GroupPoints->LineEdit2) { myVec = getSelected( TopAbs_EDGE );
aSelectedObject = GEOM::GEOM_Object::_nil(); if ( myVec ) {
aName = ""; QString aName = GEOMBase::GetName( myVec.get() );
myOk = false;
}
}
}
if (myEditCurrentArgument == GroupPoints->LineEdit2 && myOk) {
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
myOkVec = true; if ( myBaseObjects.isEmpty() )
myVec = aSelectedObject; GroupPoints->PushButton1->click();
} }
} }
else if (getConstructorId() == 1) { // getConstructorId()==1 - extrusion using 2 points
if (aSelList.Extent() != 1) {
if ( myEditCurrentArgument == GroupPoints2->LineEdit2 ) { if ( myEditCurrentArgument == GroupPoints2->LineEdit2 ) {
myPoint1 = GEOM::GEOM_Object::_nil(); myPoint1 = getSelected( TopAbs_VERTEX );
myOkPnt1 = false; if ( myPoint1 ) {
} QString aName = GEOMBase::GetName( myPoint1.get() );
else if (myEditCurrentArgument == GroupPoints2->LineEdit3) {
myPoint2 = GEOM::GEOM_Object::_nil();
myOkPnt2 = false;
}
return;
}
GEOM::GEOM_Object_var aSelectedObject =
GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( CORBA::is_nil(aSelectedObject) )
return;
QString aName = GEOMBase::GetName(aSelectedObject);
TopoDS_Shape aShape;
bool myOk = true;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) {
int anIndex = aMap(1);
aName.append(":vertex_" + QString::number(anIndex));
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
if (aFindedObject->_is_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
}
else {
aSelectedObject = aFindedObject;
}
}
else {
if ((aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit2) ||
(aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit3)) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
myOk = false;
}
}
}
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
if ( !myPoint2 )
if (myEditCurrentArgument == GroupPoints2->LineEdit2 && myOk) {
myOkPnt1 = true;
myPoint1 = aSelectedObject;
if (!myOkPnt2)
GroupPoints2->PushButton3->click(); GroupPoints2->PushButton3->click();
} else if ( myBaseObjects.isEmpty() )
else if (myEditCurrentArgument == GroupPoints2->LineEdit3 && myOk) {
myOkPnt2 = true;
myPoint2 = aSelectedObject;
if (!myOkBase)
GroupPoints2->PushButton1->click(); GroupPoints2->PushButton1->click();
} }
} }
if ( myEditCurrentArgument == GroupPoints2->LineEdit3 ) {
myPoint2 = getSelected( TopAbs_VERTEX );
if ( myPoint2 ) {
QString aName = GEOMBase::GetName( myPoint2.get() );
myEditCurrentArgument->setText( aName );
if ( myBaseObjects.isEmpty() )
GroupPoints2->PushButton1->click();
else if ( !myPoint1 )
GroupPoints2->PushButton2->click();
}
}
displayPreview(); displayPreview();
} }
@ -523,24 +413,6 @@ void GenerationGUI_PrismDlg::SetEditCurrentArgument()
displayPreview(); displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GenerationGUI_PrismDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if (send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2 ||
send == GroupPoints2->LineEdit1 ||
send == GroupPoints2->LineEdit2 ||
send == GroupPoints2->LineEdit3 ||
send == GroupPoints3->LineEdit1) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -598,24 +470,26 @@ GEOM::GEOM_IOperations_ptr GenerationGUI_PrismDlg::createOperation()
//================================================================================= //=================================================================================
bool GenerationGUI_PrismDlg::isValid (QString& msg) bool GenerationGUI_PrismDlg::isValid (QString& msg)
{ {
bool ok = true; bool ok = false;
if( getConstructorId() == 0 ) switch ( getConstructorId() ) {
ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; case 0:
else if( getConstructorId() == 2 ) ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
{ !myBaseObjects.isEmpty() && myVec;
ok = GroupPoints3->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; break;
ok = GroupPoints3->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; case 1:
ok = GroupPoints3->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; ok = !myBaseObjects.isEmpty() && myPoint1 && myPoint2;
break;
case 2:
ok = GroupPoints3->SpinBox_DX->isValid( msg, !IsPreview() ) &&
GroupPoints3->SpinBox_DY->isValid( msg, !IsPreview() ) &&
GroupPoints3->SpinBox_DZ->isValid( msg, !IsPreview() ) &&
!myBaseObjects.isEmpty();
break;
default:
break;
} }
if (getConstructorId() == 0) return ok;
return (myOkBase && myOkVec) && ok; // by vector and height
else if (getConstructorId() == 1)
return (myOkBase && myOkPnt1 && myOkPnt2); // by two points
else if (getConstructorId() == 2)
return myOkBase && ok;
return false;
} }
//================================================================================= //=================================================================================
@ -625,19 +499,17 @@ bool GenerationGUI_PrismDlg::isValid (QString& msg)
bool GenerationGUI_PrismDlg::execute (ObjectList& objects) bool GenerationGUI_PrismDlg::execute (ObjectList& objects)
{ {
QStringList aParameters; QStringList aParameters;
GEOM::GEOM_Object_var anObj, aBaseObj; GEOM::GEOM_Object_var anObj;
GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation()); GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
for (int i=0; i < myBaseObjects.length(); i++) { for (int i = 0; i < myBaseObjects.count(); i++) {
aBaseObj = myBaseObjects[i];
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
if (!myBothway) if (!GroupPoints->CheckButton1->isChecked())
anObj = anOper->MakePrismVecH(aBaseObj, myVec, getHeight()); anObj = anOper->MakePrismVecH(myBaseObjects[i].get(), myVec.get(), getHeight());
else else
anObj = anOper->MakePrismVecH2Ways(aBaseObj, myVec, getHeight()); anObj = anOper->MakePrismVecH2Ways(myBaseObjects[i].get(), myVec.get(), getHeight());
if (!anObj->_is_nil() && !IsPreview()) { if (!anObj->_is_nil() && !IsPreview()) {
aParameters << GroupPoints->SpinBox_DX->text(); aParameters << GroupPoints->SpinBox_DX->text();
@ -645,20 +517,20 @@ bool GenerationGUI_PrismDlg::execute (ObjectList& objects)
} }
break; break;
case 1: case 1:
if (!myBothway2) if (!GroupPoints2->CheckButton1->isChecked())
anObj = anOper->MakePrismTwoPnt(aBaseObj, myPoint1, myPoint2); anObj = anOper->MakePrismTwoPnt(myBaseObjects[i].get(), myPoint1.get(), myPoint2.get());
else else
anObj = anOper->MakePrismTwoPnt2Ways(aBaseObj, myPoint1, myPoint2); anObj = anOper->MakePrismTwoPnt2Ways(myBaseObjects[i].get(), myPoint1.get(), myPoint2.get());
break; break;
case 2: case 2:
double dx = GroupPoints3->SpinBox_DX->value(); double dx = GroupPoints3->SpinBox_DX->value();
double dy = GroupPoints3->SpinBox_DY->value(); double dy = GroupPoints3->SpinBox_DY->value();
double dz = GroupPoints3->SpinBox_DZ->value(); double dz = GroupPoints3->SpinBox_DZ->value();
if (!myBothway3) if (!GroupPoints3->CheckButton1->isChecked())
anObj = anOper->MakePrismDXDYDZ(aBaseObj, dx, dy, dz); anObj = anOper->MakePrismDXDYDZ(myBaseObjects[i].get(), dx, dy, dz);
else else
anObj = anOper->MakePrismDXDYDZ2Ways(aBaseObj, dx, dy, dz); anObj = anOper->MakePrismDXDYDZ2Ways(myBaseObjects[i].get(), dx, dy, dz);
if (!anObj->_is_nil() && !IsPreview()) { if (!anObj->_is_nil() && !IsPreview()) {
aParameters << GroupPoints3->SpinBox_DX->text(); aParameters << GroupPoints3->SpinBox_DX->text();
@ -692,25 +564,8 @@ void GenerationGUI_PrismDlg::onReverse()
//================================================================================= //=================================================================================
void GenerationGUI_PrismDlg::onBothway() void GenerationGUI_PrismDlg::onBothway()
{ {
bool anOldValue; GroupPoints->CheckButton2->setEnabled(!GroupPoints->CheckButton1->isChecked());
switch (getConstructorId()) {
case 0:
anOldValue = myBothway;
myBothway = !anOldValue;
GroupPoints->CheckButton2->setEnabled(!myBothway);
displayPreview(); displayPreview();
break;
case 1:
anOldValue = myBothway2;
myBothway2 = !anOldValue;
displayPreview();
break;
case 2:
anOldValue = myBothway3;
myBothway3 = !anOldValue;
displayPreview();
break;
}
} }
//================================================================================= //=================================================================================
@ -719,18 +574,17 @@ void GenerationGUI_PrismDlg::onBothway()
//================================================================================= //=================================================================================
void GenerationGUI_PrismDlg::addSubshapesToStudy() void GenerationGUI_PrismDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
objMap[GroupPoints->LineEdit2->text()] = myVec; GEOMBase::PublishSubObject( myVec.get() );
break; break;
case 1: case 1:
objMap[GroupPoints2->LineEdit2->text()] = myPoint1; GEOMBase::PublishSubObject( myPoint1.get() );
objMap[GroupPoints2->LineEdit3->text()] = myPoint2; GEOMBase::PublishSubObject( myPoint2.get() );
break;
default:
break; break;
} }
addSubshapesToFather(objMap);
} }
//================================================================================= //=================================================================================
@ -739,5 +593,5 @@ void GenerationGUI_PrismDlg::addSubshapesToStudy()
//================================================================================= //=================================================================================
bool GenerationGUI_PrismDlg::extractPrefix() const bool GenerationGUI_PrismDlg::extractPrefix() const
{ {
return myBaseObjects.length() > 1; return myBaseObjects.count() > 1;
} }

View File

@ -27,7 +27,8 @@
#ifndef GENERATIONGUI_PRISMDLG_H #ifndef GENERATIONGUI_PRISMDLG_H
#define GENERATIONGUI_PRISMDLG_H #define GENERATIONGUI_PRISMDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel1Spin2Check; class DlgRef_2Sel1Spin2Check;
class DlgRef_3Sel1Check; class DlgRef_3Sel1Check;
@ -59,20 +60,9 @@ private:
double getHeight() const; double getHeight() const;
private: private:
GEOM::ListOfGO myBaseObjects; /* Base shapes */ QList<GEOM::GeomObjPtr> myBaseObjects; /* Base shapes */
GEOM::GEOM_Object_var myVec; /* Vector, defining the direction */ GEOM::GeomObjPtr myVec; /* Vector, defining the direction */
GEOM::GEOM_Object_var myPoint1, myPoint2; /* Points for extrusion */ GEOM::GeomObjPtr myPoint1, myPoint2; /* Points for extrusion */
bool myOkBase;
bool myOkVec;
bool myOkPnt1;
bool myOkPnt2;
bool myBothway;
bool myBothway2;
bool myBothway3;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
DlgRef_2Sel1Spin2Check* GroupPoints; DlgRef_2Sel1Spin2Check* GroupPoints;
DlgRef_3Sel1Check* GroupPoints2; // for second layout for extrusion using 2 points DlgRef_3Sel1Check* GroupPoints2; // for second layout for extrusion using 2 points
@ -82,7 +72,6 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ConstructorsClicked( int ); void ConstructorsClicked( int );

View File

@ -68,7 +68,6 @@ GenerationGUI_RevolDlg::GenerationGUI_RevolDlg (GeometryGUI* theGeometryGUI, QWi
mainFrame()->RadioButton2->close(); mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
myBothway = false;
GroupPoints = new DlgRef_2Sel1Spin2Check(centralWidget()); GroupPoints = new DlgRef_2Sel1Spin2Check(centralWidget());
GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
@ -119,8 +118,9 @@ void GenerationGUI_RevolDlg::Init()
GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText(""); GroupPoints->LineEdit2->setText("");
myAxis = GEOM::GEOM_Object::_nil();
myOkBase = myOkAxis = false; myBaseObjects.clear();
myAxis.nullify();
// signals and slots connections // signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
@ -129,9 +129,6 @@ void GenerationGUI_RevolDlg::Init()
connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway())); connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse())); connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse()));
@ -180,32 +177,6 @@ bool GenerationGUI_RevolDlg::ClickOnApply()
return true; return true;
} }
//=======================================================================
//function : isAcceptableBase
//purpose : return true if theBase can be used as algo argument
//=======================================================================
static bool isAcceptableBase (const TopoDS_Shape& theBase)
{
switch (theBase.ShapeType()) {
case TopAbs_VERTEX:
case TopAbs_EDGE:
case TopAbs_WIRE:
case TopAbs_FACE:
case TopAbs_SHELL:
return true;
case TopAbs_SOLID:
case TopAbs_COMPSOLID:
return false;
case TopAbs_COMPOUND: {
TopExp_Explorer exp(theBase, TopAbs_SOLID);
return !exp.More();
}
default:
return false;
}
return false;
}
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection is changed or on dialog initialization or activation // purpose : Called when selection is changed or on dialog initialization or activation
@ -214,76 +185,30 @@ void GenerationGUI_RevolDlg::SelectionIntoArgument()
{ {
erasePreview(); erasePreview();
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
if (myEditCurrentArgument == GroupPoints->LineEdit1) myOkBase = false;
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myOkAxis = false;
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() < 1)
return;
GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
QString aName = GEOMBase::GetName(aSelectedObject);
if ( aSelectedObject->_is_nil() )
return;
TopoDS_Shape S;
if (!GEOMBase::GetShape(aSelectedObject, S) || S.IsNull())
return;
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
myOkBase = false; myBaseObjects.clear();
if (aSelList.Extent() > 1) QList<GEOM::GeomObjPtr> objects = getSelected( TopAbs_SHAPE, -1 );
aName = QString( "%1_objects").arg( aSelList.Extent() ); for ( int i = 0; i < objects.count(); i++ ) {
GEOM::shape_type stype = objects[i]->GetMaxShapeType();
if ( aSelList.Extent() > 0 ) { if ( stype < GEOM::SHELL || stype > GEOM::VERTEX )
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myBaseObjects, true); continue;
// check base shapes myBaseObjects << objects[i];
for (int i=0; i < myBaseObjects.length(); i++) {
GEOMBase::GetShape(myBaseObjects[i], S);
if (!isAcceptableBase(S))
return;
} }
if ( !myBaseObjects.isEmpty() ) {
QString aName = myBaseObjects.count() > 1 ? QString( "%1_objects").arg( myBaseObjects.count() ) : GEOMBase::GetName( myBaseObjects[0].get() );
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
myOkBase = true;
} }
} }
else if (myEditCurrentArgument == GroupPoints->LineEdit2) { else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
TColStd_IndexedMapOfInteger aMap; myAxis = getSelected( TopAbs_EDGE );
aSelMgr->GetIndexes(aSelList.First(), aMap); if ( myAxis ) {
if (aMap.Extent() == 1) { QString aName = GEOMBase::GetName( myAxis.get() );
int anIndex = aMap(1);
aName.append(":edge_" + QString::number(anIndex));
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if (aFindedObject->_is_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp =
getGeomEngine()->GetIShapesOperations(getStudyId());
myAxis = aShapesOp->GetSubShape(aSelectedObject, anIndex);
myOkAxis = true;
} else {
myAxis = aFindedObject;
myOkAxis = true;
}
} else {
myOkAxis = true;
if (S.ShapeType() != TopAbs_EDGE) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
myOkAxis = false;
}
myAxis = aSelectedObject;
}
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
if (myOkAxis && !myOkBase) if ( myBaseObjects.isEmpty() )
GroupPoints->PushButton1->click(); GroupPoints->PushButton1->click();
} }
}
displayPreview(); displayPreview();
} }
@ -321,20 +246,6 @@ void GenerationGUI_RevolDlg::SetEditCurrentArgument()
displayPreview(); displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GenerationGUI_RevolDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if (send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -391,8 +302,7 @@ GEOM::GEOM_IOperations_ptr GenerationGUI_RevolDlg::createOperation()
//================================================================================= //=================================================================================
bool GenerationGUI_RevolDlg::isValid (QString& msg) bool GenerationGUI_RevolDlg::isValid (QString& msg)
{ {
bool ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ); return GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && !myBaseObjects.isEmpty() && myAxis;
return myOkBase && myOkAxis && ok;
} }
//================================================================================= //=================================================================================
@ -401,16 +311,14 @@ bool GenerationGUI_RevolDlg::isValid (QString& msg)
//================================================================================= //=================================================================================
bool GenerationGUI_RevolDlg::execute (ObjectList& objects) bool GenerationGUI_RevolDlg::execute (ObjectList& objects)
{ {
GEOM::GEOM_Object_var anObj, aBase; GEOM::GEOM_Object_var anObj;
GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation()); GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
for (int i=0; i < myBaseObjects.length(); i++) { for (int i = 0; i < myBaseObjects.count(); i++) {
aBase = myBaseObjects[i]; if (!GroupPoints->CheckButton1->isChecked())
anObj = anOper->MakeRevolutionAxisAngle(myBaseObjects[i].get(), myAxis.get(), getAngle() * PI180);
if (!myBothway)
anObj = anOper->MakeRevolutionAxisAngle(aBase, myAxis, getAngle() * PI180);
else else
anObj = anOper->MakeRevolutionAxisAngle2Ways(aBase, myAxis, getAngle() * PI180); anObj = anOper->MakeRevolutionAxisAngle2Ways(myBaseObjects[i].get(), myAxis.get(), getAngle() * PI180);
if (!anObj->_is_nil()) { if (!anObj->_is_nil()) {
if (!IsPreview()) { if (!IsPreview()) {
@ -441,9 +349,7 @@ void GenerationGUI_RevolDlg::onReverse()
//================================================================================= //=================================================================================
void GenerationGUI_RevolDlg::onBothway() void GenerationGUI_RevolDlg::onBothway()
{ {
bool anOldValue = myBothway; GroupPoints->CheckButton2->setEnabled(!GroupPoints->CheckButton1->isChecked());
myBothway = !anOldValue;
GroupPoints->CheckButton2->setEnabled(!myBothway);
displayPreview(); displayPreview();
} }
@ -453,11 +359,7 @@ void GenerationGUI_RevolDlg::onBothway()
//================================================================================= //=================================================================================
void GenerationGUI_RevolDlg::addSubshapesToStudy() void GenerationGUI_RevolDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap; GEOMBase::PublishSubObject( myAxis.get() );
objMap[GroupPoints->LineEdit2->text()] = myAxis;
addSubshapesToFather(objMap);
} }
//================================================================================= //=================================================================================
@ -466,5 +368,5 @@ void GenerationGUI_RevolDlg::addSubshapesToStudy()
//================================================================================= //=================================================================================
bool GenerationGUI_RevolDlg::extractPrefix() const bool GenerationGUI_RevolDlg::extractPrefix() const
{ {
return myBaseObjects.length() > 1; return myBaseObjects.count() > 1;
} }

View File

@ -27,7 +27,8 @@
#ifndef GENERATIONGUI_REVOLUTIONDLG_H #ifndef GENERATIONGUI_REVOLUTIONDLG_H
#define GENERATIONGUI_REVOLUTIONDLG_H #define GENERATIONGUI_REVOLUTIONDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel1Spin2Check; class DlgRef_2Sel1Spin2Check;
@ -57,11 +58,8 @@ private:
double getAngle() const; double getAngle() const;
private: private:
GEOM::ListOfGO myBaseObjects; /* Base shapes */ QList<GEOM::GeomObjPtr> myBaseObjects; /* Base shapes */
GEOM::GEOM_Object_var myAxis; /* Axis of the revolution */ GEOM::GeomObjPtr myAxis; /* Axis of the revolution */
bool myOkBase;
bool myOkAxis;
bool myBothway;
DlgRef_2Sel1Spin2Check* GroupPoints; DlgRef_2Sel1Spin2Check* GroupPoints;
@ -69,7 +67,6 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ValueChangedInSpinBox(); void ValueChangedInSpinBox();

View File

@ -43,7 +43,6 @@
#include <TopTools_IndexedMapOfShape.hxx> #include <TopTools_IndexedMapOfShape.hxx>
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
//#include <ostream>
//================================================================================= //=================================================================================
// class : PrimitiveGUI_BoxDlg() // class : PrimitiveGUI_BoxDlg()
@ -123,7 +122,8 @@ void PrimitiveGUI_BoxDlg::Init()
GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText(""); GroupPoints->LineEdit2->setText("");
myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); myPoint1.nullify();
myPoint2.nullify();
double initValue = 200.0; double initValue = 200.0;
GroupDimensions->SpinBox_DX->setValue(initValue); GroupDimensions->SpinBox_DX->setValue(initValue);
@ -139,9 +139,6 @@ void PrimitiveGUI_BoxDlg::Init()
connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
@ -242,50 +239,15 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument()
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil(); if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1.nullify();
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2.nullify();
return; return;
} }
// nbSel == 1 GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX );
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( CORBA::is_nil(aSelectedObject) )
return;
QString aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
{ QString aName = GEOMBase::GetName( aSelectedObject.get() );
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) // Local Selection
{
int anIndex = aMap(1);
aName.append(":vertex_" + QString::number(anIndex));
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if (aFindedObject->_is_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp =
getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else // Global Selection
{
if (aShape.ShapeType() != TopAbs_VERTEX) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
@ -297,15 +259,16 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument()
if (myEditCurrentArgument == GroupPoints->LineEdit1) { if (myEditCurrentArgument == GroupPoints->LineEdit1) {
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
if (!myPoint1->_is_nil() && myPoint2->_is_nil()) if (myPoint1 && !myPoint2)
GroupPoints->PushButton2->click(); GroupPoints->PushButton2->click();
} }
else if (myEditCurrentArgument == GroupPoints->LineEdit2) { else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
if (!myPoint2->_is_nil() && myPoint1->_is_nil()) if (myPoint2 && !myPoint1)
GroupPoints->PushButton1->click(); GroupPoints->PushButton1->click();
} }
}
displayPreview(); displayPreview();
} }
@ -351,19 +314,6 @@ void PrimitiveGUI_BoxDlg::SetEditCurrentArgument()
displayPreview(); displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void PrimitiveGUI_BoxDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if (send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -413,18 +363,21 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_BoxDlg::createOperation()
//================================================================================= //=================================================================================
bool PrimitiveGUI_BoxDlg::isValid (QString& msg) bool PrimitiveGUI_BoxDlg::isValid (QString& msg)
{ {
bool ok = true; bool ok = false;
if( getConstructorId() == 1 ) if( getConstructorId() == 1 )
{ {
ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) &&
ok = GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) &&
qAbs( GroupDimensions->SpinBox_DX->value() ) > Precision::Confusion() &&
ok = fabs( GroupDimensions->SpinBox_DX->value() ) > Precision::Confusion() && ok; qAbs( GroupDimensions->SpinBox_DY->value() ) > Precision::Confusion() &&
ok = fabs( GroupDimensions->SpinBox_DY->value() ) > Precision::Confusion() && ok; qAbs( GroupDimensions->SpinBox_DZ->value() ) > Precision::Confusion();
ok = fabs( GroupDimensions->SpinBox_DZ->value() ) > Precision::Confusion() && ok;
} }
return getConstructorId() == 0 ? !(myPoint1->_is_nil() || myPoint2->_is_nil()) : ok; else
{
ok = myPoint1 && myPoint2 && myPoint1 != myPoint2;
}
return ok;
} }
//================================================================================= //=================================================================================
@ -442,8 +395,8 @@ bool PrimitiveGUI_BoxDlg::execute (ObjectList& objects)
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
{ {
if (!CORBA::is_nil(myPoint1) && !CORBA::is_nil(myPoint2)) { if ( myPoint1 && myPoint2 ) {
anObj = anOper->MakeBoxTwoPnt(myPoint1, myPoint2); anObj = anOper->MakeBoxTwoPnt(myPoint1.get(), myPoint2.get());
res = true; res = true;
} }
} }
@ -481,9 +434,7 @@ bool PrimitiveGUI_BoxDlg::execute (ObjectList& objects)
void PrimitiveGUI_BoxDlg::addSubshapesToStudy() void PrimitiveGUI_BoxDlg::addSubshapesToStudy()
{ {
if (getConstructorId() == 0) { if (getConstructorId() == 0) {
QMap<QString, GEOM::GEOM_Object_var> objMap; GEOMBase::PublishSubObject( myPoint1.get() );
objMap[GroupPoints->LineEdit1->text()] = myPoint1; GEOMBase::PublishSubObject( myPoint2.get() );
objMap[GroupPoints->LineEdit2->text()] = myPoint2;
addSubshapesToFather(objMap);
} }
} }

View File

@ -27,7 +27,8 @@
#ifndef PRIMITIVEGUI_BOXDLG_H #ifndef PRIMITIVEGUI_BOXDLG_H
#define PRIMITIVEGUI_BOXDLG_H #define PRIMITIVEGUI_BOXDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel; class DlgRef_2Sel;
class DlgRef_3Spin; class DlgRef_3Spin;
@ -56,7 +57,7 @@ private:
void enterEvent( QEvent* ); void enterEvent( QEvent* );
private: private:
GEOM::GEOM_Object_var myPoint1, myPoint2; /* Points containing the vector */ GEOM::GeomObjPtr myPoint1, myPoint2; /* Points containing the vector */
DlgRef_2Sel* GroupPoints; DlgRef_2Sel* GroupPoints;
DlgRef_3Spin* GroupDimensions; DlgRef_3Spin* GroupDimensions;
@ -65,7 +66,6 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ConstructorsClicked( int ); void ConstructorsClicked( int );

View File

@ -129,7 +129,8 @@ void PrimitiveGUI_ConeDlg::Init()
GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText(""); GroupPoints->LineEdit2->setText("");
myPoint = myDir = GEOM::GEOM_Object::_nil(); myPoint.nullify();
myDir.nullify();
double aRadius1(100.0), aRadius2(0.0), aHeight(300.0); double aRadius1(100.0), aRadius2(0.0), aHeight(300.0);
GroupPoints->SpinBox_DX->setValue(aRadius1); GroupPoints->SpinBox_DX->setValue(aRadius1);
@ -148,9 +149,6 @@ void PrimitiveGUI_ConeDlg::Init()
connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
@ -257,57 +255,16 @@ void PrimitiveGUI_ConeDlg::SelectionIntoArgument()
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = GEOM::GEOM_Object::_nil(); if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint.nullify();
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir.nullify();
return; return;
} }
// nbSel == 1 TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupPoints->LineEdit2 ? TopAbs_EDGE : TopAbs_VERTEX;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
if ( CORBA::is_nil(aSelectedObject) )
return;
QString aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
{ QString aName = GEOMBase::GetName( aSelectedObject.get() );
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if (myEditCurrentArgument == GroupPoints->LineEdit2)
aNeedType = TopAbs_EDGE;
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) // Local Selection
{
int anIndex = aMap(1);
if (aNeedType == TopAbs_EDGE)
aName.append(":edge_" + QString::number(anIndex));
else
aName.append(":vertex_" + QString::number(anIndex));
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if (aFindedObject->_is_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp =
getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else // Global Selection
{
if (aShape.ShapeType() != aNeedType) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
@ -319,14 +276,15 @@ void PrimitiveGUI_ConeDlg::SelectionIntoArgument()
if (myEditCurrentArgument == GroupPoints->LineEdit1) { if (myEditCurrentArgument == GroupPoints->LineEdit1) {
myPoint = aSelectedObject; myPoint = aSelectedObject;
if (!myPoint->_is_nil() && myDir->_is_nil()) if (myPoint && !myDir)
GroupPoints->PushButton2->click(); GroupPoints->PushButton2->click();
} }
else if (myEditCurrentArgument == GroupPoints->LineEdit2) { else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myDir = aSelectedObject; myDir = aSelectedObject;
if (!myDir->_is_nil() && myPoint->_is_nil()) if (myDir && !myPoint)
GroupPoints->PushButton1->click(); GroupPoints->PushButton1->click();
} }
}
displayPreview(); displayPreview();
} }
@ -371,20 +329,6 @@ void PrimitiveGUI_ConeDlg::SetEditCurrentArgument()
displayPreview(); displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void PrimitiveGUI_ConeDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if (send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -433,24 +377,22 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_ConeDlg::createOperation()
//================================================================================= //=================================================================================
bool PrimitiveGUI_ConeDlg::isValid (QString& msg) bool PrimitiveGUI_ConeDlg::isValid (QString& msg)
{ {
if (!getRadius1() && !getRadius2()) bool ok = false;
return false;
bool ok = true;
if( getConstructorId() == 0 ) if( getConstructorId() == 0 )
{ {
ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
ok = GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) &&
myPoint && myDir;
} }
else if( getConstructorId() == 1 ) else if( getConstructorId() == 1 )
{ {
ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) &&
ok = GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() );
} }
ok = fabs( getHeight() ) > Precision::Confusion() && ok; ok = ( getRadius1() > 0 || getRadius2() > 0 ) && qAbs( getHeight() ) > Precision::Confusion() && ok;
return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) && ok : ok; return ok;
} }
//================================================================================= //=================================================================================
@ -467,8 +409,8 @@ bool PrimitiveGUI_ConeDlg::execute (ObjectList& objects)
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) { if ( myPoint && myDir ) {
anObj = anOper->MakeConePntVecR1R2H(myPoint, myDir, getRadius1(), getRadius2(), getHeight()); anObj = anOper->MakeConePntVecR1R2H(myPoint.get(), myDir.get(), getRadius1(), getRadius2(), getHeight());
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
QStringList aParameters; QStringList aParameters;
@ -548,15 +490,8 @@ double PrimitiveGUI_ConeDlg::getHeight() const
//================================================================================= //=================================================================================
void PrimitiveGUI_ConeDlg::addSubshapesToStudy() void PrimitiveGUI_ConeDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap; if ( getConstructorId() == 0 ) {
GEOMBase::PublishSubObject( myPoint.get() );
switch (getConstructorId()) { GEOMBase::PublishSubObject( myDir.get() );
case 0:
objMap[GroupPoints->LineEdit1->text()] = myPoint;
objMap[GroupPoints->LineEdit2->text()] = myDir;
break;
case 1:
return;
} }
addSubshapesToFather(objMap);
} }

View File

@ -27,7 +27,8 @@
#ifndef PRIMITIVEGUI_CONEDLG_H #ifndef PRIMITIVEGUI_CONEDLG_H
#define PRIMITIVEGUI_CONEDLG_H #define PRIMITIVEGUI_CONEDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel3Spin; class DlgRef_2Sel3Spin;
class DlgRef_3Spin; class DlgRef_3Spin;
@ -59,7 +60,7 @@ private:
double getHeight() const; double getHeight() const;
private: private:
GEOM::GEOM_Object_var myPoint, myDir; GEOM::GeomObjPtr myPoint, myDir;
DlgRef_2Sel3Spin* GroupPoints; DlgRef_2Sel3Spin* GroupPoints;
DlgRef_3Spin* GroupDimensions; DlgRef_3Spin* GroupDimensions;
@ -68,7 +69,6 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ConstructorsClicked( int ); void ConstructorsClicked( int );

View File

@ -127,7 +127,8 @@ void PrimitiveGUI_CylinderDlg::Init()
GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText(""); GroupPoints->LineEdit2->setText("");
myPoint = myDir = GEOM::GEOM_Object::_nil(); myPoint.nullify();
myDir.nullify();
double aRadius(100.0), aHeight(300.0); double aRadius(100.0), aHeight(300.0);
GroupPoints->SpinBox_DX->setValue(aRadius); GroupPoints->SpinBox_DX->setValue(aRadius);
@ -144,9 +145,6 @@ void PrimitiveGUI_CylinderDlg::Init()
connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
@ -250,56 +248,17 @@ void PrimitiveGUI_CylinderDlg::SelectionIntoArgument()
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPoints->LineEdit1) if (myEditCurrentArgument == GroupPoints->LineEdit1)
myPoint = GEOM::GEOM_Object::_nil(); myPoint.nullify();
else if (myEditCurrentArgument == GroupPoints->LineEdit2) else if (myEditCurrentArgument == GroupPoints->LineEdit2)
myDir = GEOM::GEOM_Object::_nil(); myDir.nullify();
return; return;
} }
// nbSel == 1 TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupPoints->LineEdit2 ? TopAbs_EDGE : TopAbs_VERTEX;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
if (CORBA::is_nil(aSelectedObject))
return;
QString aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
{ QString aName = GEOMBase::GetName( aSelectedObject.get() );
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if (myEditCurrentArgument == GroupPoints->LineEdit2)
aNeedType = TopAbs_EDGE;
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) { // Local Selection
int anIndex = aMap(1);
if (aNeedType == TopAbs_EDGE)
aName.append(":edge_" + QString::number(anIndex));
else
aName.append(":vertex_" + QString::number(anIndex));
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if (aFindedObject->_is_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp =
getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else { // Global Selection
if (aShape.ShapeType() != aNeedType) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
@ -311,14 +270,15 @@ void PrimitiveGUI_CylinderDlg::SelectionIntoArgument()
if (myEditCurrentArgument == GroupPoints->LineEdit1) { if (myEditCurrentArgument == GroupPoints->LineEdit1) {
myPoint = aSelectedObject; myPoint = aSelectedObject;
if (!myPoint->_is_nil() && myDir->_is_nil()) if (myPoint && !myDir)
GroupPoints->PushButton2->click(); GroupPoints->PushButton2->click();
} }
else if (myEditCurrentArgument == GroupPoints->LineEdit2) { else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myDir = aSelectedObject; myDir = aSelectedObject;
if (!myDir->_is_nil() && myPoint->_is_nil()) if (myDir && !myPoint)
GroupPoints->PushButton1->click(); GroupPoints->PushButton1->click();
} }
}
displayPreview(); displayPreview();
} }
@ -363,20 +323,6 @@ void PrimitiveGUI_CylinderDlg::SetEditCurrentArgument()
displayPreview(); displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void PrimitiveGUI_CylinderDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if (send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -425,19 +371,20 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_CylinderDlg::createOperation()
//================================================================================= //=================================================================================
bool PrimitiveGUI_CylinderDlg::isValid (QString& msg) bool PrimitiveGUI_CylinderDlg::isValid (QString& msg)
{ {
bool ok = true; bool ok = false;
if( getConstructorId() == 0 ) if( getConstructorId() == 0 )
{ {
ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
myPoint && myDir;
} }
else if( getConstructorId() == 1 ) else if( getConstructorId() == 1 )
{ {
ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() );
} }
ok = fabs( getHeight() ) > Precision::Confusion() && ok; ok = qAbs( getHeight() ) > Precision::Confusion() && ok;
return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) && ok : ok; return ok;
} }
//================================================================================= //=================================================================================
@ -454,8 +401,8 @@ bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects)
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) { if ( myPoint && myDir ) {
anObj = anOper->MakeCylinderPntVecRH(myPoint, myDir, getRadius(), getHeight()); anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight());
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
QStringList aParameters; QStringList aParameters;
@ -519,15 +466,8 @@ double PrimitiveGUI_CylinderDlg::getHeight() const
//================================================================================= //=================================================================================
void PrimitiveGUI_CylinderDlg::addSubshapesToStudy() void PrimitiveGUI_CylinderDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap; if ( getConstructorId() == 0 ) {
GEOMBase::PublishSubObject( myPoint.get() );
switch (getConstructorId()) { GEOMBase::PublishSubObject( myDir.get() );
case 0:
objMap[GroupPoints->LineEdit1->text()] = myPoint;
objMap[GroupPoints->LineEdit2->text()] = myDir;
break;
case 1:
return;
} }
addSubshapesToFather(objMap);
} }

View File

@ -27,7 +27,8 @@
#ifndef PRIMITIVEGUI_CYLINDERDLG_H #ifndef PRIMITIVEGUI_CYLINDERDLG_H
#define PRIMITIVEGUI_CYLINDERDLG_H #define PRIMITIVEGUI_CYLINDERDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel2Spin; class DlgRef_2Sel2Spin;
class DlgRef_2Spin; class DlgRef_2Spin;
@ -58,7 +59,7 @@ private:
double getHeight() const; double getHeight() const;
private: private:
GEOM::GEOM_Object_var myPoint, myDir; GEOM::GeomObjPtr myPoint, myDir;
// to initialize the first selection field with a selected object on the dialog creation // to initialize the first selection field with a selected object on the dialog creation
bool myInitial; bool myInitial;
@ -70,7 +71,6 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ConstructorsClicked( int ); void ConstructorsClicked( int );

View File

@ -142,7 +142,11 @@ void PrimitiveGUI_DiskDlg::Init()
Group3Pnts->LineEdit1->setText(""); Group3Pnts->LineEdit1->setText("");
Group3Pnts->LineEdit2->setText(""); Group3Pnts->LineEdit2->setText("");
Group3Pnts->LineEdit3->setText(""); Group3Pnts->LineEdit3->setText("");
myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); myPoint.nullify();
myDir.nullify();
myPoint1.nullify();
myPoint2.nullify();
myPoint3.nullify();
GroupPntVecR->SpinBox_DX->setValue(100); GroupPntVecR->SpinBox_DX->setValue(100);
GroupDimensions->SpinBox_DX->setValue(100); GroupDimensions->SpinBox_DX->setValue(100);
@ -156,17 +160,10 @@ void PrimitiveGUI_DiskDlg::Init()
connect(GroupPntVecR->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPntVecR->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPntVecR->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPntVecR->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPntVecR->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPntVecR->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(Group3Pnts->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(Group3Pnts->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(Group3Pnts->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(Group3Pnts->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(Group3Pnts->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(Group3Pnts->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(Group3Pnts->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(Group3Pnts->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(Group3Pnts->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPntVecR->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPntVecR->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
@ -299,58 +296,19 @@ void PrimitiveGUI_DiskDlg::SelectionIntoArgument()
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPntVecR->LineEdit1) myPoint = GEOM::GEOM_Object::_nil(); if (myEditCurrentArgument == GroupPntVecR->LineEdit1) myPoint.nullify();
else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) myDir = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) myDir.nullify();
else if (myEditCurrentArgument == Group3Pnts->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == Group3Pnts->LineEdit1) myPoint1.nullify();
else if (myEditCurrentArgument == Group3Pnts->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == Group3Pnts->LineEdit2) myPoint2.nullify();
else if (myEditCurrentArgument == Group3Pnts->LineEdit3) myPoint3 = GEOM::GEOM_Object::_nil(); else if (myEditCurrentArgument == Group3Pnts->LineEdit3) myPoint3.nullify();
return; return;
} }
// nbSel == 1 TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupPntVecR->LineEdit2 ? TopAbs_EDGE : TopAbs_VERTEX;
Handle(SALOME_InteractiveObject) anIO = aSelList.First(); GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO );
if ( CORBA::is_nil(aSelectedObject) )
return;
QString aName = GEOMBase::GetName(aSelectedObject);
// If selected Vertex or Edge on the some Shape Get selection Subshape
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
{ QString aName = GEOMBase::GetName( aSelectedObject.get() );
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if (myEditCurrentArgument == GroupPntVecR->LineEdit2)
aNeedType = TopAbs_EDGE;
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(anIO, aMap);
if (aMap.Extent() == 1) { // Local Selection
int anIndex = aMap(1);
if (aNeedType == TopAbs_EDGE)
aName += QString(":edge_%1").arg(anIndex);
else
aName += QString(":vertex_%1").arg(anIndex);
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if (aFindedObject->_is_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else { // Global Selection
if (aShape.ShapeType() != aNeedType) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
@ -362,29 +320,30 @@ void PrimitiveGUI_DiskDlg::SelectionIntoArgument()
if (myEditCurrentArgument == GroupPntVecR->LineEdit1) { if (myEditCurrentArgument == GroupPntVecR->LineEdit1) {
myPoint = aSelectedObject; myPoint = aSelectedObject;
if (!myPoint->_is_nil() && myDir->_is_nil()) if (myPoint && !myDir)
GroupPntVecR->PushButton2->click(); GroupPntVecR->PushButton2->click();
} }
else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) { else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) {
myDir = aSelectedObject; myDir = aSelectedObject;
if (!myDir->_is_nil() && myPoint->_is_nil()) if (myDir && !myPoint)
GroupPntVecR->PushButton1->click(); GroupPntVecR->PushButton1->click();
} }
else if (myEditCurrentArgument == Group3Pnts->LineEdit1) { else if (myEditCurrentArgument == Group3Pnts->LineEdit1) {
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
if (!myPoint1->_is_nil() && myPoint2->_is_nil()) if (myPoint1 && !myPoint2)
Group3Pnts->PushButton2->click(); Group3Pnts->PushButton2->click();
} }
else if (myEditCurrentArgument == Group3Pnts->LineEdit2) { else if (myEditCurrentArgument == Group3Pnts->LineEdit2) {
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
if (!myPoint2->_is_nil() && myPoint3->_is_nil()) if (myPoint2 && !myPoint3)
Group3Pnts->PushButton3->click(); Group3Pnts->PushButton3->click();
} }
else if (myEditCurrentArgument == Group3Pnts->LineEdit3) { else if (myEditCurrentArgument == Group3Pnts->LineEdit3) {
myPoint3 = aSelectedObject; myPoint3 = aSelectedObject;
if (!myPoint3->_is_nil() && myPoint1->_is_nil()) if (myPoint3 && !myPoint1)
Group3Pnts->PushButton1->click(); Group3Pnts->PushButton1->click();
} }
}
displayPreview(); displayPreview();
} }
@ -456,23 +415,6 @@ void PrimitiveGUI_DiskDlg::SetEditCurrentArgument()
displayPreview(); displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void PrimitiveGUI_DiskDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if (send == GroupPntVecR->LineEdit1 ||
send == GroupPntVecR->LineEdit2 ||
send == Group3Pnts->LineEdit1 ||
send == Group3Pnts->LineEdit2 ||
send == Group3Pnts->LineEdit3) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -529,21 +471,14 @@ static bool isEqual (const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Obje
//================================================================================= //=================================================================================
bool PrimitiveGUI_DiskDlg::isValid (QString& msg) bool PrimitiveGUI_DiskDlg::isValid (QString& msg)
{ {
bool ok = true; bool ok = false;
if ( getConstructorId() == 0 ) if ( getConstructorId() == 0 )
ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && getRadius() > 0;
else if ( getConstructorId() == 1 ) else if ( getConstructorId() == 1 )
ok = GroupPntVecR->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupPntVecR->SpinBox_DX->isValid( msg, !IsPreview() ) && myPoint && myDir && getRadius() > 0;
else if ( getConstructorId() == 2 )
const int id = getConstructorId(); ok = myPoint1 && myPoint2 && myPoint3 && myPoint1 != myPoint2 && myPoint1 != myPoint3 && myPoint2 != myPoint3;
if (id == 0)
return ok; return ok;
else if (id == 1)
return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0 && ok;
else if (id == 2)
return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() &&
!isEqual(myPoint1, myPoint2) && !isEqual(myPoint1, myPoint3) && !isEqual(myPoint2, myPoint3);
return false;
} }
//================================================================================= //=================================================================================
@ -570,7 +505,7 @@ bool PrimitiveGUI_DiskDlg::execute (ObjectList& objects)
res = true; res = true;
break; break;
case 1: case 1:
anObj = anOper->MakeDiskPntVecR(myPoint, myDir, getRadius()); anObj = anOper->MakeDiskPntVecR(myPoint.get(), myDir.get(), getRadius());
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
aParameters << GroupPntVecR->SpinBox_DX->text(); aParameters << GroupPntVecR->SpinBox_DX->text();
@ -579,7 +514,7 @@ bool PrimitiveGUI_DiskDlg::execute (ObjectList& objects)
res = true; res = true;
break; break;
case 2: case 2:
anObj = anOper->MakeDiskThreePnt(myPoint1, myPoint2, myPoint3); anObj = anOper->MakeDiskThreePnt(myPoint1.get(), myPoint2.get(), myPoint3.get());
res = true; res = true;
break; break;
} }
@ -612,18 +547,17 @@ double PrimitiveGUI_DiskDlg::getRadius() const
//================================================================================= //=================================================================================
void PrimitiveGUI_DiskDlg::addSubshapesToStudy() void PrimitiveGUI_DiskDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch (getConstructorId()) { switch (getConstructorId()) {
case 1: case 1:
objMap[GroupPntVecR->LineEdit1->text()] = myPoint; GEOMBase::PublishSubObject( myPoint.get() );
objMap[GroupPntVecR->LineEdit2->text()] = myDir; GEOMBase::PublishSubObject( myDir.get() );
break; break;
case 2: case 2:
objMap[Group3Pnts->LineEdit1->text()] = myPoint1; GEOMBase::PublishSubObject( myPoint1.get() );
objMap[Group3Pnts->LineEdit2->text()] = myPoint2; GEOMBase::PublishSubObject( myPoint2.get() );
objMap[Group3Pnts->LineEdit3->text()] = myPoint3; GEOMBase::PublishSubObject( myPoint3.get() );
break;
default:
break; break;
} }
addSubshapesToFather(objMap);
} }

View File

@ -24,7 +24,8 @@
#ifndef BASICGUI_DISKDLG_H #ifndef BASICGUI_DISKDLG_H
#define BASICGUI_DISKDLG_H #define BASICGUI_DISKDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_3Sel; class DlgRef_3Sel;
class DlgRef_2Sel1Spin; class DlgRef_2Sel1Spin;
@ -58,7 +59,7 @@ private:
int myOrientationType; int myOrientationType;
private: private:
GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3; GEOM::GeomObjPtr myPoint, myDir, myPoint1, myPoint2, myPoint3;
DlgRef_2Sel1Spin* GroupPntVecR; DlgRef_2Sel1Spin* GroupPntVecR;
DlgRef_3Sel* Group3Pnts; DlgRef_3Sel* Group3Pnts;
@ -74,7 +75,6 @@ private slots:
void SelectionIntoArgument(); void SelectionIntoArgument();
void ConstructorsClicked( int ); void ConstructorsClicked( int );
void LineEditReturnPressed();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ValueChangedInSpinBox(); void ValueChangedInSpinBox();
void SetDoubleSpinBoxStep( double ); void SetDoubleSpinBoxStep( double );

View File

@ -124,8 +124,8 @@ void PrimitiveGUI_FaceDlg::Init()
/* init variables */ /* init variables */
myEditCurrentArgument = GroupPlane->LineEdit1; myEditCurrentArgument = GroupPlane->LineEdit1;
GroupType->RadioButton1->setChecked(true); GroupType->RadioButton1->setChecked(true);
myEdge = GEOM::GEOM_Object::_nil(); myEdge.nullify();
myFace = GEOM::GEOM_Object::_nil(); myFace.nullify();
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any
// localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); // localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
@ -159,7 +159,6 @@ void PrimitiveGUI_FaceDlg::Init()
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( GroupPlane->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupPlane->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPlane->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPlane->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupPlane->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupPlane->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupPlane->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
@ -233,6 +232,10 @@ void PrimitiveGUI_FaceDlg::TypeButtonClicked()
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE ); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
GroupPlane->TextLabel1->setText( tr( "GEOM_FACE" ) ); GroupPlane->TextLabel1->setText( tr( "GEOM_FACE" ) );
} }
myEditCurrentArgument = GroupPlane->LineEdit1;
myEditCurrentArgument->setText( "" );
myEdge.nullify();
myFace.nullify();
} }
//================================================================================= //=================================================================================
@ -287,8 +290,8 @@ void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId )
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
myEditCurrentArgument = GroupPlane->LineEdit1; myEditCurrentArgument = GroupPlane->LineEdit1;
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
myEdge = GEOM::GEOM_Object::_nil(); myEdge.nullify();
myFace = GEOM::GEOM_Object::_nil(); myFace.nullify();
GroupType->RadioButton1->setChecked( true ); GroupType->RadioButton1->setChecked( true );
TypeButtonClicked(); TypeButtonClicked();
GroupDimensions->hide(); GroupDimensions->hide();
@ -324,54 +327,24 @@ void PrimitiveGUI_FaceDlg::SelectionIntoArgument()
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if ( aSelList.Extent() != 1 ) { if ( aSelList.Extent() != 1 ) {
if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myEdge = GEOM::GEOM_Object::_nil(); if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myEdge.nullify();
return; return;
} }
// nbSel == 1 TopAbs_ShapeEnum aNeedType = GroupType->RadioButton2->isChecked() ? TopAbs_FACE : TopAbs_EDGE;
TopAbs_ShapeEnum aNeedType = TopAbs_EDGE; GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( !CORBA::is_nil( aSelectedObject ) ) {
QString aName = GEOMBase::GetName( aSelectedObject );
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
if (GroupType->RadioButton2->isChecked()) QString aName = GEOMBase::GetName( aSelectedObject.get() );
aNeedType = TopAbs_FACE;
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes( aSelList.First(), aMap );
if ( aMap.Extent() == 1 ) { // Local Selection
int anIndex = aMap( 1 );
if ( aNeedType == TopAbs_EDGE )
aName += QString( ":edge_%1" ).arg( anIndex );
else
aName += QString( ":face_%1" ).arg( anIndex );
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
if ( aFindedObject->_is_nil() ) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
}
else
aSelectedObject = aFindedObject; // get Object from study
}
else { // Global Selection
if ( aShape.ShapeType() != aNeedType ) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
if ( myEditCurrentArgument == GroupPlane->LineEdit1 && aNeedType == TopAbs_EDGE ) if ( myEditCurrentArgument == GroupPlane->LineEdit1 && aNeedType == TopAbs_EDGE )
myEdge = aSelectedObject; myEdge = aSelectedObject;
else if ( myEditCurrentArgument == GroupPlane->LineEdit1 && aNeedType == TopAbs_FACE ) else if ( myEditCurrentArgument == GroupPlane->LineEdit1 && aNeedType == TopAbs_FACE )
myFace = aSelectedObject; myFace = aSelectedObject;
} }
displayPreview(); displayPreview();
} }
@ -397,20 +370,6 @@ void PrimitiveGUI_FaceDlg::SetEditCurrentArgument()
SelectionIntoArgument(); SelectionIntoArgument();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void PrimitiveGUI_FaceDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPlane->LineEdit1 ) myEditCurrentArgument = GroupPlane->LineEdit1;
else return;
GEOMBase_Skeleton::LineEditReturnPressed();
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -458,28 +417,19 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_FaceDlg::createOperation()
//================================================================================= //=================================================================================
bool PrimitiveGUI_FaceDlg::isValid( QString& msg ) bool PrimitiveGUI_FaceDlg::isValid( QString& msg )
{ {
bool ok = true; bool ok = false;
if( getConstructorId() == 0 ) if( getConstructorId() == 0 )
{ {
ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() );
} }
else if( getConstructorId() == 1 ) else if( getConstructorId() == 1 )
{ {
ok = GroupPlane->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupPlane->SpinBox_DX->isValid( msg, !IsPreview() ) &&
ok = GroupPlane->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; GroupPlane->SpinBox_DY->isValid( msg, !IsPreview() ) &&
( GroupType->RadioButton1->isChecked() ? myEdge : myFace );
} }
const int id = getConstructorId();
if ( id == 0 )
return ok; return ok;
else if ( id == 1 ) {
if (GroupType->RadioButton1->isChecked())
return !myEdge->_is_nil() && ok;
else if (GroupType->RadioButton2->isChecked())
return !myFace->_is_nil() && ok;
}
return false;
} }
//================================================================================= //=================================================================================
@ -508,8 +458,8 @@ bool PrimitiveGUI_FaceDlg::execute (ObjectList& objects)
break; break;
case 1: case 1:
anObj = GroupType->RadioButton1->isChecked() ? anObj = GroupType->RadioButton1->isChecked() ?
anOper->MakeFaceObjHW(myEdge, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value()) : anOper->MakeFaceObjHW(myEdge.get(), GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value()) :
anOper->MakeFaceObjHW(myFace, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value()); anOper->MakeFaceObjHW(myFace.get(), GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value());
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
aParameters << GroupPlane->SpinBox_DX->text(); aParameters << GroupPlane->SpinBox_DX->text();
@ -532,14 +482,10 @@ bool PrimitiveGUI_FaceDlg::execute (ObjectList& objects)
//================================================================================= //=================================================================================
void PrimitiveGUI_FaceDlg::addSubshapesToStudy() void PrimitiveGUI_FaceDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap; if ( getConstructorId() == 1 ) {
switch ( getConstructorId() ) {
case 1 :
if ( GroupType->RadioButton1->isChecked() ) if ( GroupType->RadioButton1->isChecked() )
objMap[GroupPlane->LineEdit1->text()] = myEdge; GEOMBase::PublishSubObject( myEdge.get() );
if ( GroupType->RadioButton2->isChecked() ) if ( GroupType->RadioButton2->isChecked() )
objMap[GroupPlane->LineEdit1->text()] = myFace; GEOMBase::PublishSubObject( myFace.get() );
break;
} }
addSubshapesToFather( objMap );
} }

View File

@ -24,7 +24,8 @@
#ifndef BASICGUI_FACEDLG_H #ifndef BASICGUI_FACEDLG_H
#define BASICGUI_FACEDLG_H #define BASICGUI_FACEDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_2Spin; class DlgRef_2Spin;
class DlgRef_1Sel2Spin; class DlgRef_1Sel2Spin;
@ -54,8 +55,8 @@ private:
void enterEvent( QEvent* ); void enterEvent( QEvent* );
private: private:
GEOM::GEOM_Object_var myEdge; GEOM::GeomObjPtr myEdge;
GEOM::GEOM_Object_var myFace; GEOM::GeomObjPtr myFace;
int myOrientationType; int myOrientationType;
@ -72,7 +73,6 @@ private slots:
void DeactivateActiveDialog(); void DeactivateActiveDialog();
void ConstructorsClicked( int ); void ConstructorsClicked( int );
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ValueChangedInSpinBox( double ); void ValueChangedInSpinBox( double );

View File

@ -109,7 +109,7 @@ void PrimitiveGUI_SphereDlg::Init()
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly( true );
myPoint = GEOM::GEOM_Object::_nil(); myPoint.nullify();
/* Get setting of step value from file configuration */ /* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
@ -128,7 +128,6 @@ void PrimitiveGUI_SphereDlg::Init()
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupDimensions->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); connect( GroupDimensions->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
@ -173,7 +172,7 @@ void PrimitiveGUI_SphereDlg::ConstructorsClicked( int constructorId )
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setText( "" ); GroupPoints->LineEdit1->setText( "" );
myPoint = GEOM::GEOM_Object::_nil(); myPoint.nullify();
connect( myGeomGUI->getApp()->selectionMgr(), connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
@ -241,65 +240,21 @@ void PrimitiveGUI_SphereDlg::SelectionIntoArgument()
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1) {
myPoint = GEOM::GEOM_Object::_nil(); myPoint.nullify();
return; return;
} }
/* nbSel == 1 ! */ GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX );
GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( CORBA::is_nil( aSelectedObject ) )
return;
QString aName = GEOMBase::GetName( aSelectedObject );
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull() ) { if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
TColStd_IndexedMapOfInteger aMap; QString aName = GEOMBase::GetName( aSelectedObject.get() );
aSelMgr->GetIndexes(aSelList.First(), aMap);
if ( aMap.Extent() == 1 ) { // Local Selection
int anIndex = aMap( 1 );
aName.append( ":vertex_" + QString::number( anIndex ) );
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName );
if ( aFindedObject->_is_nil() ) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp =
getGeomEngine()->GetIShapesOperations( getStudyId() );
aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else { // Global Selection
if (aShape.ShapeType() != TopAbs_VERTEX) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText( aName );
myPoint = aSelectedObject; myPoint = aSelectedObject;
}
displayPreview(); displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void PrimitiveGUI_SphereDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 ) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -379,12 +334,12 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_SphereDlg::createOperation()
//================================================================================= //=================================================================================
bool PrimitiveGUI_SphereDlg::isValid( QString& msg ) bool PrimitiveGUI_SphereDlg::isValid( QString& msg )
{ {
bool ok = true; bool ok = false;
if( getConstructorId() == 0 ) if( getConstructorId() == 0 )
ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && myPoint;
else if( getConstructorId() == 1 ) else if( getConstructorId() == 1 )
ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() );
return getConstructorId() == 0 ? !myPoint->_is_nil() && ok : ok; return ok;
} }
//================================================================================= //=================================================================================
@ -402,8 +357,8 @@ bool PrimitiveGUI_SphereDlg::execute( ObjectList& objects )
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0 : case 0 :
{ {
if ( !CORBA::is_nil( myPoint ) ) { if ( myPoint ) {
anObj = anOper->MakeSpherePntR( myPoint, getRadius() ); anObj = anOper->MakeSpherePntR( myPoint.get(), getRadius() );
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
QStringList aParameters; QStringList aParameters;
@ -455,14 +410,7 @@ double PrimitiveGUI_SphereDlg::getRadius() const
//================================================================================= //=================================================================================
void PrimitiveGUI_SphereDlg::addSubshapesToStudy() void PrimitiveGUI_SphereDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap; if ( getConstructorId() == 0 ) {
GEOMBase::PublishSubObject( myPoint.get() );
switch ( getConstructorId() ) {
case 0:
objMap[GroupPoints->LineEdit1->text()] = myPoint;
break;
case 1:
return;
} }
addSubshapesToFather( objMap );
} }

View File

@ -27,7 +27,8 @@
#ifndef PRIMITIVEGUI_SPHEREDLG_H #ifndef PRIMITIVEGUI_SPHEREDLG_H
#define PRIMITIVEGUI_SPHEREDLG_H #define PRIMITIVEGUI_SPHEREDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel1Spin; class DlgRef_1Sel1Spin;
class DlgRef_1Spin; class DlgRef_1Spin;
@ -57,7 +58,7 @@ private:
double getRadius() const; double getRadius() const;
private: private:
GEOM::GEOM_Object_var myPoint; /* Center point */ GEOM::GeomObjPtr myPoint; /* Center point */
DlgRef_1Sel1Spin* GroupPoints; DlgRef_1Sel1Spin* GroupPoints;
DlgRef_1Spin* GroupDimensions; DlgRef_1Spin* GroupDimensions;
@ -67,7 +68,6 @@ private slots:
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void DeactivateActiveDialog(); void DeactivateActiveDialog();
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ConstructorsClicked( int ); void ConstructorsClicked( int );

View File

@ -126,7 +126,8 @@ void PrimitiveGUI_TorusDlg::Init()
GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText(""); GroupPoints->LineEdit2->setText("");
myPoint = myDir = GEOM::GEOM_Object::_nil(); myPoint.nullify();
myDir.nullify();
GroupPoints->SpinBox_DX->setValue(300.0); GroupPoints->SpinBox_DX->setValue(300.0);
GroupPoints->SpinBox_DY->setValue(100.0); GroupPoints->SpinBox_DY->setValue(100.0);
@ -142,9 +143,6 @@ void PrimitiveGUI_TorusDlg::Init()
connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
@ -242,60 +240,21 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument()
erasePreview(); erasePreview();
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint.nullify();
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir.nullify();
return; return;
}
// nbSel == 1 TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupPoints->LineEdit2 ? TopAbs_EDGE : TopAbs_VERTEX;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
if ( CORBA::is_nil(aSelectedObject) )
return;
QString aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
{ QString aName = GEOMBase::GetName( aSelectedObject.get() );
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if (myEditCurrentArgument == GroupPoints->LineEdit2)
aNeedType = TopAbs_EDGE;
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) { // Local Selection
int anIndex = aMap(1);
if (aNeedType == TopAbs_EDGE)
aName.append(":edge_" + QString::number(anIndex));
else
aName.append(":vertex_" + QString::number(anIndex));
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if (aFindedObject->_is_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp =
getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else { // Global Selection
if (aShape.ShapeType() != aNeedType) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
@ -307,14 +266,15 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument()
if (myEditCurrentArgument == GroupPoints->LineEdit1) { if (myEditCurrentArgument == GroupPoints->LineEdit1) {
myPoint = aSelectedObject; myPoint = aSelectedObject;
if (!myPoint->_is_nil() && myDir->_is_nil()) if (myPoint && !myDir)
GroupPoints->PushButton2->click(); GroupPoints->PushButton2->click();
} }
else if (myEditCurrentArgument == GroupPoints->LineEdit2) { else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myDir = aSelectedObject; myDir = aSelectedObject;
if (!myDir->_is_nil() && myPoint->_is_nil()) if (myDir && !myPoint)
GroupPoints->PushButton1->click(); GroupPoints->PushButton1->click();
} }
}
displayPreview(); displayPreview();
} }
@ -359,20 +319,6 @@ void PrimitiveGUI_TorusDlg::SetEditCurrentArgument()
displayPreview(); displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void PrimitiveGUI_TorusDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if (send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -421,18 +367,19 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_TorusDlg::createOperation()
//================================================================================= //=================================================================================
bool PrimitiveGUI_TorusDlg::isValid (QString& msg) bool PrimitiveGUI_TorusDlg::isValid (QString& msg)
{ {
bool ok = true; bool ok = false;
if( getConstructorId() == 0 ) if( getConstructorId() == 0 )
{ {
ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
myPoint && myDir;
} }
else if( getConstructorId() == 1 ) else if( getConstructorId() == 1 )
{ {
ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() );
} }
return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) && ok : ok; return ok;
} }
//================================================================================= //=================================================================================
@ -449,8 +396,8 @@ bool PrimitiveGUI_TorusDlg::execute (ObjectList& objects)
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) { if ( myPoint && myDir ) {
anObj = anOper->MakeTorusPntVecRR(myPoint, myDir, getRadius1(), getRadius2()); anObj = anOper->MakeTorusPntVecRR(myPoint.get(), myDir.get(), getRadius1(), getRadius2());
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
QStringList aParameters; QStringList aParameters;
@ -514,15 +461,8 @@ double PrimitiveGUI_TorusDlg::getRadius2() const
//================================================================================= //=================================================================================
void PrimitiveGUI_TorusDlg::addSubshapesToStudy() void PrimitiveGUI_TorusDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap; if ( getConstructorId() == 0 ) {
GEOMBase::PublishSubObject( myPoint.get() );
switch (getConstructorId()) { GEOMBase::PublishSubObject( myDir.get() );
case 0:
objMap[GroupPoints->LineEdit1->text()] = myPoint;
objMap[GroupPoints->LineEdit2->text()] = myDir;
break;
case 1:
return;
} }
addSubshapesToFather(objMap);
} }

View File

@ -27,7 +27,8 @@
#ifndef PRIMITIVEGUI_TORUSDLG_H #ifndef PRIMITIVEGUI_TORUSDLG_H
#define PRIMITIVEGUI_TORUSDLG_H #define PRIMITIVEGUI_TORUSDLG_H
#include <GEOMBase_Skeleton.h> #include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel2Spin; class DlgRef_2Sel2Spin;
class DlgRef_2Spin; class DlgRef_2Spin;
@ -58,7 +59,7 @@ private:
double getRadius2() const; double getRadius2() const;
private: private:
GEOM::GEOM_Object_var myPoint, myDir; GEOM::GeomObjPtr myPoint, myDir;
DlgRef_2Sel2Spin* GroupPoints; DlgRef_2Sel2Spin* GroupPoints;
DlgRef_2Spin* GroupDimensions; DlgRef_2Spin* GroupDimensions;
@ -67,7 +68,6 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ActivateThisDialog(); void ActivateThisDialog();
void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void ConstructorsClicked( int ); void ConstructorsClicked( int );