/* init variables */
myEditCurrentArgument = Group3Pnts->LineEdit1;
- myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
+ myPoint1.nullify();
+ myPoint2.nullify();
+ myPoint3.nullify();
Group3Pnts2->CheckButton1->setChecked( false );
Group3Pnts->PushButton1->setDown(true);
connect( Group3Pnts->PushButton2, 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->PushButton2, 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( Group3Pnts3->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts3->PushButton2, 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() ),
this, SLOT( SelectionIntoArgument() ) );
if (aSelList.Extent() != 1) {
switch (getConstructorId()) {
case 0:
- if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil();
- return;
+ if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3.nullify();
break;
case 1:
- if ( myEditCurrentArgument == Group3Pnts2->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts2->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts2->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil();
- return;
+ if ( myEditCurrentArgument == Group3Pnts2->LineEdit1 ) myPoint1.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts2->LineEdit2 ) myPoint2.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts2->LineEdit3 ) myPoint3.nullify();
break;
case 2:
- if ( myEditCurrentArgument == Group3Pnts3->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts3->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts3->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil();
- return;
+ if ( myEditCurrentArgument == Group3Pnts3->LineEdit1 ) myPoint1.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts3->LineEdit2 ) myPoint2.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts3->LineEdit3 ) myPoint3.nullify();
+ break;
+ default:
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
- TopoDS_Shape aShape;
- if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
- {
- 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 = "";
- }
- }
- }
+ GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
myEditCurrentArgument->setText(aName);
-
- if (!aSelectedObject->_is_nil()) { // clear selection if something selected
- globalSelection();
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
- }
-
switch ( getConstructorId() ) {
case 0:
- if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
+ if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
myPoint1 = aSelectedObject;
- if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
+ if ( myPoint1 && !myPoint2 )
Group3Pnts->PushButton2->click();
}
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
myPoint2 = aSelectedObject;
- if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
+ if ( myPoint2 && !myPoint3 )
Group3Pnts->PushButton3->click();
}
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
myPoint3 = aSelectedObject;
- if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
+ if ( myPoint3 && !myPoint1 )
Group3Pnts->PushButton1->click();
}
break;
case 1:
if ( myEditCurrentArgument == Group3Pnts2->LineEdit1 ) {
myPoint1 = aSelectedObject;
- if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
+ if ( myPoint1 && !myPoint2 )
Group3Pnts2->PushButton2->click();
}
else if ( myEditCurrentArgument == Group3Pnts2->LineEdit2 ) {
myPoint2 = aSelectedObject;
- if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
+ if ( myPoint2 && !myPoint3 )
Group3Pnts2->PushButton3->click();
}
else if ( myEditCurrentArgument == Group3Pnts2->LineEdit3 ) {
myPoint3 = aSelectedObject;
- if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
+ if ( myPoint3 && !myPoint1 )
Group3Pnts2->PushButton1->click();
}
break;
case 2:
if ( myEditCurrentArgument == Group3Pnts3->LineEdit1 ) {
myPoint1 = aSelectedObject;
- if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
+ if ( myPoint1 && !myPoint2 )
Group3Pnts3->PushButton2->click();
}
else if ( myEditCurrentArgument == Group3Pnts3->LineEdit2 ) {
myPoint2 = aSelectedObject;
- if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
+ if ( myPoint2 && !myPoint3 )
Group3Pnts3->PushButton3->click();
}
else if ( myEditCurrentArgument == Group3Pnts3->LineEdit3 ) {
myPoint3 = aSelectedObject;
- if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
+ if ( myPoint3 && !myPoint1 )
Group3Pnts3->PushButton1->click();
}
break;
}
-//=================================================================================
-// 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()
// purpose :
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
// purpose :
//=================================================================================
bool BasicGUI_ArcDlg::isValid( QString& msg )
{
- switch (getConstructorId()) {
- case 0:
- {
- 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 );
+ bool ok = myPoint1 && myPoint2 && myPoint3 &&
+ myPoint1 != myPoint2 && myPoint1 != myPoint3 && myPoint2 != myPoint3;
+ return ok;
}
//=================================================================================
switch ( getConstructorId() ) {
case 0:
{
- if ( !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) ) {
- anObj = anOper->MakeArc( myPoint1, myPoint2, myPoint3 );
+ if ( myPoint1 && myPoint2 && myPoint3 ) {
+ anObj = anOper->MakeArc( myPoint1.get(), myPoint2.get(), myPoint3.get() );
res = true;
}
break;
case 1:
{
bool Sense = Group3Pnts2->CheckButton1->isChecked();
- if ( !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) ) {
- anObj = anOper->MakeArcCenter( myPoint1, myPoint2, myPoint3, Sense );
+ if ( myPoint1 && myPoint2 && myPoint3 ) {
+ anObj = anOper->MakeArcCenter( myPoint1.get(), myPoint2.get(), myPoint3.get(), Sense );
res = true;
}
break;
}
case 2:
{
- if ( !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) ) {
- anObj = anOper->MakeArcOfEllipse( myPoint1, myPoint2, myPoint3 );
+ if ( myPoint1 && myPoint2 && myPoint3 ) {
+ anObj = anOper->MakeArcOfEllipse( myPoint1.get(), myPoint2.get(), myPoint3.get() );
res = true;
}
break;
{
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
+ myPoint1.nullify();
+ myPoint2.nullify();
+ myPoint3.nullify();
+
switch ( constructorId ) {
case 0:
{
- globalSelection(); // close local contexts, if any
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes
-
Group3Pnts->show();
Group3Pnts2->hide();
Group3Pnts3->hide();
Group3Pnts->LineEdit1->setEnabled(true);
Group3Pnts->LineEdit2->setEnabled(false);
Group3Pnts->LineEdit3->setEnabled(false);
- myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
myEditCurrentArgument = Group3Pnts->LineEdit1;
break;
}
case 1:
{
- globalSelection(); // close local contexts, if any
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes
-
Group3Pnts->hide();
Group3Pnts2->show();
Group3Pnts3->hide();
Group3Pnts2->LineEdit1->setEnabled(true);
Group3Pnts2->LineEdit2->setEnabled(false);
Group3Pnts2->LineEdit3->setEnabled(false);
- myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
myEditCurrentArgument = Group3Pnts2->LineEdit1;
break;
}
case 2:
{
- globalSelection(); // close local contexts, if any
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes
-
Group3Pnts->hide();
Group3Pnts2->hide();
Group3Pnts3->show();
Group3Pnts3->LineEdit1->setEnabled(true);
Group3Pnts3->LineEdit2->setEnabled(false);
Group3Pnts3->LineEdit3->setEnabled(false);
- myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
myEditCurrentArgument = Group3Pnts3->LineEdit1;
break;
}
}
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); //Select Vertex on All Shapes
+
qApp->processEvents();
updateGeometry();
resize( minimumSizeHint() );
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
- if ( CORBA::is_nil( myPoint1 ) )
- SelectionIntoArgument();
+ SelectionIntoArgument();
displayPreview();
}
//=================================================================================
void BasicGUI_ArcDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
switch ( getConstructorId() ) {
case 0:
- objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
- objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
- objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
- break;
case 1:
- objMap[Group3Pnts2->LineEdit1->text()] = myPoint1;
- objMap[Group3Pnts2->LineEdit2->text()] = myPoint2;
- objMap[Group3Pnts2->LineEdit3->text()] = myPoint3;
- break;
case 2:
- objMap[Group3Pnts3->LineEdit1->text()] = myPoint1;
- objMap[Group3Pnts3->LineEdit2->text()] = myPoint2;
- objMap[Group3Pnts3->LineEdit3->text()] = myPoint3;
+ GEOMBase::PublishSubObject( myPoint1.get() );
+ GEOMBase::PublishSubObject( myPoint2.get() );
+ GEOMBase::PublishSubObject( myPoint3.get() );
+ break;
+ default:
break;
}
- addSubshapesToFather( objMap );
}
#ifndef BASICGUI_ARCDLG_H
#define BASICGUI_ARCDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_3Sel;
class DlgRef_3Sel1Check;
void enterEvent( QEvent* );
private:
- GEOM::GEOM_Object_var myPoint1, myPoint2, myPoint3;
+ GEOM::GeomObjPtr myPoint1, myPoint2, myPoint3;
DlgRef_3Sel* Group3Pnts;
DlgRef_3Sel1Check* Group3Pnts2;
void ActivateThisDialog();
void ConstructorsClicked( int );
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ReverseSense();
/* init variables */
myEditCurrentArgument = GroupPntVecR->LineEdit1;
- myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
-
- // myGeomGUI->SetState( 0 );
+ myPoint.nullify();
+ myDir.nullify();
+ myPoint1.nullify();
+ myPoint2.nullify();
+ myPoint3.nullify();
+ myPoint4.nullify();
+ myPoint5.nullify();
+ myPoint6.nullify();
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
connect( GroupCenter2Pnts->PushButton2, 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( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
{
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 ) {
case 0:
aSelMgr->selectedObjects( aList );
if ( aList.Extent() != 1 ) {
- if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) myPoint4 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) myPoint5 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) myPoint6 = GEOM::GEOM_Object::_nil();
+ if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint.nullify();
+ else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3.nullify();
+ else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) myPoint4.nullify();
+ else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) myPoint5.nullify();
+ else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) myPoint6.nullify();
return;
}
- // nbSel == 1
- Handle(SALOME_InteractiveObject) anIO = aList.First();
-
- 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;
- if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
- 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 = "";
- }
- }
- }
+ TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) ?
+ TopAbs_EDGE : TopAbs_VERTEX;
+ GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
myEditCurrentArgument->setText( aName );
- if (!aSelectedObject->_is_nil()) { // clear selection if something selected
- globalSelection();
- localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
- }
-
if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) {
myPoint = aSelectedObject;
- if ( !myPoint->_is_nil() && myDir->_is_nil() )
+ if ( myPoint && !myDir )
GroupPntVecR->PushButton2->click();
}
else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
myDir = aSelectedObject;
- if ( !myDir->_is_nil() && myPoint->_is_nil() )
+ if ( myDir && !myPoint )
GroupPntVecR->PushButton1->click();
}
else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
myPoint1 = aSelectedObject;
- if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
+ if ( myPoint1 && !myPoint2 )
Group3Pnts->PushButton2->click();
}
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
myPoint2 = aSelectedObject;
- if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
+ if ( myPoint2 && !myPoint3 )
Group3Pnts->PushButton3->click();
}
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
myPoint3 = aSelectedObject;
- if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
+ if ( myPoint3 && !myPoint1 )
Group3Pnts->PushButton1->click();
}
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) {
myPoint4 = aSelectedObject;
- if ( !myPoint4->_is_nil() && myPoint5->_is_nil() )
+ if ( myPoint4 && !myPoint5 )
GroupCenter2Pnts->PushButton2->click();
}
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) {
myPoint5 = aSelectedObject;
- if ( !myPoint5->_is_nil() && myPoint6->_is_nil() )
+ if ( myPoint5 && !myPoint6 )
GroupCenter2Pnts->PushButton3->click();
}
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) {
myPoint6 = aSelectedObject;
- if ( !myPoint6->_is_nil() && myPoint4->_is_nil() )
+ if ( myPoint6 && !myPoint4 )
GroupCenter2Pnts->PushButton1->click();
}
}
myEditCurrentArgument->setFocus();
- if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
- globalSelection(); // close local contexts, if any
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
- }
- else {
- globalSelection(); // close local contexts, if any
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
- }
+ TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) ?
+ TopAbs_EDGE : TopAbs_VERTEX;
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
myEditCurrentArgument->setFocus();
// SelectionIntoArgument();
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()
//=================================================================================
void BasicGUI_CircleDlg::DeactivateActiveDialog()
{
- // myGeomGUI->SetState( -1 );
GEOMBase_Skeleton::DeactivateActiveDialog();
}
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
// purpose :
//=================================================================================
bool BasicGUI_CircleDlg::isValid( QString& msg )
{
- const int id = getConstructorId();
- if ( id == 0 ) {
- //return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0;
- //nil point means origin of global CS
- //nil vector means Z axis
- bool ok = GroupPntVecR->SpinBox_DX->isValid(msg, !IsPreview());
- return getRadius() > 0 && ok;
+ bool ok = false;
+ switch( getConstructorId() ) {
+ case 0:
+ // nil point means origin of global CS
+ // nil vector means Z axis
+ ok = GroupPntVecR->SpinBox_DX->isValid(msg, !IsPreview()) && getRadius() > 0;
+ 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 !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;
+ return ok;
}
//=================================================================================
{
QStringList aParameters;
aParameters << GroupPntVecR->SpinBox_DX->text();
- anObj = anOper->MakeCirclePntVecR( myPoint, myDir, getRadius() );
+ anObj = anOper->MakeCirclePntVecR( myPoint.get(), myDir.get(), getRadius() );
if ( !anObj->_is_nil() && !IsPreview() )
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
res = true;
break;
}
case 1 :
- anObj = anOper->MakeCircleThreePnt( myPoint1, myPoint2, myPoint3 );
+ anObj = anOper->MakeCircleThreePnt( myPoint1.get(), myPoint2.get(), myPoint3.get() );
res = true;
break;
case 2:
- anObj = anOper->MakeCircleCenter2Pnt( myPoint4, myPoint5, myPoint6 );
+ anObj = anOper->MakeCircleCenter2Pnt( myPoint4.get(), myPoint5.get(), myPoint6.get() );
res = true;
break;
}
//=================================================================================
void BasicGUI_CircleDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
switch ( getConstructorId() ) {
case 0:
- if (!CORBA::is_nil(myPoint))
- objMap[GroupPntVecR->LineEdit1->text()] = myPoint;
- if (!CORBA::is_nil(myDir))
- objMap[GroupPntVecR->LineEdit2->text()] = myDir;
+ GEOMBase::PublishSubObject( myPoint.get() );
+ GEOMBase::PublishSubObject( myDir.get() );
break;
case 1:
- objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
- objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
- objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
+ GEOMBase::PublishSubObject( myPoint1.get() );
+ GEOMBase::PublishSubObject( myPoint2.get() );
+ GEOMBase::PublishSubObject( myPoint3.get() );
break;
case 2:
- objMap[GroupCenter2Pnts->LineEdit1->text()] = myPoint4;
- objMap[GroupCenter2Pnts->LineEdit2->text()] = myPoint5;
- objMap[GroupCenter2Pnts->LineEdit3->text()] = myPoint6;
+ GEOMBase::PublishSubObject( myPoint4.get() );
+ GEOMBase::PublishSubObject( myPoint5.get() );
+ GEOMBase::PublishSubObject( myPoint6.get() );
break;
+ default:
+ break;
}
- addSubshapesToFather( objMap );
}
#ifndef BASICGUI_CIRCLEDLG_H
#define BASICGUI_CIRCLEDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_3Sel;
class DlgRef_2Sel1Spin;
double getRadius() const;
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_3Sel* Group3Pnts;
void SelectionIntoArgument();
void ConstructorsClicked( int );
- void LineEditReturnPressed();
void SetEditCurrentArgument();
void ValueChangedInSpinBox();
void SetDoubleSpinBoxStep( double );
/* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1;
- myPoints = new GEOM::ListOfGO();
- myPoints->length( 0 );
+ myPoints.clear();
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
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() ) );
else
GroupPoints->CheckButton1->hide();
- myPoints = new GEOM::ListOfGO();
- myPoints->length( 0 );
+ myPoints.clear();
myEditCurrentArgument->setText( "" );
qApp->processEvents();
SelectionIntoArgument();
}
-
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void BasicGUI_CurveDlg::LineEditReturnPressed()
-{
- if ( sender() == GroupPoints->LineEdit1 )
- {
- myEditCurrentArgument = GroupPoints->LineEdit1;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
-}
-
//=================================================================================
// function : CheckButtonToggled()
// purpose :
return true;
}
-//=================================================================================
-/*! 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();
-
- if ( len < 1 ) {
- return -1;
- }
-
- 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 )
+static void synchronize( QList<GEOM::GeomObjPtr>& left, QList<GEOM::GeomObjPtr>& right )
{
- std::list<GEOM::GEOM_Object_var> objs_to_remove;
- for ( std::list<GEOM::GEOM_Object_var>::iterator i = theOldPoints.begin(); i != theOldPoints.end(); i++ ) {
+ // 1. remove items from the "left" list that are not in the "right" list
+ QMutableListIterator<GEOM::GeomObjPtr> it1( left );
+ while ( it1.hasNext() ) {
+ GEOM::GeomObjPtr o1 = it1.next();
bool found = false;
- for ( int j = 0; j < theNewPoints->length() && !found ; j++ ) {
- if ( std::string( (*i)->GetEntry() ) == std::string( theNewPoints[j]->GetEntry() ) ) {
- found = true;
- }
- }
- if ( !found ) {
- objs_to_remove.push_back( *i );
- //cout << "removed: " << (*i)->GetEntry() << endl;
- }
+ QMutableListIterator<GEOM::GeomObjPtr> it2( right );
+ while ( it2.hasNext() && !found )
+ found = o1 == it2.next();
+ if ( !found )
+ it1.remove();
}
- for ( std::list<GEOM::GEOM_Object_var>::iterator i = objs_to_remove.begin(); i != objs_to_remove.end(); i++ ) {
- theOldPoints.remove( *i );
+ // 2. add items from the "right" list that are not in the "left" list (to keep selection order)
+ it1 = right;
+ while ( it1.hasNext() ) {
+ GEOM::GeomObjPtr o1 = it1.next();
+ bool found = false;
+ QMutableListIterator<GEOM::GeomObjPtr> it2( left );
+ while ( it2.hasNext() && !found )
+ found = o1 == it2.next();
+ if ( !found )
+ left << o1;
}
}
//=================================================================================
void BasicGUI_CurveDlg::SelectionIntoArgument()
{
- myEditCurrentArgument->setText( "" );
-
- SalomeApp_Application* app = myGeomGUI->getApp();
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
- _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();
+ QList<GEOM::GeomObjPtr> points = getSelected( TopAbs_VERTEX, -1 );
+ synchronize( myPoints, points );
+ if ( !myPoints.isEmpty() )
+ GroupPoints->LineEdit1->setText( QString::number( myPoints.count() ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) );
else
- removeUnnecessaryPnt( myOrderedSel, myPoints );
-
- // 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_" ) );
-
+ GroupPoints->LineEdit1->setText( "" );
displayPreview();
}
//=================================================================================
bool BasicGUI_CurveDlg::isValid( QString& msg )
{
- return myPoints->length() > 1;
+ return myPoints.count() > 1;
}
//=================================================================================
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() ) {
case 0 :
- anObj = anOper->MakePolyline( myPoints );
+ anObj = anOper->MakePolyline( points.in() );
res = true;
break;
case 1 :
- anObj = anOper->MakeSplineBezier( myPoints );
+ anObj = anOper->MakeSplineBezier( points.in() );
res = true;
break;
case 2 :
- anObj = anOper->MakeSplineInterpolation( myPoints, GroupPoints->CheckButton1->isChecked() );
+ anObj = anOper->MakeSplineInterpolation( points.in(), GroupPoints->CheckButton1->isChecked() );
res = true;
break;
}
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() );
+}
#ifndef BASICGUI_CURVEDLG_H
#define BASICGUI_CURVEDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
#include <list>
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& );
virtual bool execute( ObjectList& );
+ virtual void addSubshapesToStudy();
private:
void Init();
private:
DlgRef_1Sel1Check* GroupPoints;
- GEOM::ListOfGO_var myPoints;
- std::list<GEOM::GEOM_Object_var> myOrderedSel; //!< This list used for managing orderes selection
+ QList<GEOM::GeomObjPtr> myPoints;
private slots:
void ClickOnOk();
void DeactivateActiveDialog();
void ConstructorsClicked( int );
- void LineEditReturnPressed();
void CheckButtonToggled();
void SelectionIntoArgument();
void SetEditCurrentArgument();
{
/* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1;
- globalSelection(); // close local contexts, if any
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
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 */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
connect( GroupPoints->PushButton2, 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_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
initName( tr( "GEOM_ELLIPSE" ) );
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+
resize( minimumSizeHint() );
SelectionIntoArgument();
displayPreview();
initName();
// reset
- myPoint = myDir = myMajor = GEOM::GEOM_Object::_nil();
+ myPoint.nullify();
+ myDir.nullify();
+ myMajor.nullify();
GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" );
GroupPoints->LineEdit3->setText( "" );
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) {
- if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPoints->LineEdit3) myMajor = GEOM::GEOM_Object::_nil();
+ if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint.nullify();
+ else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir.nullify();
+ else if (myEditCurrentArgument == GroupPoints->LineEdit3) myMajor.nullify();
return;
}
- Handle(SALOME_InteractiveObject) anIO = aSelList.First();
- GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO );
- if (!CORBA::is_nil(aSelectedObject) ) {
- QString aName = GEOMBase::GetName(aSelectedObject);
-
- // Get Selected object if selected subshape
- TopoDS_Shape aShape;
-
- TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
- 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 = "";
- }
- }
- }
-
+ TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
+ myEditCurrentArgument == GroupPoints->LineEdit3 ) ?
+ TopAbs_EDGE : TopAbs_VERTEX;
+ GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
myEditCurrentArgument->setText( aName );
-
- if (!aSelectedObject->_is_nil()) { // clear selection if something selected
- globalSelection();
- localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
- }
-
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
myPoint = aSelectedObject;
- if ( !myPoint->_is_nil() && myDir->_is_nil() )
+ if ( myPoint && !myDir )
GroupPoints->PushButton2->click();
}
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
- myDir = aSelectedObject;
- if ( !myDir->_is_nil() && myMajor->_is_nil() )
+ myDir = aSelectedObject;
+ if ( myDir && !myMajor )
GroupPoints->PushButton3->click();
}
else if ( myEditCurrentArgument == GroupPoints->LineEdit3 ) {
myMajor = aSelectedObject;
- if ( !myMajor->_is_nil() && myPoint->_is_nil() )
+ if ( myMajor && !myPoint )
GroupPoints->PushButton1->click();
}
}
GroupPoints->LineEdit3->setEnabled( true );
}
+ TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
+ myEditCurrentArgument == GroupPoints->LineEdit3 ) ?
+ TopAbs_EDGE : TopAbs_VERTEX;
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 );
myEditCurrentArgument->setFocus();
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()
GroupPoints->LineEdit2->setText( "" );
GroupPoints->LineEdit3->setText( "" );
- myPoint = myDir = GEOM::GEOM_Object::_nil();
+ myPoint.nullify();
+ myDir.nullify();
//globalSelection( GEOM_POINT );
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
//=================================================================================
bool BasicGUI_EllipseDlg::isValid( QString& msg )
{
- double aMajorR = GroupPoints->SpinBox_DX->value();
- double aMinorR = GroupPoints->SpinBox_DY->value();
- if ( aMajorR < aMinorR ) {
- msg = tr( "GEOM_ELLIPSE_ERROR_1" );
- return false;
+ // 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 aMinorR = GroupPoints->SpinBox_DY->value();
+ if ( aMajorR < aMinorR ) {
+ msg = tr( "GEOM_ELLIPSE_ERROR_1" );
+ 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;
}
aParameters<<GroupPoints->SpinBox_DY->text();
GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() );
- GEOM::GEOM_Object_var anObj = myMajor->_is_nil() ?
- anOper->MakeEllipse ( myPoint, myDir, aMajorR, aMinorR ) :
- anOper->MakeEllipseVec( myPoint, myDir, aMajorR, aMinorR, myMajor );
+ GEOM::GEOM_Object_var anObj = myMajor ?
+ anOper->MakeEllipseVec( myPoint.get(), myDir.get(), aMajorR, aMinorR, myMajor.get() ) :
+ anOper->MakeEllipse ( myPoint.get(), myDir.get(), aMajorR, aMinorR );
if ( !anObj->_is_nil() ) {
if ( !IsPreview() )
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
//=================================================================================
void BasicGUI_EllipseDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
- if (!CORBA::is_nil(myPoint))
- 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 );
+ GEOMBase::PublishSubObject( myPoint.get() );
+ GEOMBase::PublishSubObject( myDir.get() );
+ GEOMBase::PublishSubObject( myMajor.get() );
}
#ifndef BASICGUI_ELLIPSEDLG_H
#define BASICGUI_ELLIPSEDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_3Sel2Spin;
void enterEvent( QEvent* );
private:
- GEOM::GEOM_Object_var myPoint, myDir, myMajor;
+ GEOM::GeomObjPtr myPoint, myDir, myMajor;
DlgRef_3Sel2Spin* GroupPoints;
void ActivateThisDialog();
void DeactivateActiveDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ValueChangedInSpinBox( double );
{
/* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1;
- myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
- globalSelection(); // close local contexts, if any
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+ myPoint1.nullify();
+ myPoint2.nullify();
+ myFace1.nullify();
+ myFace2.nullify();
+
GroupPoints->PushButton1->setDown(true);
-
/* signals and slots connections */
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
connect( GroupFaces->PushButton1, 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() ),
this, SLOT( SelectionIntoArgument() ) );
switch ( constructorId ) {
case 0:
{
- globalSelection(); // close local contexts, if any
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
-
myEditCurrentArgument = GroupPoints->LineEdit1;
myEditCurrentArgument->setText( "" );
GroupPoints->LineEdit2->setText( "" );
- myPoint1 = GEOM::GEOM_Object::_nil();
- myPoint2 = GEOM::GEOM_Object::_nil();
+ myPoint1.nullify();
+ myPoint2.nullify();
GroupPoints->PushButton1->setDown(true);
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit1->setEnabled(true);
}
case 1:
{
- globalSelection(); // close local contexts, if any
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
-
myEditCurrentArgument = GroupFaces->LineEdit1;
myEditCurrentArgument->setText("");
- myFace1 = GEOM::GEOM_Object::_nil();
- myFace2 = GEOM::GEOM_Object::_nil();
+ myFace1.nullify();
+ myFace2.nullify();
GroupFaces->PushButton1->setDown(true);
GroupFaces->PushButton2->setDown(false);
GroupFaces->LineEdit1->setEnabled(true);
}
}
+ 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();
updateGeometry();
resize( minimumSizeHint() );
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) {
- if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupFaces->LineEdit1) myFace1 = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupFaces->LineEdit2) myFace2 = GEOM::GEOM_Object::_nil();
+ if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1.nullify();
+ else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2.nullify();
+ else if (myEditCurrentArgument == GroupFaces->LineEdit1) myFace1.nullify();
+ else if (myEditCurrentArgument == GroupFaces->LineEdit2) myFace2.nullify();
displayPreview();
return;
}
- 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 == GroupFaces->LineEdit1 ||
- myEditCurrentArgument == GroupFaces->LineEdit2 )
- aNeedType = TopAbs_FACE;
-
- TopoDS_Shape aShape;
- if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
- TColStd_IndexedMapOfInteger aMap;
- 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 = "";
- }
- }
- }
-
+ TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupFaces->LineEdit1 ||
+ myEditCurrentArgument == GroupFaces->LineEdit2 ) ?
+ TopAbs_FACE : TopAbs_VERTEX;
+ GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
myEditCurrentArgument->setText( aName );
-
- if (!aSelectedObject->_is_nil()) { // clear selection if something selected
- globalSelection();
- localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
- }
-
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
myPoint1 = aSelectedObject;
- if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
+ if ( myPoint1 && !myPoint2 )
GroupPoints->PushButton2->click();
}
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
myPoint2 = aSelectedObject;
- if ( !myPoint2->_is_nil() && myPoint1->_is_nil() )
+ if ( myPoint2 && !myPoint1 )
GroupPoints->PushButton1->click();
}
else if ( myEditCurrentArgument == GroupFaces->LineEdit1 ) {
myFace1 = aSelectedObject;
- if ( !myFace1->_is_nil() && myFace2->_is_nil() )
+ if ( myFace1 && !myFace2 )
GroupFaces->PushButton2->click();
}
else if ( myEditCurrentArgument == GroupFaces->LineEdit2 ) {
myFace2 = aSelectedObject;
- if ( !myFace2->_is_nil() && myFace1->_is_nil() )
+ if ( myFace2 && !myFace1 )
GroupFaces->PushButton1->click();
}
}
displayPreview();
}
-
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
GroupFaces->LineEdit2->setEnabled(true);
}
+ TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupFaces->LineEdit1 ||
+ myEditCurrentArgument == GroupFaces->LineEdit2 ) ?
+ TopAbs_FACE : TopAbs_VERTEX;
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 );
myEditCurrentArgument->setFocus();
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()
// purpose :
//=================================================================================
bool BasicGUI_LineDlg::isValid( QString& msg )
{
- const int id = getConstructorId();
- if ( id == 0 )
- return !myPoint1->_is_nil() && !myPoint2->_is_nil();
- else if ( id == 1 )
- return !myFace1->_is_nil() && !myFace2->_is_nil();
- return false;
+ bool ok = false;
+ switch ( getConstructorId() ) {
+ case 0 :
+ ok = myPoint1 && myPoint2;
+ break;
+ case 1:
+ ok = myFace1 && myFace2;
+ break;
+ default:
+ break;
+ }
+ return ok;
}
//=================================================================================
GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
switch ( getConstructorId() ) {
case 0 :
- anObj = anOper->MakeLineTwoPnt( myPoint1, myPoint2 );
+ anObj = anOper->MakeLineTwoPnt( myPoint1.get(), myPoint2.get() );
res = true;
break;
case 1 :
- anObj = anOper->MakeLineTwoFaces( myFace1, myFace2 );
+ anObj = anOper->MakeLineTwoFaces( myFace1.get(), myFace2.get() );
res = true;
break;
}
//=================================================================================
void BasicGUI_LineDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) {
case 0 :
- objMap[GroupPoints->LineEdit1->text()] = myPoint1;
- objMap[GroupPoints->LineEdit2->text()] = myPoint2;
+ GEOMBase::PublishSubObject( myPoint1.get() );
+ GEOMBase::PublishSubObject( myPoint2.get() );
break;
case 1 :
- objMap[GroupFaces->LineEdit1->text()] = myFace1;
- objMap[GroupFaces->LineEdit2->text()] = myFace2;
+ GEOMBase::PublishSubObject( myFace1.get() );
+ GEOMBase::PublishSubObject( myFace2.get() );
+ break;
+ default:
break;
}
- addSubshapesToFather( objMap );
}
#ifndef BASICGUI_LINEDLG_H
#define BASICGUI_LINEDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel;
void enterEvent( QEvent* );
private:
- GEOM::GEOM_Object_var myPoint1;
- GEOM::GEOM_Object_var myPoint2;
- GEOM::GEOM_Object_var myFace1;
- GEOM::GEOM_Object_var myFace2;
+ GEOM::GeomObjPtr myPoint1;
+ GEOM::GeomObjPtr myPoint2;
+ GEOM::GeomObjPtr myFace1;
+ GEOM::GeomObjPtr myFace2;
DlgRef_2Sel* GroupPoints;
DlgRef_2Sel* GroupFaces;
void DeactivateActiveDialog();
void ConstructorsClicked( int );
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
};
//=================================================================================
void BasicGUI_MarkerDlg::Init()
{
- myShape = myPoint = myVectorX = myVectorY = GEOM::GEOM_Object::_nil();
+ myShape.nullify();
+ myPoint.nullify();
+ myVectorX.nullify();
+ myVectorY.nullify();
myBlockPreview = false;
myConstructorId = -1;
myEditCurrentArgument = Group1->LineEdit1;
connect( Group2->PushButton2, 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( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
globalSelection( GEOM_ALLGEOM );
myEditCurrentArgument = Group1->LineEdit1;
Group1->LineEdit1->setText( "" );
- myShape = GEOM::GEOM_Object::_nil();
+ myShape.nullify();
break;
}
case 2:
Group2->LineEdit1->setEnabled( true );
Group2->LineEdit2->setEnabled( false );
Group2->LineEdit3->setEnabled( false );
- myPoint = GEOM::GEOM_Object::_nil();
- myVectorX = GEOM::GEOM_Object::_nil();
- myVectorY = GEOM::GEOM_Object::_nil();
+ myPoint.nullify();
+ myVectorX.nullify();
+ myVectorY.nullify();
break;
}
}
//=================================================================================
void BasicGUI_MarkerDlg::onSelectionDone0()
{
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
-
- if (aSelList.Extent() == 1) {
- Handle(SALOME_InteractiveObject) anIO = aSelList.First();
- GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO );
+ GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_FACE );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && aSelectedObject->GetType() == GEOM_MARKER && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ // Existing LCS selected
+ TopoDS_Face aFace = TopoDS::Face( aShape );
+ Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
- if ( !aSelectedObj->_is_nil() ) {
- TopoDS_Shape aShape;
- if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
- // Existing LCS selected
- if ( aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE ) {
- TopoDS_Face aFace = TopoDS::Face( aShape );
- Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
-
- if ( !aPlane.IsNull() ) {
- gp_Ax3 anAx3 = aPlane->Pln().Position();
- gp_Pnt aLoc = anAx3.Location();
- gp_Dir aXDir = anAx3.XDirection();
- gp_Dir aYDir = anAx3.YDirection();
-
- myData[ X ]->setValue( aLoc.X() );
- myData[ Y ]->setValue( aLoc.Y() );
- myData[ Z ]->setValue( aLoc.Z() );
-
- myData[ DX1 ]->setValue( aXDir.X() );
- myData[ DY1 ]->setValue( aXDir.Y() );
- myData[ DZ1 ]->setValue( aXDir.Z() );
-
- myData[ DX2 ]->setValue( aYDir.X() );
- myData[ DY2 ]->setValue( aYDir.Y() );
- myData[ DZ2 ]->setValue( aYDir.Z() );
- aSelMgr->clearSelected();
- }
- }
- else {
- TColStd_IndexedMapOfInteger aMap;
- 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 ) );
- myData[ X ]->setValue( aPnt.X() );
- myData[ Y ]->setValue( aPnt.Y() );
- myData[ Z ]->setValue( aPnt.Z() );
- }
- }
- }
+ if ( !aPlane.IsNull() ) {
+ gp_Ax3 anAx3 = aPlane->Pln().Position();
+ gp_Pnt aLoc = anAx3.Location();
+ gp_Dir aXDir = anAx3.XDirection();
+ gp_Dir aYDir = anAx3.YDirection();
+
+ myData[ X ]->setValue( aLoc.X() );
+ myData[ Y ]->setValue( aLoc.Y() );
+ myData[ Z ]->setValue( aLoc.Z() );
+
+ myData[ DX1 ]->setValue( aXDir.X() );
+ myData[ DY1 ]->setValue( aXDir.Y() );
+ myData[ DZ1 ]->setValue( aXDir.Z() );
+
+ myData[ DX2 ]->setValue( aYDir.X() );
+ myData[ DY2 ]->setValue( aYDir.Y() );
+ myData[ DZ2 ]->setValue( aYDir.Z() );
}
+ displayPreview();
+ return;
+ }
+ aSelectedObject = getSelected( TopAbs_VERTEX );
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
+ myData[ X ]->setValue( aPnt.X() );
+ myData[ Y ]->setValue( aPnt.Y() );
+ myData[ Z ]->setValue( aPnt.Z() );
+ displayPreview();
+ return;
}
-
- displayPreview();
}
return;
}
- myEditCurrentArgument->setText( "" );
-
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- 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;
- if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) )
- myShape = aSelectedObj;
- myEditCurrentArgument->setText( aName );
+ 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;
+
+ GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+ myEditCurrentArgument->setText( aName );
+ if ( getConstructorId() == 1 ) { // by shape position
+ myShape = aSelectedObject;
+ }
+ else if ( getConstructorId() == 2 ) { // by point and two vectors
+ if ( myEditCurrentArgument == Group2->LineEdit1 ) {
+ myPoint = aSelectedObject;
+ if (myPoint && !myVectorX)
+ Group2->PushButton2->click();
+ }
+ else if (myEditCurrentArgument == Group2->LineEdit2) {
+ myVectorX = aSelectedObject;
+ if (myVectorX && !myVectorY)
+ Group2->PushButton3->click();
}
- 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 ) {
- myPoint = aSelectedObj;
- myEditCurrentArgument->setText( aName );
- if (!myPoint->_is_nil() && Group2->LineEdit2->text() == "")
- Group2->PushButton2->click();
- }
- else if (myEditCurrentArgument == Group2->LineEdit2) {
- myVectorX = aSelectedObj;
- myEditCurrentArgument->setText( aName );
- if (!myVectorX->_is_nil() && Group2->LineEdit3->text() == "")
- Group2->PushButton3->click();
- }
- else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
- myVectorY = aSelectedObj;
- myEditCurrentArgument->setText( aName );
- if (!myVectorX->_is_nil() && Group2->LineEdit1->text() == "")
- Group2->PushButton1->click();
- }
- }
+ else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
+ myVectorY = aSelectedObject;
+ if (myVectorY && !myPoint)
+ Group2->PushButton1->click();
}
}
}
else {
if ( getConstructorId() == 1 ) {
- myShape = GEOM::GEOM_Object::_nil();
- } else if ( getConstructorId() == 2 ) {
+ myShape.nullify();
+ }
+ else if ( getConstructorId() == 2 ) {
if ( myEditCurrentArgument == Group2->LineEdit1 )
- myPoint = GEOM::GEOM_Object::_nil();
+ myPoint.nullify();
else if ( myEditCurrentArgument == Group2->LineEdit2 )
- myVectorX = GEOM::GEOM_Object::_nil();
+ myVectorX.nullify();
else if ( myEditCurrentArgument == Group2->LineEdit3 )
- myVectorY = GEOM::GEOM_Object::_nil();
+ myVectorY.nullify();
}
}
onSelectionDone();
}
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void BasicGUI_MarkerDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
-
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
-}
-
//=================================================================================
// function : onActivate()
// purpose :
//=================================================================================
bool BasicGUI_MarkerDlg::isValid( QString& msg )
{
- const int id = getConstructorId();
- switch ( id ) {
- case 0: {
- gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ),
- v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
+ bool ok = false;
+ switch ( getConstructorId() ) {
+ case 0: {
+ gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->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()
- // Vectors shouldn't be checked for being orthogonal here!
- if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
- isOk = !v1.IsParallel( v2, Precision::Angular() );
- if ( !isOk )
- msg += tr( "VEC_PARALLEL" );
- }
- bool ok = true;
- for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
- ok = anIter.value()->isValid( msg, !IsPreview()) && ok;
- return isOk && ok;
+ // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
+ // Vectors shouldn't be checked for being orthogonal here!
+ if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
+ ok = !v1.IsParallel( v2, Precision::Angular() );
+ if ( !ok )
+ msg += tr( "VEC_PARALLEL" );
}
- case 1:
- return !myShape->_is_nil();
- case 2:
- return !myPoint->_is_nil() && !myVectorX->_is_nil() && !myVectorY->_is_nil();
+ for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end() && ok; ++anIter )
+ ok = anIter.value()->isValid( msg, !IsPreview()) && ok;
+ break;
}
- return false;
+ case 1:
+ ok = myShape;
+ break;
+ case 2:
+ ok = myPoint && myVectorX && myVectorY;
+ break;
+ default:
+ break;
+ }
+ return ok;
}
//=================================================================================
aParameters<<myData[ DY2 ]->text();
aParameters<<myData[ DZ2 ]->text();
} else if (id == 1) {
- anObj = anOper->MakeMarkerFromShape( myShape );
+ anObj = anOper->MakeMarkerFromShape( myShape.get() );
} else if (id == 2) {
- anObj = anOper->MakeMarkerPntTwoVec( myPoint, myVectorX, myVectorY );
+ anObj = anOper->MakeMarkerPntTwoVec( myPoint.get(), myVectorX.get(), myVectorY.get() );
}
if ( !anObj->_is_nil() ) {
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
// purpose :
#ifndef BASICGUI_MARKERDLG_H
#define BASICGUI_MARKERDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
#include <QMap>
const bool = true,
const bool = true,
const double = -1 );
+ virtual void addSubshapesToStudy();
private:
void enterEvent( QEvent* );
void onSelectionDone0();
- GEOM::GEOM_Object_var myShape;
- GEOM::GEOM_Object_var myPoint;
- GEOM::GEOM_Object_var myVectorX;
- GEOM::GEOM_Object_var myVectorY;
+ GEOM::GeomObjPtr myShape;
+ GEOM::GeomObjPtr myPoint;
+ GEOM::GeomObjPtr myVectorX;
+ GEOM::GeomObjPtr myVectorY;
private slots:
void onOk();
void onSelectionDone();
void onValueChanged( double );
void ConstructorsClicked( int );
- void LineEditReturnPressed();
void SetEditCurrentArgument();
private:
GroupLCS->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) );
GroupLCS->RadioButton2->setText( tr( "GEOM_WPLANE_OYZ" ) );
GroupLCS->RadioButton3->setText( tr( "GEOM_WPLANE_OZX" ) );
+ GroupLCS->LineEdit1->setReadOnly( true );
GroupLCS->PushButton1->setIcon( image3 );
GroupLCS->PushButton1->setDown( true );
/* init variables */
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 );
myOriginType = 1;
connect( GroupLCS->RadioButton2, 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( Group3Pnts->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupFace->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
void BasicGUI_PlaneDlg::ConstructorsClicked( int constructorId )
{
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 ) {
case 0: /* plane from a point and a direction (vector, edge...) */
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) {
- if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) myVec1 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) myVec2 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) myLCS = GEOM::GEOM_Object::_nil();
+ if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint.nullify();
+ else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3.nullify();
+ else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace.nullify();
+ else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) myVec1.nullify();
+ else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) myVec2.nullify();
+ else if ( myEditCurrentArgument == GroupLCS->LineEdit1 ) myLCS.nullify();
displayPreview();
return;
}
- // nbSel == 1
- 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)
- aNeedType = TopAbs_EDGE;
- else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
- aNeedType = TopAbs_FACE;
- else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
- aNeedType = TopAbs_FACE;
-
- TopoDS_Shape aShape;
- if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
- 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 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 = "";
- }
- }
- }
-
+ TopAbs_ShapeEnum aNeedType;
+ if ( myEditCurrentArgument == GroupPntDir->LineEdit2 || myEditCurrentArgument == Group2Vec->LineEdit1 || myEditCurrentArgument == Group2Vec->LineEdit2)
+ aNeedType = TopAbs_EDGE;
+ else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
+ aNeedType = TopAbs_FACE;
+ else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
+ aNeedType = TopAbs_FACE;
+ else
+ aNeedType = TopAbs_VERTEX;
+ GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
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 ) {
- myPoint = aSelectedObject;
- if ( !myPoint->_is_nil() && myDir->_is_nil() )
+ if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) {
+ myPoint = aSelectedObject;
+ if ( myPoint && !myDir )
GroupPntDir->PushButton2->click();
}
else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) {
- myDir = aSelectedObject;
- if ( !myDir->_is_nil() && myPoint->_is_nil() )
+ myDir = aSelectedObject;
+ if ( myDir && !myPoint )
GroupPntDir->PushButton1->click();
}
else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
myPoint1 = aSelectedObject;
- if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
+ if ( myPoint1 && !myPoint2 )
Group3Pnts->PushButton2->click();
}
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
myPoint2 = aSelectedObject;
- if ( !myPoint2->_is_nil() && myPoint3->_is_nil() )
+ if ( myPoint2 && !myPoint3 )
Group3Pnts->PushButton3->click();
}
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
myPoint3 = aSelectedObject;
- if ( !myPoint3->_is_nil() && myPoint1->_is_nil() )
+ if ( myPoint3 && !myPoint1 )
Group3Pnts->PushButton1->click();
}
else if ( myEditCurrentArgument == GroupFace->LineEdit1 )
myFace = aSelectedObject;
else if ( myEditCurrentArgument == Group2Vec->LineEdit1 ) {
myVec1 = aSelectedObject;
- if ( !myVec1->_is_nil() && myVec2->_is_nil() )
+ if ( myVec1 && !myVec2 )
Group2Vec->PushButton2->click();
} else if ( myEditCurrentArgument == Group2Vec->LineEdit2 ) {
myVec2 = aSelectedObject;
- if ( !myVec2->_is_nil() && myVec1->_is_nil() )
+ if ( myVec2 && !myVec1 )
Group2Vec->PushButton1->click();
} else if ( myEditCurrentArgument == GroupLCS->LineEdit1 )
myLCS = aSelectedObject;
-
}
displayPreview();
}
-//=================================================================================
-// 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()
// purpose :
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
// purpose :
//=================================================================================
bool BasicGUI_PlaneDlg::isValid( QString& msg )
{
- const int id = getConstructorId();
+ bool ok = false;
if ( getSize() <= 0 ) {
msg = QString( "Please, enter size greater than 0." );
- return false;
}
-
- if ( id == 0 ) {
- bool ok = GroupPntDir->SpinBox_DX->isValid( msg, !IsPreview() );
- return !CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir ) && ok;
- }
- 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;
+ else {
+ switch ( getConstructorId() ) {
+ case 0:
+ 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;
+ }
}
- return false;
+ return ok;
}
//=================================================================================
switch ( getConstructorId() ) {
case 0 :
- anObj = anOper->MakePlanePntVec( myPoint, myDir, getSize() );
+ anObj = anOper->MakePlanePntVec( myPoint.get(), myDir.get(), getSize() );
res = true;
break;
case 1 :
- anObj = anOper->MakePlaneThreePnt( myPoint1, myPoint2, myPoint3, getSize() );
+ anObj = anOper->MakePlaneThreePnt( myPoint1.get(), myPoint2.get(), myPoint3.get(), getSize() );
res = true;
break;
case 2 :
- anObj = anOper->MakePlaneFace( myFace, getSize() );
+ anObj = anOper->MakePlaneFace( myFace.get(), getSize() );
res = true;
break;
case 3 :
- anObj = anOper->MakePlane2Vec( myVec1, myVec2, getSize() );
+ anObj = anOper->MakePlane2Vec( myVec1.get(), myVec2.get(), getSize() );
res = true;
break;
case 4 :
- anObj = anOper->MakePlaneLCS( myLCS, getSize(), myOriginType );
+ anObj = anOper->MakePlaneLCS( myLCS.get(), getSize(), myOriginType );
res = true;
break;
}
//=================================================================================
void BasicGUI_PlaneDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
switch ( getConstructorId() ) {
case 0:
- objMap[GroupPntDir->LineEdit1->text()] = myPoint;
- objMap[GroupPntDir->LineEdit2->text()] = myDir;
+ GEOMBase::PublishSubObject( myPoint.get() );
+ GEOMBase::PublishSubObject( myDir.get() );
break;
case 1:
- objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
- objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
- objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
+ GEOMBase::PublishSubObject( myPoint1.get() );
+ GEOMBase::PublishSubObject( myPoint2.get() );
+ GEOMBase::PublishSubObject( myPoint3.get() );
break;
case 2:
- objMap[GroupFace->LineEdit1->text()] = myFace;
+ GEOMBase::PublishSubObject( myFace.get() );
break;
case 3:
- objMap[Group2Vec->LineEdit1->text()] = myVec1;
- objMap[Group2Vec->LineEdit2->text()] = myVec2;
+ GEOMBase::PublishSubObject( myVec1.get() );
+ GEOMBase::PublishSubObject( myVec2.get() );
+ break;
+ case 4:
+ GEOMBase::PublishSubObject( myLCS.get() );
break;
+ default:
+ break;
}
- addSubshapesToFather( objMap );
}
#ifndef BASICGUI_PLANEDLG_H
#define BASICGUI_PLANEDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel1Spin;
class DlgRef_2Sel1Spin;
int myOriginType;
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_3Sel1Spin* Group3Pnts;
void DeactivateActiveDialog();
void SelectionIntoArgument();
- void LineEditReturnPressed();
void SetEditCurrentArgument();
void ConstructorsClicked( int );
void ValueChangedInSpinBox( double );
#define SPACING 6
#define MARGIN 9
+enum { SelectEdge, SelectWire };
+
//=================================================================================
// class : BasicGUI_PointDlg()
// purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the
myBtnPopup = new QMenu(this);
QIcon ico_line = QIcon( image6 );
QIcon ico_wire = QIcon( image7 );
- myActions[myBtnPopup->addAction( ico_line, tr( "GEOM_EDGE" ) )] = 0;
- myActions[myBtnPopup->addAction( ico_wire, tr( "GEOM_WIRE" ) )] = 1;
+ myActions[myBtnPopup->addAction( ico_line, tr( "GEOM_EDGE" ) )] = SelectEdge;
+ myActions[myBtnPopup->addAction( ico_wire, tr( "GEOM_WIRE" ) )] = SelectWire;
GroupLineIntersection = new DlgRef_2Sel( centralWidget() );
GroupLineIntersection->GroupBox1->setTitle( tr( "GEOM_LINE_INTERSECTION" ) );
GroupLineIntersection->LineEdit1->setEnabled( true );
GroupLineIntersection->LineEdit2->setEnabled( false );
- myEdge = GEOM::GEOM_Object::_nil();
- myRefPoint = GEOM::GEOM_Object::_nil();
+ myEdge.nullify();
+ myFace.nullify();
+ myRefPoint.nullify();
+ myLine1.nullify();
+ myLine2.nullify();
myNeedType = TopAbs_VERTEX;
myEditCurrentArgument = 0;
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
connect( myParamCoord, SIGNAL( buttonClicked( int ) ), this, SLOT( ClickParamCoord( int ) ) );
- 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->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
+ connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( GroupOnSurface->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( GroupLineIntersection->PushButton1, SIGNAL( pressed() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( GroupLineIntersection->PushButton2, SIGNAL( pressed() ), this, SLOT( SetEditCurrentArgument() ) );
- connect( myBtnPopup, SIGNAL( triggered( QAction* ) ), SLOT( onBtnPopup( QAction* ) ) );
- connect( GroupLineIntersection->PushButton1, 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( GroupOnSurface->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
case GEOM_POINT_XYZ:
{
globalSelection(); // close local contexts, if any
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+ myNeedType = TopAbs_VERTEX;
+ localSelection( GEOM::GEOM_Object::_nil(), myNeedType );
GroupRefPoint->hide();
GroupOnCurve->hide();
case GEOM_POINT_REF:
{
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->setText( "" );
- myRefPoint = GEOM::GEOM_Object::_nil();
+ myRefPoint.nullify();
GroupRefPoint->PushButton1->setDown(true);
myParamGroup->hide();
GroupXYZ->hide();
case GEOM_POINT_EDGE:
{
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->setText( "" );
- myEdge = GEOM::GEOM_Object::_nil();
+ myEdge.nullify();
GroupOnCurve->PushButton1->setDown(true);
GroupRefPoint->hide();
GroupLineIntersection->hide();
case GEOM_POINT_INTINT:
{
globalSelection(); // close local contexts, if any
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
myNeedType = TopAbs_EDGE;
+ localSelection( GEOM::GEOM_Object::_nil(), myNeedType );
myEditCurrentArgument = GroupLineIntersection->LineEdit1;
GroupLineIntersection->LineEdit1->setText( "" );
GroupLineIntersection->LineEdit2->setText( "" );
GroupLineIntersection->LineEdit1->setEnabled( true );
GroupLineIntersection->LineEdit2->setEnabled( false );
- myLine1 = GEOM::GEOM_Object::_nil();
- myLine2 = GEOM::GEOM_Object::_nil();
+ myLine1.nullify();
+ myLine2.nullify();
GroupLineIntersection->PushButton1->setDown(true);
GroupLineIntersection->PushButton2->setDown(false);
myParamGroup->hide();
case GEOM_POINT_SURF:
{
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->setText( "" );
- myFace = GEOM::GEOM_Object::_nil();
+ myFace.nullify();
GroupOnSurface->PushButton1->setDown(true);
GroupRefPoint->hide();
GroupOnCurve->hide();
myX->setText( "" );
myY->setText( "" );
myZ->setText( "" );
- myRefPoint = myEdge = myFace = GEOM::GEOM_Object::_nil();
+ myRefPoint.nullify();
+ myEdge.nullify();
+ myFace.nullify();
} else if ( id == GEOM_POINT_INTINT ) {
myEditCurrentArgument->setText( "" );
if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 )
- myLine1 = GEOM::GEOM_Object::_nil();
+ myLine1.nullify();
else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 )
- myLine2 = GEOM::GEOM_Object::_nil();
+ myLine2.nullify();
}
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- 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;
- if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
- if ( id == GEOM_POINT_XYZ || id == GEOM_POINT_REF)
- 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;
-
- if ( id == GEOM_POINT_XYZ ) {
- gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
- GroupXYZ->SpinBox_DX->setValue( aPnt.X() );
- GroupXYZ->SpinBox_DY->setValue( aPnt.Y() );
- GroupXYZ->SpinBox_DZ->setValue( aPnt.Z() );
- }
- else if ( id == GEOM_POINT_REF ) {
- myRefPoint = aSelectedObject;
- GroupRefPoint->LineEdit1->setText( aName );
- }
- else if ( id == GEOM_POINT_EDGE ) {
- myEdge = aSelectedObject;
- GroupOnCurve->LineEdit1->setText( aName );
- }
- else if ( id == GEOM_POINT_INTINT ) {
- myEditCurrentArgument->setText( aName );
- if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) {
- myLine1 = aSelectedObject;
- if ( !myLine1->_is_nil() && myLine2->_is_nil() ) {
- GroupLineIntersection->PushButton2->setMenu( 0 );
- GroupLineIntersection->PushButton2->click();
- GroupLineIntersection->PushButton2->setDown(true);
- GroupLineIntersection->PushButton2->setMenu( myBtnPopup );
- }
- }
- else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) {
- myLine2 = aSelectedObject;
- if ( !myLine2->_is_nil() && myLine1->_is_nil() ) {
- GroupLineIntersection->PushButton1->setMenu( 0 );
- GroupLineIntersection->PushButton1->click();
- GroupLineIntersection->PushButton1->setDown(true);
- GroupLineIntersection->PushButton1->setMenu( myBtnPopup );
- }
- }
+ GEOM::GeomObjPtr aSelectedObject = getSelected( myNeedType );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+ myBusy = true;
+ if ( id == GEOM_POINT_XYZ ) {
+ gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
+ GroupXYZ->SpinBox_DX->setValue( aPnt.X() );
+ GroupXYZ->SpinBox_DY->setValue( aPnt.Y() );
+ GroupXYZ->SpinBox_DZ->setValue( aPnt.Z() );
+ }
+ else if ( id == GEOM_POINT_REF ) {
+ myRefPoint = aSelectedObject;
+ GroupRefPoint->LineEdit1->setText( aName );
+ }
+ else if ( id == GEOM_POINT_EDGE ) {
+ myEdge = aSelectedObject;
+ GroupOnCurve->LineEdit1->setText( aName );
+ }
+ else if ( id == GEOM_POINT_INTINT ) {
+ myEditCurrentArgument->setText( aName );
+ if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) {
+ myLine1 = aSelectedObject;
+ if ( myLine1 && !myLine2 ) {
+ GroupLineIntersection->PushButton2->setMenu( 0 );
+ GroupLineIntersection->PushButton2->click();
+ GroupLineIntersection->PushButton2->setDown(true);
+ GroupLineIntersection->PushButton2->setMenu( myBtnPopup );
+ }
}
- else if ( id == GEOM_POINT_SURF )
- {
- myFace = aSelectedObject;
- GroupOnSurface->LineEdit1->setText( aName );
+ else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) {
+ myLine2 = aSelectedObject;
+ if ( myLine2 && !myLine1 ) {
+ GroupLineIntersection->PushButton1->setMenu( 0 );
+ GroupLineIntersection->PushButton1->click();
+ GroupLineIntersection->PushButton1->setDown(true);
+ GroupLineIntersection->PushButton1->setMenu( myBtnPopup );
+ }
}
- myBusy = false;
}
+ else if ( id == GEOM_POINT_SURF ) {
+ myFace = aSelectedObject;
+ GroupOnSurface->LineEdit1->setText( aName );
+ }
+ myBusy = false;
}
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()
// purpose :
//=================================================================================
bool BasicGUI_PointDlg::isValid( QString& msg )
{
- const int id = getConstructorId();
- if ( id == GEOM_POINT_XYZ ) {
- bool ok = true;
- 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 ok;
- }
- else if ( id == GEOM_POINT_REF ) {
- bool ok = true;
- ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
- ok = GroupRefPoint->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
-
- return !myRefPoint->_is_nil() && ok;
- }
- else if ( id == GEOM_POINT_EDGE ) {
- bool ok = true;
+ bool ok = false;
+ switch ( getConstructorId() ) {
+ case GEOM_POINT_XYZ :
+ ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) &&
+ GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() );
+ break;
+ case GEOM_POINT_REF:
+ ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) &&
+ GroupRefPoint->SpinBox_DZ->isValid( msg, !IsPreview() ) &&
+ myRefPoint;
+ break;
+ case GEOM_POINT_EDGE:
if ( myParamCoord->checkedId() == PARAM_VALUE || myParamCoord->checkedId() == LENGTH_VALUE )
ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
- 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 !myEdge->_is_nil() && 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;
+ else
+ ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) &&
+ 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 false;
+ return ok;
}
//=================================================================================
aParameters << GroupRefPoint->SpinBox_DY->text();
aParameters << GroupRefPoint->SpinBox_DZ->text();
- anObj = anOper->MakePointWithReference( myRefPoint, dx, dy, dz );
+ anObj = anOper->MakePointWithReference( myRefPoint.get(), dx, dy, dz );
res = true;
break;
}
case GEOM_POINT_EDGE :
{
if ( myParamCoord->checkedId() == PARAM_VALUE ) {
- anObj = anOper->MakePointOnCurve( myEdge, getParameter() );
+ anObj = anOper->MakePointOnCurve( myEdge.get(), getParameter() );
aParameters<<GroupOnCurve->SpinBox_DX->text();
}
else if ( myParamCoord->checkedId() == LENGTH_VALUE ) {
bool reversed = GroupOnCurve->CheckButton1->isChecked();
- anObj = anOper->MakePointOnCurveByLength( myEdge, getParameter(), reversed );
+ anObj = anOper->MakePointOnCurveByLength( myEdge.get(), getParameter(), reversed );
aParameters<<GroupOnCurve->SpinBox_DX->text();
aParameters<<QString::number( reversed );
aParameters << GroupXYZ->SpinBox_DY->text();
aParameters << GroupXYZ->SpinBox_DZ->text();
- anObj = anOper->MakePointOnCurveByCoord( myEdge, x, y, z );
+ anObj = anOper->MakePointOnCurveByCoord( myEdge.get(), x, y, z );
}
res = true;
break;
}
case GEOM_POINT_INTINT :
- anObj = anOper->MakePointOnLinesIntersection( myLine1, myLine2 );
+ anObj = anOper->MakePointOnLinesIntersection( myLine1.get(), myLine2.get() );
if ( !anObj->_is_nil() ) {
QString aName = getNewObjectName();
if ( anObj->GetShapeType() == GEOM::COMPOUND && aName.startsWith("Vertex") )
case GEOM_POINT_SURF :
{
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_DY->text();
} else {
aParameters << GroupXYZ->SpinBox_DY->text();
aParameters << GroupXYZ->SpinBox_DZ->text();
- anObj = anOper->MakePointOnSurfaceByCoord( myFace, x, y, z );
+ anObj = anOper->MakePointOnSurfaceByCoord( myFace.get(), x, y, z );
}
res = true;
break;
//=================================================================================
void BasicGUI_PointDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
switch ( getConstructorId() ) {
- case GEOM_POINT_XYZ:
- break;
case GEOM_POINT_REF:
- objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint;
+ GEOMBase::PublishSubObject( myRefPoint.get() );
break;
case GEOM_POINT_EDGE:
- objMap[GroupOnCurve->LineEdit1->text()] = myEdge;
+ GEOMBase::PublishSubObject( myEdge.get() );
break;
case GEOM_POINT_INTINT:
- objMap[GroupLineIntersection->LineEdit1->text()] = myLine1;
- objMap[GroupLineIntersection->LineEdit2->text()] = myLine2;
+ GEOMBase::PublishSubObject( myLine1.get() );
+ GEOMBase::PublishSubObject( myLine2.get() );
break;
case GEOM_POINT_SURF:
- objMap[GroupOnSurface->LineEdit1->text()] = myFace;
+ GEOMBase::PublishSubObject( myFace.get() );
+ break;
+ default:
break;
}
- addSubshapesToFather( objMap );
}
//=================================================================================
//=================================================================================
void BasicGUI_PointDlg::onBtnPopup( QAction* a )
{
- int index = myActions[a];
globalSelection(); // close local contexts, if any
- QString type;
- if ( index == 0 )
- myNeedType = TopAbs_EDGE;
- else
- myNeedType = TopAbs_WIRE;
-
+ myNeedType = myActions[a] == SelectEdge ? TopAbs_EDGE : TopAbs_WIRE;
localSelection( GEOM::GEOM_Object::_nil(), myNeedType );
}
#ifndef BASICGUI_POINTDLG_H
#define BASICGUI_POINTDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
#include <QMap>
class DlgRef_1Sel1Spin1Check;
void updateParamCoord(bool theIsUpdate);
private:
- GEOM::GEOM_Object_var myEdge;
- GEOM::GEOM_Object_var myFace;
- GEOM::GEOM_Object_var myRefPoint;
- GEOM::GEOM_Object_var myLine1;
- GEOM::GEOM_Object_var myLine2;
+ GEOM::GeomObjPtr myEdge;
+ GEOM::GeomObjPtr myFace;
+ GEOM::GeomObjPtr myRefPoint;
+ GEOM::GeomObjPtr myLine1;
+ GEOM::GeomObjPtr myLine2;
bool myBusy;
bool ClickOnApply();
void ActivateThisDialog();
void DeactivateActiveDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ConstructorsClicked( int );
/* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1;
- myPoint1 = GEOM::GEOM_Object::_nil();
- myPoint2 = GEOM::GEOM_Object::_nil();
+ myPoint1.nullify();
+ myPoint2.nullify();
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
connect( GroupPoints->PushButton1, 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_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupDimensions->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
void BasicGUI_VectorDlg::ConstructorsClicked( int constructorId )
{
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
- myPoint1 = GEOM::GEOM_Object::_nil();
- myPoint2 = GEOM::GEOM_Object::_nil();
+ myPoint1.nullify();
+ myPoint2.nullify();
switch ( constructorId ) {
case 0:
void BasicGUI_VectorDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText( "" );
-
+
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPoints->LineEdit1)
- myPoint1 = GEOM::GEOM_Object::_nil();
+ myPoint1.nullify();
else if (myEditCurrentArgument == GroupPoints->LineEdit2)
- myPoint2 = GEOM::GEOM_Object::_nil();
+ myPoint2.nullify();
return;
}
- // nbSel == 1
- GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
- if (!CORBA::is_nil(aSelectedObject) ) {
- QString aName = GEOMBase::GetName(aSelectedObject);
-
- TopoDS_Shape aShape;
- if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
- 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 = "";
- }
- }
- }
-
+ GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
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;
- if (!myPoint1->_is_nil() && myPoint2->_is_nil())
+ if (myPoint1 && !myPoint2)
GroupPoints->PushButton2->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myPoint2 = aSelectedObject;
- if (!myPoint2->_is_nil() && myPoint1->_is_nil())
+ if (myPoint2 && !myPoint1)
GroupPoints->PushButton1->click();
}
}
}
-//=================================================================================
-// 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()
// purpose :
//=================================================================================
bool BasicGUI_VectorDlg::isValid( QString& msg )
{
+ bool ok = false;
if(getConstructorId() == 0)
- return !myPoint1->_is_nil() && !myPoint2->_is_nil();
+ ok = myPoint1 && myPoint2;
else if(getConstructorId() == 1)
{
- bool ok = true;
- ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
- return ok;
+ ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() );
}
- return false;
+ return ok;
}
//=================================================================================
switch ( getConstructorId() ) {
case 0 :
{
- anObj = anOper->MakeVectorTwoPnt( myPoint1, myPoint2 );
+ anObj = anOper->MakeVectorTwoPnt( myPoint1.get(), myPoint2.get() );
res = true;
break;
}
//=================================================================================
void BasicGUI_VectorDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
- switch ( getConstructorId() ) {
- case 0:
- objMap[GroupPoints->LineEdit1->text()] = myPoint1;
- objMap[GroupPoints->LineEdit2->text()] = myPoint2;
- break;
- case 1:
- return;
+ if ( getConstructorId() == 0 ) {
+ GEOMBase::PublishSubObject( myPoint1.get() );
+ GEOMBase::PublishSubObject( myPoint2.get() );
}
- addSubshapesToFather( objMap );
}
#ifndef BASICGUI_VECTORDLG_H
#define BASICGUI_VECTORDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel;
class DlgRef_3Spin1Check;
void Init();
void enterEvent( QEvent* );
- GEOM::GEOM_Object_var myPoint1;
- GEOM::GEOM_Object_var myPoint2;
+ GEOM::GeomObjPtr myPoint1;
+ GEOM::GeomObjPtr myPoint2;
DlgRef_2Sel* GroupPoints;
DlgRef_3Spin1Check* GroupDimensions;
void ActivateThisDialog();
void DeactivateActiveDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ConstructorsClicked( int );
myConstructorId = constructorId;
// init fields
- myFace1 = myFace2 = GEOM::GEOM_Object::_nil();
- myFace3 = myFace4 = myFace5 = myFace6 = myFace1;
+ myFace1.nullify();
+ myFace2.nullify();
+ myFace3.nullify();
+ myFace4.nullify();
+ myFace5.nullify();
+ myFace6.nullify();
switch (constructorId) {
case 0:
void BlocksGUI_BlockDlg::SelectionIntoArgument()
{
erasePreview();
- myEditCurrentArgument->setText("");
-
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- 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
+ GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_FACE );
TopoDS_Shape aShape;
- if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
- {
- 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
- }
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+ myEditCurrentArgument->setText( aName );
+ if ( myEditCurrentArgument == Group2F->LineEdit1 ) {
+ myFace1 = aSelectedObject;
+ if (!myFace2) Group2F->PushButton2->click();
}
- else // Global Selection
- {
- if (aShape.ShapeType() != TopAbs_FACE) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- }
+ else if ( myEditCurrentArgument == Group2F->LineEdit2 ) {
+ myFace2 = aSelectedObject;
+ if (!myFace1) Group2F->PushButton1->click();
+ }
+ else if ( myEditCurrentArgument == Group6F->LineEdit1 ) {
+ myFace1 = aSelectedObject;
+ 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 (!myFace6) Group6F->PushButton6->click();
+ }
+ else if ( myEditCurrentArgument == Group6F->LineEdit2 ) {
+ myFace2 = aSelectedObject;
+ 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 (!myFace1) Group6F->PushButton1->click();
+ }
+ else if ( myEditCurrentArgument == Group6F->LineEdit3 ) {
+ myFace3 = aSelectedObject;
+ 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 (!myFace2) Group6F->PushButton2->click();
+ }
+ else if ( myEditCurrentArgument == Group6F->LineEdit4 ) {
+ myFace4 = aSelectedObject;
+ 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 (!myFace3) Group6F->PushButton3->click();
+ }
+ else if ( myEditCurrentArgument == Group6F->LineEdit5 ) {
+ myFace5 = aSelectedObject;
+ 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 (!myFace4) Group6F->PushButton4->click();
+ }
+ else if ( myEditCurrentArgument == Group6F->LineEdit6 ) {
+ myFace6 = aSelectedObject;
+ 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 (!myFace5) Group6F->PushButton5->click();
}
}
-
- myEditCurrentArgument->setText(aName);
-
- if (myEditCurrentArgument == Group2F->LineEdit1) {
- myFace1 = aSelectedObject;
- if (!myFace1->_is_nil() && myFace2->_is_nil())
- Group2F->PushButton2->click();
- }
- else if (myEditCurrentArgument == Group2F->LineEdit2) {
- myFace2 = aSelectedObject;
- if (!myFace2->_is_nil() && myFace1->_is_nil())
- Group2F->PushButton1->click();
- }
- else if (myEditCurrentArgument == Group6F->LineEdit1) {
- myFace1 = aSelectedObject;
- if (!myFace1->_is_nil() && myFace2->_is_nil())
- Group6F->PushButton2->click();
- }
- else if (myEditCurrentArgument == Group6F->LineEdit2) {
- myFace2 = aSelectedObject;
- if (!myFace2->_is_nil() && myFace3->_is_nil())
- Group6F->PushButton3->click();
- }
- else if (myEditCurrentArgument == Group6F->LineEdit3) {
- myFace3 = aSelectedObject;
- if (!myFace3->_is_nil() && myFace4->_is_nil())
- Group6F->PushButton4->click();
- }
- else if (myEditCurrentArgument == Group6F->LineEdit4) {
- myFace4 = aSelectedObject;
- if (!myFace4->_is_nil() && myFace5->_is_nil())
- Group6F->PushButton5->click();
- }
- else if (myEditCurrentArgument == Group6F->LineEdit5) {
- myFace5 = aSelectedObject;
- if (!myFace5->_is_nil() && myFace6->_is_nil())
- Group6F->PushButton6->click();
- }
- else if (myEditCurrentArgument == Group6F->LineEdit6) {
- myFace6 = aSelectedObject;
- if (!myFace6->_is_nil() && myFace1->_is_nil())
- Group6F->PushButton1->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();
// function : isValid
// purpose :
//=================================================================================
-bool BlocksGUI_BlockDlg::isValid (QString&)
+bool BlocksGUI_BlockDlg::isValid(QString&)
{
bool ok = false;
switch (getConstructorId()) {
case 0:
- ok = !(myFace1->_is_nil() || myFace2->_is_nil());
+ ok = myFace1 && myFace2;
break;
case 1:
- ok = !(myFace1->_is_nil() || myFace2->_is_nil() ||
- myFace3->_is_nil() || myFace4->_is_nil() ||
- myFace5->_is_nil() || myFace6->_is_nil());
+ ok = myFace1 && myFace2 && myFace3 && myFace4 && myFace5 && myFace6;
break;
default:
break;
switch (getConstructorId()) {
case 0:
- if (!CORBA::is_nil(myFace1) && !CORBA::is_nil(myFace2)) {
- anObj = anOper->MakeHexa2Faces(myFace1, myFace2);
+ if ( myFace1 && myFace2 ) {
+ anObj = anOper->MakeHexa2Faces(myFace1.get(), myFace2.get());
res = true;
}
break;
case 1:
- if (!CORBA::is_nil(myFace1) && !CORBA::is_nil(myFace2) &&
- !CORBA::is_nil(myFace3) && !CORBA::is_nil(myFace4) &&
- !CORBA::is_nil(myFace5) && !CORBA::is_nil(myFace6)) {
- anObj = anOper->MakeHexa(myFace1, myFace2, myFace3, myFace4, myFace5, myFace6);
+ if ( myFace1 && myFace2 && myFace3 && myFace4 && myFace5 && myFace6 ) {
+ anObj = anOper->MakeHexa(myFace1.get(), myFace2.get(), myFace3.get(), myFace4.get(), myFace5.get(), myFace6.get());
res = true;
}
break;
//=================================================================================
void BlocksGUI_BlockDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
switch (getConstructorId()) {
case 0:
- objMap[Group2F->LineEdit1->text()] = myFace1;
- objMap[Group2F->LineEdit2->text()] = myFace2;
+ GEOMBase::PublishSubObject( myFace1.get() );
+ GEOMBase::PublishSubObject( myFace2.get() );
break;
case 1:
- objMap[Group6F->LineEdit1->text()] = myFace1;
- objMap[Group6F->LineEdit2->text()] = myFace2;
- objMap[Group6F->LineEdit3->text()] = myFace3;
- objMap[Group6F->LineEdit4->text()] = myFace4;
- objMap[Group6F->LineEdit5->text()] = myFace5;
- objMap[Group6F->LineEdit6->text()] = myFace6;
+ GEOMBase::PublishSubObject( myFace1.get() );
+ GEOMBase::PublishSubObject( myFace2.get() );
+ GEOMBase::PublishSubObject( myFace3.get() );
+ GEOMBase::PublishSubObject( myFace4.get() );
+ GEOMBase::PublishSubObject( myFace5.get() );
+ GEOMBase::PublishSubObject( myFace6.get() );
+ break;
+ default:
break;
}
- addSubshapesToFather(objMap);
}
#ifndef BLOCKSGUI_BLOCKDLG_H
#define BLOCKSGUI_BLOCKDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel;
class DlgRef_6Sel;
private:
int myConstructorId;
- GEOM::GEOM_Object_var myFace1, myFace2;
- GEOM::GEOM_Object_var myFace3, myFace4, myFace5, myFace6;
+ GEOM::GeomObjPtr myFace1, myFace2;
+ GEOM::GeomObjPtr myFace3, myFace4, myFace5, myFace6;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
myConstructorId = constructorId;
// init fields
- myShape1 = myShape2 = GEOM::GEOM_Object::_nil();
- myShape3 = myShape4 = myShape1;
+ myShape1.nullify();
+ myShape2.nullify();
+ myShape3.nullify();
+ myShape4.nullify();
// clear line edits
QMap<int, QLineEdit*>::iterator anIterLE;
}
}
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
-
TopAbs_ShapeEnum aType = TopAbs_EDGE;
if (aCurrFocus == Vertex1 || aCurrFocus == Vertex2 ||
aCurrFocus == Vertex3 || aCurrFocus == Vertex4)
aType = TopAbs_VERTEX;
- QString aName;
- 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;
- if (GEOMBase::GetShape(anObj, aShape, TopAbs_SHAPE) && !aShape.IsNull())
- {
- 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 = "";
- }
- }
- }
+ GEOM::GeomObjPtr aSelectedObject = getSelected( aType );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+ myEditCurrentArgument->setText( aName );
+ switch (aCurrFocus) {
+ // four vertices
+ case Vertex1:
+ myShape1 = aSelectedObject;
+ if (!myShape2) mySelBtn[Vertex2]->click();
+ else if (!myShape3) mySelBtn[Vertex3]->click();
+ else if (!myShape4) mySelBtn[Vertex4]->click();
+ break;
+ case Vertex2:
+ myShape2 = aSelectedObject;
+ if (!myShape3) mySelBtn[Vertex3]->click();
+ else if (!myShape4) mySelBtn[Vertex4]->click();
+ else if (!myShape1) mySelBtn[Vertex1]->click();
+ break;
+ case Vertex3:
+ myShape3 = aSelectedObject;
+ if (!myShape4) mySelBtn[Vertex4]->click();
+ else if (!myShape1) mySelBtn[Vertex1]->click();
+ else if (!myShape2) mySelBtn[Vertex2]->click();
+ break;
+ case Vertex4:
+ myShape4 = aSelectedObject;
+ if (!myShape1) mySelBtn[Vertex1]->click();
+ else if (!myShape2) mySelBtn[Vertex2]->click();
+ else if (!myShape3) mySelBtn[Vertex3]->click();
+ break;
+ // two edges
+ case Edge12:
+ myShape1 = aSelectedObject;
+ if (!myShape2) mySelBtn[Edge22]->click();
+ break;
+ case Edge22:
+ myShape2 = aSelectedObject;
+ if (!myShape1) mySelBtn[Edge12]->click();
+ break;
+ // four edges
+ case Edge14:
+ myShape1 = aSelectedObject;
+ if (!myShape2) mySelBtn[Edge24]->click();
+ else if (!myShape3) mySelBtn[Edge34]->click();
+ else if (!myShape4) mySelBtn[Edge44]->click();
+ break;
+ case Edge24:
+ myShape2 = aSelectedObject;
+ if (!myShape3) mySelBtn[Edge34]->click();
+ else if (!myShape4) mySelBtn[Edge44]->click();
+ else if (!myShape1) mySelBtn[Edge14]->click();
+ break;
+ case Edge34:
+ myShape3 = aSelectedObject;
+ if (!myShape4) mySelBtn[Edge44]->click();
+ else if (!myShape1) mySelBtn[Edge14]->click();
+ else if (!myShape2) mySelBtn[Edge24]->click();
+ break;
+ case Edge44:
+ myShape4 = aSelectedObject;
+ if (!myShape1) mySelBtn[Edge14]->click();
+ else if (!myShape2) mySelBtn[Edge24]->click();
+ else if (!myShape3) mySelBtn[Edge34]->click();
+ break;
+ default:
+ break;
}
}
-
- myEditCurrentArgument->setText(aName);
-
- switch (aCurrFocus) {
- // four vertices
- case Vertex1:
- myShape1 = anObj;
- if (!myShape1->_is_nil() && myShape2->_is_nil())
- mySelBtn[Vertex2]->click();
- break;
- case Vertex2:
- myShape2 = anObj;
- if (!myShape2->_is_nil() && myShape3->_is_nil())
- mySelBtn[Vertex3]->click();
- break;
- case Vertex3:
- myShape3 = anObj;
- if (!myShape3->_is_nil() && myShape4->_is_nil())
- mySelBtn[Vertex4]->click();
- break;
- case Vertex4:
- myShape4 = anObj;
- if (!myShape4->_is_nil() && myShape1->_is_nil())
- mySelBtn[Vertex1]->click();
- break;
-
- // two edges
- case Edge12:
- myShape1 = anObj;
- if (!myShape1->_is_nil() && myShape2->_is_nil())
- mySelBtn[Edge22]->click();
- break;
- case Edge22:
- myShape2 = anObj;
- if (!myShape2->_is_nil() && myShape1->_is_nil())
- mySelBtn[Edge12]->click();
- break;
-
- // four edges
- case Edge14:
- myShape1 = anObj;
- if (!myShape1->_is_nil() && myShape2->_is_nil())
- mySelBtn[Edge24]->click();
- break;
- case Edge24:
- myShape2 = anObj;
- if (!myShape2->_is_nil() && myShape3->_is_nil())
- mySelBtn[Edge34]->click();
- break;
- case Edge34:
- myShape3 = anObj;
- if (!myShape3->_is_nil() && myShape4->_is_nil())
- mySelBtn[Edge44]->click();
- break;
- case Edge44:
- myShape4 = anObj;
- if (!myShape4->_is_nil() && myShape1->_is_nil())
- mySelBtn[Edge14]->click();
- break;
-
- default:
- 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();
bool ok = false;
switch (getConstructorId()) {
case 0:
- ok = (!myShape1->_is_nil() && !myShape2->_is_nil() &&
- !myShape3->_is_nil() && !myShape4->_is_nil());
+ ok = myShape1 && myShape2 && myShape3 && myShape4;
break;
case 1:
- ok = (!myShape1->_is_nil() && !myShape2->_is_nil());
+ ok = myShape1 && myShape2;
break;
case 2:
- ok = (!myShape1->_is_nil() && !myShape2->_is_nil() &&
- !myShape3->_is_nil() && !myShape4->_is_nil());
+ ok = myShape1 && myShape2 && myShape3 && myShape4;
break;
default:
break;
switch (getConstructorId()) {
case 0:
- anObj = anOper->MakeQuad4Vertices(myShape1, myShape2, myShape3, myShape4);
+ anObj = anOper->MakeQuad4Vertices(myShape1.get(), myShape2.get(), myShape3.get(), myShape4.get());
res = true;
break;
case 1:
- anObj = anOper->MakeQuad2Edges(myShape1, myShape2);
+ anObj = anOper->MakeQuad2Edges(myShape1.get(), myShape2.get());
res = true;
break;
case 2:
- anObj = anOper->MakeQuad(myShape1, myShape2, myShape3, myShape4);
+ anObj = anOper->MakeQuad(myShape1.get(), myShape2.get(), myShape3.get(), myShape4.get());
res = true;
break;
default:
//=================================================================================
void BlocksGUI_QuadFaceDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
switch (getConstructorId()) {
case 0:
- objMap[mySelName[Vertex1]->text()] = myShape1;
- objMap[mySelName[Vertex2]->text()] = myShape2;
- objMap[mySelName[Vertex3]->text()] = myShape3;
- objMap[mySelName[Vertex4]->text()] = myShape4;
+ GEOMBase::PublishSubObject( myShape1.get() );
+ GEOMBase::PublishSubObject( myShape2.get() );
+ GEOMBase::PublishSubObject( myShape3.get() );
+ GEOMBase::PublishSubObject( myShape4.get() );
break;
case 1:
- objMap[mySelName[Edge12]->text()] = myShape1;
- objMap[mySelName[Edge22]->text()] = myShape2;
+ GEOMBase::PublishSubObject( myShape1.get() );
+ GEOMBase::PublishSubObject( myShape2.get() );
break;
case 2:
- objMap[mySelName[Edge14]->text()] = myShape1;
- objMap[mySelName[Edge24]->text()] = myShape2;
- objMap[mySelName[Edge34]->text()] = myShape3;
- objMap[mySelName[Edge44]->text()] = myShape4;
+ GEOMBase::PublishSubObject( myShape1.get() );
+ GEOMBase::PublishSubObject( myShape2.get() );
+ GEOMBase::PublishSubObject( myShape3.get() );
+ GEOMBase::PublishSubObject( myShape4.get() );
+ break;
+ default:
break;
}
- addSubshapesToFather(objMap);
}
#ifndef BLOCKSGUI_QUADFACEDLG_H
#define BLOCKSGUI_QUADFACEDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
#include <QMap>
private:
int myConstructorId;
- GEOM::GEOM_Object_var myShape1;
- GEOM::GEOM_Object_var myShape2;
- GEOM::GEOM_Object_var myShape3;
- GEOM::GEOM_Object_var myShape4;
+ GEOM::GeomObjPtr myShape1;
+ GEOM::GeomObjPtr myShape2;
+ GEOM::GeomObjPtr myShape3;
+ GEOM::GeomObjPtr myShape4;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
myGroup->LineEdit1->setText("");
myGroup->LineEdit2->setText("");
- myObject1 = myObject2 = GEOM::GEOM_Object::_nil();
+ myObject1.nullify();
+ myObject2.nullify();
// signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
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->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
{
myEditCurrentArgument->setText("");
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
-
- if (aSelList.Extent() != 1) {
- 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));
+ GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_SHAPE );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+ myEditCurrentArgument->setText( aName );
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (myEditCurrentArgument == myGroup->LineEdit1) {
myObject1 = aSelectedObject;
- if (myObject2->_is_nil())
+ if (!myObject2)
myGroup->PushButton2->click();
}
else if (myEditCurrentArgument == myGroup->LineEdit2) {
myObject2 = aSelectedObject;
- if (myObject1->_is_nil())
+ if (!myObject1)
myGroup->PushButton1->click();
}
}
+ else {
+ if (myEditCurrentArgument == myGroup->LineEdit1) myObject1.nullify();
+ else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2.nullify();
+ }
}
//=================================================================================
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()
// purpose :
//=================================================================================
bool BooleanGUI_Dialog::isValid (QString&)
{
- //Handle(SALOME_InteractiveObject) IO = firstIObject();
- //GEOM::GEOM_Object_var anObject = GEOMBase::ConvertIOinGEOMObject( IO );
- //if ( anObject->_is_nil() )
- // return false;
-
- return !CORBA::is_nil(myObject1) && !CORBA::is_nil(myObject2);
+ return myObject1 && myObject2;
}
//=================================================================================
GEOM::GEOM_Object_var anObj;
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())
objects.push_back(anObj._retn());
#ifndef BOOLEANGUI_DIALOG_H
#define BOOLEANGUI_DIALOG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel;
private:
int myOperation;
- GEOM::GEOM_Object_var myObject1;
- GEOM::GEOM_Object_var myObject2;
+ GEOM::GeomObjPtr myObject1;
+ GEOM::GeomObjPtr myObject2;
DlgRef_2Sel* myGroup;
bool ClickOnApply();
void SetEditCurrentArgument();
void SelectionIntoArgument();
- void LineEditReturnPressed();
void ActivateThisDialog();
};
myEditCurrentArgument = GroupShapes->LineEdit1;
GroupShapes->LineEdit1->setReadOnly( true );
- myOkShapes = false;
+ myShapes.clear();
mainFrame()->GroupBoxPublish->show();
void BuildGUI_CompoundDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText( "" );
- QString aString = ""; /* name of selection */
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
+ myShapes = getSelected( TopAbs_SHAPE, -1 );
- myOkShapes = false;
- int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
- if ( nbSel == 0 )
- return;
- if ( nbSel != 1 )
- aString = QString( "%1_objects").arg( nbSel );
-
- GEOMBase::ConvertListOfIOInListOfGO(aSelList, myShapes, true);
- myEditCurrentArgument->setText( aString );
- myOkShapes = true;
+ if ( !myShapes.isEmpty() ) {
+ QString aName = myShapes.count() > 1 ? QString( "%1_objects").arg( myShapes.count() ) : GEOMBase::GetName( myShapes[0].get() );
+ myEditCurrentArgument->setText( aName );
+ }
}
//=================================================================================
bool BuildGUI_CompoundDlg::isValid( QString& )
{
- return myOkShapes;
+ return !myShapes.isEmpty();
}
//=================================================================================
bool BuildGUI_CompoundDlg::execute( ObjectList& objects )
{
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() )
objects.push_back( anObj._retn() );
#ifndef BUILDGUI_COMPOUNDDLG_H
#define BUILDGUI_COMPOUNDDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel;
void enterEvent( QEvent* );
private:
- GEOM::ListOfGO myShapes;
- bool myOkShapes;
+ QList<GEOM::GeomObjPtr> myShapes;
DlgRef_1Sel* GroupShapes;
void BuildGUI_EdgeDlg::Init()
{
// init variables
- myPoint1 = myPoint2 = myWire = GEOM::GEOM_Object::_nil();
+ myPoint1.nullify();
+ myPoint2.nullify();
+ myWire.nullify();
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton1->setDown(true);
globalSelection(); // close local contexts, if any
connect(GroupPoints->PushButton2, 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() ),
this, SLOT( SelectionIntoArgument() ) );
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setText( "" );
GroupPoints->LineEdit2->setText( "" );
- myPoint1 = GEOM::GEOM_Object::_nil();
- myPoint2 = GEOM::GEOM_Object::_nil();
+ myPoint1.nullify();
+ myPoint2.nullify();
GroupPoints->PushButton1->setDown(true);
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit1->setEnabled(true);
myEditCurrentArgument = GroupWire->LineEdit1;
GroupWire->LineEdit1->setText("");
- myWire = GEOM::GEOM_Object::_nil();
+ myWire.nullify();
GroupWire->PushButton1->setDown(true);
GroupWire->LineEdit1->setEnabled(true);
GroupPoints->hide();
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) {
- if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupWire->LineEdit1) myWire = GEOM::GEOM_Object::_nil();
+ if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1.nullify();
+ else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2.nullify();
+ else if (myEditCurrentArgument == GroupWire->LineEdit1) myWire.nullify();
displayPreview();
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;
-
- TopoDS_Shape aShape;
- if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
- TColStd_IndexedMapOfInteger aMap;
- 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 = "";
- }
- }
- }
-
+ TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupWire->LineEdit1 ? TopAbs_WIRE : TopAbs_VERTEX;
+ GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
myEditCurrentArgument->setText( aName );
- if (!aSelectedObject->_is_nil()) { // clear selection if something selected
- globalSelection();
- localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
- }
+ globalSelection();
+ localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
myPoint1 = aSelectedObject;
- if ( !myPoint1->_is_nil() && myPoint2->_is_nil() )
+ if ( myPoint1 && !myPoint2 )
GroupPoints->PushButton2->click();
}
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
myPoint2 = aSelectedObject;
- if ( !myPoint2->_is_nil() && myPoint1->_is_nil() )
+ if ( myPoint2 && !myPoint1 )
GroupPoints->PushButton1->click();
}
else if ( myEditCurrentArgument == GroupWire->LineEdit1 ) {
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()
// purpose :
bool BuildGUI_EdgeDlg::isValid (QString& msg)
{
bool ok = false;
- if ( getConstructorId() == 0 ) {
- ok = !myPoint1->_is_nil() && !myPoint2->_is_nil();
- }
- else {
- ok = !myWire->_is_nil();
- ok = ok && GroupWire->SpinBox_DX->isValid( msg, !IsPreview() );
- ok = ok && GroupWire->SpinBox_DY->isValid( msg, !IsPreview() );
+ switch ( getConstructorId() ) {
+ case 0:
+ ok = myPoint1 && myPoint2;
+ break;
+ case 1:
+ ok = GroupWire->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupWire->SpinBox_DY->isValid( msg, !IsPreview() ) &&
+ myWire;
+ break;
+ default:
+ break;
}
return ok;
}
switch ( getConstructorId() ) {
case 0 :
{
- anObj = anOper->MakeEdge( myPoint1, myPoint2 );
+ anObj = anOper->MakeEdge( myPoint1.get(), myPoint2.get() );
res = true;
break;
}
aParameters << GroupWire->SpinBox_DX->text();
aParameters << GroupWire->SpinBox_DY->text();
- anObj = anOper->MakeEdgeWire( myWire, aLinearTolerance, anAngularTolerance );
+ anObj = anOper->MakeEdgeWire( myWire.get(), aLinearTolerance, anAngularTolerance );
if ( !anObj->_is_nil() && !IsPreview() )
anObj->SetParameters( aParameters.join(":").toLatin1().constData() );
//=================================================================================
void BuildGUI_EdgeDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) {
case 0 :
- objMap[GroupPoints->LineEdit1->text()] = myPoint1;
- objMap[GroupPoints->LineEdit2->text()] = myPoint2;
+ GEOMBase::PublishSubObject( myPoint1.get() );
+ GEOMBase::PublishSubObject( myPoint2.get() );
break;
case 1 :
- objMap[GroupWire->LineEdit1->text()] = myWire;
+ GEOMBase::PublishSubObject( myWire.get() );
+ break;
+ default:
break;
}
- addSubshapesToFather( objMap );
}
#ifndef BUILDGUI_EDGEDLG_H
#define BUILDGUI_EDGEDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel2Spin;
class DlgRef_2Sel;
void enterEvent( QEvent* );
private:
- GEOM::GEOM_Object_var myPoint1, myPoint2; /* Points containing the edge */
- GEOM::GEOM_Object_var myWire; /* Wire */
+ GEOM::GeomObjPtr myPoint1, myPoint2; /* Points containing the edge */
+ GEOM::GeomObjPtr myWire; /* Wire */
DlgRef_2Sel* GroupPoints;
DlgRef_1Sel2Spin* GroupWire;
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
};
GroupWire->LineEdit1->setReadOnly( true );
GroupWire->CheckButton1->setChecked( true );
+ myWires.clear();
TColStd_MapOfInteger aMap;
aMap.Add( GEOM_EDGE );
void BuildGUI_FaceDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText( "" );
- QString aName;
-
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
- int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
-
- if ( aNbSel < 1) {
- myWires.length(0);
- return;
+ QList<TopAbs_ShapeEnum> types;
+ types << TopAbs_EDGE << TopAbs_WIRE;
+ myWires = getSelected( types, -1 );
+
+ if ( !myWires.isEmpty() ) {
+ QString aName = myWires.count() > 1 ? QString( "%1_objects").arg( myWires.count() ) : GEOMBase::GetName( myWires[0].get() );
+ myEditCurrentArgument->setText( aName );
}
-
- GEOMBase::ConvertListOfIOInListOfGO(aSelList, myWires);
- if ( !myWires.length() )
- return;
- if ( aNbSel != 1 )
- aName = tr( "%1_objects" ).arg( aNbSel );
-
- myEditCurrentArgument->setText( aName );
}
//=================================================================================
bool BuildGUI_FaceDlg::isValid( QString& )
{
- return ( myWires.length() != 0 );
+ return !myWires.isEmpty();
}
//=================================================================================
bool BuildGUI_FaceDlg::execute( ObjectList& objects )
{
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() )
objects.push_back( anObj._retn() );
#ifndef BUILDGUI_FACEDLG_H
#define BUILDGUI_FACEDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel1Check;
void enterEvent( QEvent* );
private:
- GEOM::ListOfGO myWires;
+ QList<GEOM::GeomObjPtr> myWires;
DlgRef_1Sel1Check* GroupWire;
myEditCurrentArgument = GroupShell->LineEdit1;
GroupShell->LineEdit1->setReadOnly( true );
- myOkFacesAndShells = false;
+ myFacesAndShells.clear();
TColStd_MapOfInteger aMap;
aMap.Add( GEOM_SHELL );
void BuildGUI_ShellDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText( "" );
- QString aString;
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
+ QList<TopAbs_ShapeEnum> types;
+ types << TopAbs_FACE << TopAbs_SHELL << TopAbs_COMPOUND;
+ myFacesAndShells = getSelected( types, -1 );
- myOkFacesAndShells = false;
- int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
- if ( nbSel == 0 )
- return;
- if ( nbSel != 1 )
- aString = QString( "%1_objects ").arg( nbSel );
-
- GEOMBase::ConvertListOfIOInListOfGO(aSelList, myFacesAndShells, true);
- if ( !myFacesAndShells.length() )
- return;
-
- myEditCurrentArgument->setText( aString );
- myOkFacesAndShells = true;
+ if ( !myFacesAndShells.isEmpty() ) {
+ QString aName = myFacesAndShells.count() > 1 ? QString( "%1_objects").arg( myFacesAndShells.count() ) : GEOMBase::GetName( myFacesAndShells[0].get() );
+ myEditCurrentArgument->setText( aName );
+ }
}
//=================================================================================
bool BuildGUI_ShellDlg::isValid( QString& )
{
- return myOkFacesAndShells;
+ return !myFacesAndShells.isEmpty();
}
//=================================================================================
bool BuildGUI_ShellDlg::execute( ObjectList& objects )
{
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() )
objects.push_back( anObj._retn() );
#ifndef BUILDGUI_SHELLDLG_H
#define BUILDGUI_SHELLDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel;
void enterEvent( QEvent* );
private:
- GEOM::ListOfGO myFacesAndShells;
- bool myOkFacesAndShells;/* to check when arguments is defined */
+ QList<GEOM::GeomObjPtr> myFacesAndShells;
DlgRef_1Sel* GroupShell;
GroupSolid->LineEdit1->setReadOnly( true );
GroupSolid->CheckButton1->setChecked( true );
- myOkShells = false;
-
+ myShells.clear();
+
globalSelection( GEOM_SHELL );
/* signals and slots connections */
//=================================================================================
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() )
return false;
void BuildGUI_SolidDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText( "" );
- QString aString = "";
-
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
- myOkShells = false;
- int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString);
- if ( nbSel == 0 )
- return;
- if ( nbSel != 1 )
- aString = tr( "%1_objects" ).arg( nbSel );
-
- GEOMBase::ConvertListOfIOInListOfGO(aSelList, myShells);
- if ( !myShells.length() )
- return;
-
- myEditCurrentArgument->setText( aString );
- myOkShells = true;
+ myShells = getSelected( TopAbs_SHELL, -1 );
+
+ if ( !myShells.isEmpty() ) {
+ QString aName = myShells.count() > 1 ? QString( "%1_objects").arg( myShells.count() ) : GEOMBase::GetName( myShells[0].get() );
+ myEditCurrentArgument->setText( aName );
+ }
}
//=================================================================================
// function : isValid
// 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
// 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::ListOfLong_var anInts;
GEOM::ListOfDouble_var aDbls;
- if (aShape->_is_nil()) {
+ if ( !CORBA::is_nil( shell ) ) {
+ GEOM::MeasureOpPtr anOp;
+ anOp.take( myGeomGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() ) );
+
+ // Detect kind of shape and parameters
+ aKind = anOp->KindOfShape(shell, anInts, aDbls);
+
+ if ( anOp->IsDone() ) {
+ if ( anInts[0] == 1 )
+ ok = true;
+ else if ( anInts[0] == 2 )
+ ok = false;
+ }
+ else {
+ MESSAGE ("KindOfShape Operation is NOT DONE!!!");
+ }
+ }
+ else {
MESSAGE ("Shape is NULL!!!");
- return false;
}
- GEOM::GEOM_IMeasureOperations_var anOp = myGeomGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() );
-
- // Detect kind of shape and parameters
- aKind = anOp->KindOfShape(aShape, anInts, aDbls);
-
- if ( !anOp->IsDone() ) {
- MESSAGE ("KindOfShape Operation is NOT DONE!!!");
- return false;
- }
-
- if ( anInts[0] == 1 )
- return true;
- else if ( anInts[0] == 2 )
- return false;
-
- return false;
+ return ok;
}
//=================================================================================
//=================================================================================
bool BuildGUI_SolidDlg::execute( ObjectList& objects )
{
- bool toCreateSingleSolid = GroupSolid->CheckButton1->isChecked();
-
GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
- if ( toCreateSingleSolid ) {
- GEOM::GEOM_Object_var anObj = anOper->MakeSolidShells( myShells );
+ if ( GroupSolid->CheckButton1->isChecked() ) {
+ 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() )
objects.push_back( anObj._retn() );
}
else {
- for ( int i = 0, n = myShells.length(); i< n; i++ ) {
- GEOM::GEOM_Object_var anObj = anOper->MakeSolidShell( myShells[ i ] );
+ for ( int i = 0, n = myShells.count(); i< n; i++ ) {
+ GEOM::GEOM_Object_var anObj = anOper->MakeSolidShell( myShells[ i ].get() );
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
#ifndef BUILDGUI_SOLIDDLG_H
#define BUILDGUI_SOLIDDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel1Check;
private:
void Init();
- bool isClosed(int i);
+ bool isClosed( GEOM::GEOM_Object_ptr shell );
void enterEvent( QEvent* );
private:
- GEOM::ListOfGO myShells;
- bool myOkShells; /* to check when arguments is defined and
- all shells are closed */
+ QList<GEOM::GeomObjPtr> myShells;
- DlgRef_1Sel1Check* GroupSolid;
+ DlgRef_1Sel1Check* GroupSolid;
private slots:
void ClickOnOk();
GroupArgs->LineEdit1->setReadOnly( true );
GroupType->RadioButton1->setChecked(true);
- myOkEdgesAndWires = false;
-
+ myEdgesAndWires.clear();
+
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
/* signals and slots connections */
//=================================================================================
bool BuildGUI_WireDlg::ClickOnApply()
{
- if ( !onAccept() || !myOkEdgesAndWires )
+ if ( !onAccept() )
return false;
initName();
TypeButtonClicked();
- myMapToStudy.clear();
- myEdgesAndWires.length(0);
- myOkEdgesAndWires = false;
+ myEdgesAndWires.clear();
myEditCurrentArgument->setText( "" );
return true;
}
void BuildGUI_WireDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText( "" );
- QString aString = ""; /* name of selection */
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
+ QList<TopAbs_ShapeEnum> types;
+ types << TopAbs_EDGE << TopAbs_WIRE;
+ myEdgesAndWires = getSelected( types, -1 );
- myOkEdgesAndWires = false;
- int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString);
-
- if ( nbSel == 0 ) {
- myMapToStudy.clear();
- return;
+ if ( !myEdgesAndWires.isEmpty() ) {
+ QString aName = myEdgesAndWires.count() > 1 ? QString( "%1_objects").arg( myEdgesAndWires.count() ) : GEOMBase::GetName( myEdgesAndWires[0].get() );
+ myEditCurrentArgument->setText( aName );
}
-
- 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;
}
//=================================================================================
bool BuildGUI_WireDlg::isValid (QString& msg)
{
- bool ok = GroupArgs->SpinBox_DX->isValid(msg, !IsPreview());
- return myOkEdgesAndWires && ok;
+ return GroupArgs->SpinBox_DX->isValid(msg, !IsPreview()) && !myEdgesAndWires.isEmpty();
}
//=================================================================================
bool BuildGUI_WireDlg::execute (ObjectList& objects)
{
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())
objects.push_back(anObj._retn());
//=================================================================================
void BuildGUI_WireDlg::addSubshapesToStudy()
{
- addSubshapesToFather( myMapToStudy );
+ for ( int i = 0; i < myEdgesAndWires.count(); i++ )
+ GEOMBase::PublishSubObject( myEdgesAndWires[i].get() );
}
#ifndef BUILDGUI_WIREDLG_H
#define BUILDGUI_WIREDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel1Spin;
class DlgRef_3Radio;
void enterEvent( QEvent* );
private:
- GEOM::ListOfGO myEdgesAndWires;
- bool myOkEdgesAndWires; /* to check when arguments is defined */
+ QList<GEOM::GeomObjPtr> myEdgesAndWires;
DlgRef_1Sel1Spin* GroupArgs;
DlgRef_3Radio* GroupType;
- QMap<QString, GEOM::GEOM_Object_var> myMapToStudy;
-
private slots:
void ClickOnOk();
bool ClickOnApply();
{
QString name;
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
- CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( object );
- if ( study && strcmp( IOR.in(), "" ) != 0 ) {
- _PTR(SObject) aSObj( study->studyDS()->FindObjectIOR( std::string( IOR.in() ) ) );
- _PTR(GenericAttribute) anAttr;
- if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") ) {
- _PTR(AttributeName) aNameAttr( anAttr );
- name = aNameAttr->Value().c_str();
+
+ 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 );
+ if ( study && strcmp( IOR.in(), "" ) != 0 ) {
+ _PTR(SObject) aSObj( study->studyDS()->FindObjectIOR( std::string( IOR.in() ) ) );
+ _PTR(GenericAttribute) anAttr;
+ if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") ) {
+ _PTR(AttributeName) aNameAttr( anAttr );
+ name = aNameAttr->Value().c_str();
+ }
+ }
+
+ // 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 !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() );
+ }
+ }
+}
/* Gets name of object */
static QString GetName( GEOM::GEOM_Object_ptr object );
+ /* Check if object has shape */
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
#include <LightApp_SelectionMgr.h>
#include <LightApp_DataOwner.h>
#include <SalomeApp_Tools.h>
+#include <SALOME_ListIteratorOfListIO.hxx>
#include <SALOME_Prs.h>
#include <TColStd_MapOfInteger.hxx>
#include <TCollection_AsciiString.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
//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
if ( !myPrefix.isEmpty() || theObj->_is_nil() )
return myPrefix;
- //TopoDS_Shape aShape;
- //if ( !GEOMBase::GetShape( theObj, aShape ) )
- // return "";
- //
- //long aType = aShape.ShapeType();
GEOM::shape_type aType = theObj->GetShapeType();
switch ( aType )
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
// Purpose : Virtual method to add subshapes if needs
}
//================================================================
-// Function : addSubshapesToFather
-// Purpose : Method to add Father Subshapes to Study if it`s not exist
+// Function : getSelected
+// 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
+//================================================================
+GEOM::GeomObjPtr GEOMBase_Helper::getSelected( TopAbs_ShapeEnum type )
+{
+ QList<TopAbs_ShapeEnum> types;
+ types << type;
+ return getSelected( types );
+}
+
//================================================================
-void GEOMBase_Helper::addSubshapesToFather( QMap<QString, GEOM::GEOM_Object_var>& theMap )
+// Function : getSelected
+// Purpose : Get selected object by specified types
+//
+// Returns valid object if only one object of the specified type is selected
+// (no matter global or local selection is activated). The list of allowed
+// shape types is passed via \a types. If \a types includes TopAbs_SHAPE,
+// geometrical object of any valid type is expected.
+//
+// \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 )
{
- //GetStudyDS
- SalomeApp_Application* app =
- dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
- _PTR(Study) aDStudy = appStudy->studyDS();
+ 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;
- for( QMap<QString, GEOM::GEOM_Object_var>::Iterator it = theMap.begin(); it != theMap.end(); it++ ) {
- GEOM::GEOM_Object_var aFatherObj = it.value()->GetMainShape();
- if ( !aFatherObj->_is_nil() ) {
- QString aFatherEntry = getEntry( aFatherObj );
- if ( aFatherEntry != "") { // additional checking that object is valid 0020598 EDF 1191
- GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aFatherObj, it.key().toLatin1().data() );
- //Add Object to study if its not exist
- if ( aFindedObject->_is_nil() )
- GeometryGUI::GetGeomGen()->AddInStudy(GeometryGUI::ClientStudyToStudy(aDStudy),
- it.value(), it.key().toLatin1().data(), aFatherObj );
+ 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;
}
#define GEOMBASE_HELPER_H
#include "GEOM_GEOMBase.hxx"
+#include "GEOM_GenericObjPtr.h"
#include <GEOM_Displayer.h>
#include <SALOME_ListIO.hxx>
virtual void addSubshapesToStudy();
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;}
bool IsPreview() {return isPreview;}
--- /dev/null
+// 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 );
+ }
+}
--- /dev/null
+// 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
GEOMBase_Skeleton.h \
GEOMBase_Helper.h \
GEOM_Operation.h \
- GEOM_GEOMBase.hxx
+ GEOM_GEOMBase.hxx \
+ GEOM_GenericObjPtr.h
dist_libGEOMBase_la_SOURCES = \
GEOMBase.cxx \
GEOMBase_Skeleton.cxx \
GEOMBase_Helper.cxx \
- GEOM_Operation.cxx
+ GEOM_Operation.cxx \
+ GEOM_GenericObjPtr.cxx
MOC_FILES = \
GEOMBase_Skeleton_moc.cxx
myEditCurrentArgument = GroupPoints->LineEdit1;
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 );
int SpecificStep1 = 1;
initSpinBox( GroupPoints->SpinBox4, 1, MAX_NUMBER, SpecificStep1 );
initSpinBox( GroupPoints->SpinBox5, 0.00001, 10000.0, SpecificStep2, "len_tol_precision" );
- GroupPoints->SpinBox1->setValue( myMinDeg );
- GroupPoints->SpinBox2->setValue( myTol2D );
- GroupPoints->SpinBox3->setValue( myNbIter );
- GroupPoints->SpinBox4->setValue( myMaxDeg );
- GroupPoints->SpinBox5->setValue( myTol3D );
+ GroupPoints->SpinBox1->setValue( 2 );
+ GroupPoints->SpinBox2->setValue( 0.0001 );
+ GroupPoints->SpinBox3->setValue( 0 );
+ GroupPoints->SpinBox4->setValue( 5 );
+ GroupPoints->SpinBox5->setValue( 0.0001 );
GroupPoints->ComboBox1->addItem(tr("GEOM_FILLING_DEFAULT"));
GroupPoints->ComboBox1->addItem(tr("GEOM_FILLING_USEORI"));
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
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()));
erasePreview();
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) {
- TopoDS_Shape S;
- myOkCompound = false;
-
- if (GEOMBase::GetShape(aSelectedObject, S) && S.ShapeType() == TopAbs_COMPOUND) {
- // myCompound should be a compound of edges
- for (TopoDS_Iterator it (S); it.More(); it.Next())
- if ( it.Value().ShapeType() != TopAbs_EDGE &&
- it.Value().ShapeType() != TopAbs_WIRE )
- return;
- myCompound = aSelectedObject;
- myOkCompound = true;
+ myCompound = getSelected( TopAbs_COMPOUND );
+ if ( myCompound ) {
+ if ( myCompound->GetMaxShapeType() < GEOM::WIRE || myCompound->GetMinShapeType() > GEOM::EDGE ) {
+ myCompound.nullify();
+ }
+ else {
+ QString aName = GEOMBase::GetName( myCompound.get() );
+ myEditCurrentArgument->setText( aName );
+ }
}
}
- myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
displayPreview();
}
}
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void GenerationGUI_FillingDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if ( send == GroupPoints->LineEdit1 ) {
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
-}
-
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
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();
}
//=================================================================================
void GenerationGUI_FillingDlg::MethodChanged()
{
- myMethod = GroupPoints->ComboBox1->currentIndex();
displayPreview();
}
//=================================================================================
void GenerationGUI_FillingDlg::ApproxChanged()
{
- myIsApprox = GroupPoints->CheckBox1->isChecked();
displayPreview();
}
//=================================================================================
bool GenerationGUI_FillingDlg::isValid( QString& msg )
{
- bool ok = true;
- ok = GroupPoints->SpinBox1->isValid( msg, !IsPreview() ) && ok;
- ok = GroupPoints->SpinBox2->isValid( msg, !IsPreview() ) && ok;
- ok = GroupPoints->SpinBox3->isValid( msg, !IsPreview() ) && ok;
- ok = GroupPoints->SpinBox4->isValid( msg, !IsPreview() ) && ok;
- ok = GroupPoints->SpinBox5->isValid( msg, !IsPreview() ) && ok;
-
- return myOkCompound > 0 && ok;
+ bool ok = GroupPoints->SpinBox1->isValid( msg, !IsPreview() ) &&
+ GroupPoints->SpinBox2->isValid( msg, !IsPreview() ) &&
+ GroupPoints->SpinBox3->isValid( msg, !IsPreview() ) &&
+ GroupPoints->SpinBox4->isValid( msg, !IsPreview() ) &&
+ GroupPoints->SpinBox5->isValid( msg, !IsPreview() ) &&
+ myCompound;
+ return ok;
}
//=================================================================================
}
GEOM::GEOM_Object_var anObj =
- anOper->MakeFilling( myCompound, myMinDeg, myMaxDeg, myTol2D, myTol3D,
- myNbIter, aMethod, myIsApprox );
+ anOper->MakeFilling( myCompound.get(),
+ GroupPoints->SpinBox1->value(),
+ GroupPoints->SpinBox4->value(),
+ GroupPoints->SpinBox2->value(),
+ GroupPoints->SpinBox5->value(),
+ GroupPoints->SpinBox3->value(),
+ aMethod,
+ GroupPoints->CheckBox1->isChecked() );
if ( !anObj->_is_nil() )
{
if ( !IsPreview() )
#ifndef GENERATIONGUI_FILLINGDLG_H
#define GENERATIONGUI_FILLINGDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel5Spin1Check;
void enterEvent( QEvent* );
private:
- GEOM::GEOM_Object_var 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 */
-
+ GEOM::GeomObjPtr myCompound; /* compound of curves */
DlgRef_1Sel5Spin1Check* GroupPoints;
private slots:
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ValueChangedInSpinBox( double );
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
GroupPoints->LineEdit3->setText("");
- myPath = myVec = GEOM::GEOM_Object::_nil();
- myOkBase = myOkPath = myOkVec = false;
+ myPath.nullify();
+ myVec.nullify();
GroupPoints->CheckButton1->setEnabled(false);
connect(GroupPoints->PushButton2, 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()));
initName(tr("GEOM_PIPE"));
{
erasePreview();
- switch (constructorId)
- {
- case 0:
- {
- GroupPoints->TextLabel3->hide();
- GroupPoints->PushButton3->hide();
- GroupPoints->LineEdit3->hide();
- break;
- }
- case 1:
- {
- GroupPoints->TextLabel3->show();
- GroupPoints->PushButton3->show();
- GroupPoints->LineEdit3->show();
- break;
- }
+ switch (constructorId) {
+ case 0:
+ GroupPoints->TextLabel3->hide();
+ GroupPoints->PushButton3->hide();
+ GroupPoints->LineEdit3->hide();
+ GroupPoints->PushButton1->click();
+ break;
+ case 1:
+ GroupPoints->TextLabel3->show();
+ GroupPoints->PushButton3->show();
+ GroupPoints->LineEdit3->show();
+ break;
+ default:
+ break;
}
+
qApp->processEvents();
updateGeometry();
resize(100,100);
+ SelectionIntoArgument();
displayPreview();
}
aMap.Add(GEOM_LINE);
globalSelection(aMap);
}
- if(myEditCurrentArgument == GroupPoints->LineEdit2) {
+ if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
myEditCurrentArgument->setText("");
- myOkPath = false;
+ myPath.nullify();
}
displayPreview();
}
initName();
if ( getConstructorId() != 1 )
- ConstructorsClicked( getConstructorId() );
+ ConstructorsClicked( getConstructorId() );
// activate selection and connect selection manager
GroupPoints->PushButton1->click();
return true;
{
erasePreview();
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) {
- myOkBase = false;
- GEOMBase::ConvertListOfIOInListOfGO(aSelList, myBaseObjects, true);
- if (aSelList.Extent() > 1)
- aName = QString( "%1_objects").arg( aSelList.Extent() );
-
- if ( aSelList.Extent() > 0 ) {
- // check base shapes
- for (int i=0; i < myBaseObjects.length(); i++) {
- GEOMBase::GetShape(myBaseObjects[i], S);
- 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;
- }
- }
- myEditCurrentArgument->setText(aName);
- myOkBase = true;
- } else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
- myEditCurrentArgument == GroupPoints->LineEdit3) {
- myEditCurrentArgument == GroupPoints->LineEdit2 ? myOkPath = false : myOkVec = false;
- bool myOk = false;
-
- if (myEditCurrentArgument == GroupPoints->LineEdit2 && !GroupPoints->CheckButton1->isChecked() ){
- myPath = aSelectedObject;
- myOkPath = true;
- myEditCurrentArgument->setText(aName);
- } else {
- 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();
- } else if (myOkVec) {
- if (!myOkBase)
- GroupPoints->PushButton1->click();
- else if (!myOkPath)
- GroupPoints->PushButton2->click();
- }
+ if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
+ myBaseObjects.clear();
+ QList<GEOM::GeomObjPtr> objects = getSelected( TopAbs_SHAPE, -1 );
+ for ( int i = 0; i < objects.count(); i++ ) {
+ GEOM::shape_type stype = objects[i]->GetMaxShapeType();
+ GEOM::shape_type maxallowed = getConstructorId() == 1 ? GEOM::FACE : GEOM::SHELL;
+ GEOM::shape_type minallowed = getConstructorId() == 1 ? GEOM::EDGE : GEOM::VERTEX;
+ if ( stype < maxallowed || stype > minallowed )
+ continue;
+ myBaseObjects << objects[i];
+ }
+ if ( !myBaseObjects.isEmpty() ) {
+ QString aName = myBaseObjects.count() > 1 ? QString( "%1_objects").arg( myBaseObjects.count() ) : GEOMBase::GetName( myBaseObjects[0].get() );
+ myEditCurrentArgument->setText( aName );
+ }
+ }
+ else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
+ QList<TopAbs_ShapeEnum> types;
+ types << TopAbs_EDGE << TopAbs_WIRE;
+ myPath = getSelected( types );
+ if ( myPath ) {
+ QString aName = GEOMBase::GetName( myPath.get() );
+ myEditCurrentArgument->setText( aName );
+ if ( getConstructorId() == 1 && !myVec )
+ GroupPoints->PushButton3->click();
+ else if ( myBaseObjects.isEmpty() )
+ GroupPoints->PushButton1->click();
+ }
+ }
+ 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();
}
}
+
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()
// purpose :
//=================================================================================
bool GenerationGUI_PipeDlg::isValid (QString&)
{
+ bool ok = false;
switch ( getConstructorId() ) {
case 0 :
- return myOkBase && myOkPath;
+ ok = !myBaseObjects.isEmpty() && myPath;
+ break;
case 1 :
- return myOkBase && myOkPath && myOkVec;
+ ok = !myBaseObjects.isEmpty() && myPath && myVec;
+ break;
+ default:
+ break;
}
+ return ok;
}
//=================================================================================
//=================================================================================
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());
- for (int i=0; i < myBaseObjects.length(); i++) {
- aBase = myBaseObjects[i];
+ for (int i = 0; i < myBaseObjects.count(); i++) {
switch ( getConstructorId() ) {
case 0 :
- anObj = anOper->MakePipe(aBase, myPath);
+ anObj = anOper->MakePipe(myBaseObjects[i].get(), myPath.get());
break;
case 1 :
- anObj = anOper->MakePipeBiNormalAlongVector(aBase, myPath, myVec);
+ anObj = anOper->MakePipeBiNormalAlongVector(myBaseObjects[i].get(), myPath.get(), myVec.get());
break;
}
//=================================================================================
void GenerationGUI_PipeDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
- objMap[GroupPoints->LineEdit2->text()] = myPath;
-
- addSubshapesToFather(objMap);
+ GEOMBase::PublishSubObject( myPath.get() );
+ GEOMBase::PublishSubObject( myVec.get() );
}
//=================================================================================
//=================================================================================
bool GenerationGUI_PipeDlg::extractPrefix() const
{
- return myBaseObjects.length() > 1;
+ return myBaseObjects.count() > 1;
}
#ifndef GENERATIONGUI_PIPEDLG_H
#define GENERATIONGUI_PIPEDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_3Sel1Check;
void enterEvent( QEvent* );
private:
- GEOM::ListOfGO myBaseObjects; /* Base shapes */
- GEOM::GEOM_Object_var myPath; /* Shape, defining the path */
- GEOM::GEOM_Object_var myVec; /* Vector, defining the constant binormal direction */
- bool myOkBase;
- bool myOkPath;
- bool myOkVec; /* to check when arguments are defined */
+ QList<GEOM::GeomObjPtr> myBaseObjects; /* Base shapes */
+ GEOM::GeomObjPtr myPath; /* Shape, defining the path */
+ GEOM::GeomObjPtr myVec; /* Vector, defining the constant binormal direction */
- DlgRef_3Sel1Check* GroupPoints;
+ DlgRef_3Sel1Check* GroupPoints;
private slots:
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ConstructorsClicked( int );
//=================================================================================
GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl)
- : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
- myInitial(true)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
{
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PRISM")));
mainFrame()->RadioButton3->setIcon(image3);
mainFrame()->RadioButton1->setChecked(true);
- myBothway = myBothway2 = myBothway3 = false;
GroupPoints = new DlgRef_2Sel1Spin2Check(centralWidget());
GroupPoints->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV"));
GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->CheckButton1->setText(tr("GEOM_BOTHWAY"));
- GroupPoints->CheckButton1->setChecked(myBothway);
GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE"));
GroupPoints2 = new DlgRef_3Sel1Check(centralWidget());
GroupPoints2->PushButton2->setIcon(image1);
GroupPoints2->PushButton3->setIcon(image1);
GroupPoints2->CheckButton1->setText(tr("GEOM_BOTHWAY"));
- GroupPoints2->CheckButton1->setChecked(myBothway2);
GroupPoints3 = new DlgRef_1Sel3Spin1Check(centralWidget());
GroupPoints3->GroupBox1->setTitle(tr("GEOM_EXTRUSION_DXDYDZ"));
GroupPoints3->TextLabel3->setText(tr("GEOM_DY"));
GroupPoints3->TextLabel4->setText(tr("GEOM_DZ"));
GroupPoints3->CheckButton1->setText(tr("GEOM_BOTHWAY"));
- GroupPoints3->CheckButton1->setChecked(myBothway3);
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
GroupPoints3->LineEdit1->setText("");
- myPoint1 = myPoint2 = myVec = GEOM::GEOM_Object::_nil();
- myOkBase = myOkVec = myOkPnt1 = myOkPnt2 = false;
+ myBaseObjects.clear();
+ myPoint1.nullify();
+ myPoint2.nullify();
+ myVec.nullify();
// signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(GroupPoints->PushButton1, 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(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
connect(GroupPoints2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints2->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- 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(GroupPoints2->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
- 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_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
- connect(GroupPoints3->SpinBox_DZ, SIGNAL(valueChanged (double)), this, SLOT(ValueChangedInSpinBox()));
- connect(GroupPoints3->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
+ connect(GroupPoints3->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(GroupPoints3->SpinBox_DX, 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->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
initName(tr("GEOM_EXTRUSION"));
//=================================================================================
void GenerationGUI_PrismDlg::ConstructorsClicked (int constructorId)
{
- disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
-
switch (constructorId) {
case 0:
- {
- GroupPoints2->hide();
- GroupPoints3->hide();
- GroupPoints->show();
-
- GroupPoints->LineEdit1->setText(GroupPoints2->LineEdit1->text()); // keep base
- GroupPoints->LineEdit2->setText("");
- myVec = GEOM::GEOM_Object::_nil();
- myOkVec = false;
-
- GroupPoints->PushButton1->click();
- break;
- }
+ GroupPoints2->hide();
+ GroupPoints3->hide();
+ GroupPoints->show();
+
+ GroupPoints->LineEdit2->setText("");
+ myVec.nullify();
+
+ GroupPoints->PushButton1->click();
+ break;
case 1:
- {
- GroupPoints->hide();
- GroupPoints2->show();
- GroupPoints3->hide();
-
- GroupPoints2->LineEdit1->setText(GroupPoints->LineEdit1->text()); // keep base
- GroupPoints2->LineEdit2->setText("");
- GroupPoints2->LineEdit3->setText("");
- myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
- myOkPnt1 = myOkPnt2 = false;
-
- GroupPoints2->PushButton1->click();
- break;
- }
+ GroupPoints->hide();
+ GroupPoints2->show();
+ GroupPoints3->hide();
+
+ GroupPoints2->LineEdit2->setText("");
+ GroupPoints2->LineEdit3->setText("");
+ myPoint1.nullify();
+ myPoint2.nullify();
+
+ GroupPoints2->PushButton1->click();
+ break;
case 2:
- {
- GroupPoints->hide();
- GroupPoints2->hide();
- GroupPoints3->show();
-
- GroupPoints3->LineEdit1->setText(GroupPoints->LineEdit1->text()); // keep base
-
- GroupPoints3->PushButton1->click();
- break;
- }
+ GroupPoints->hide();
+ GroupPoints2->hide();
+ GroupPoints3->show();
+
+ GroupPoints3->PushButton1->click();
+ break;
+ default:
+ break;
}
qApp->processEvents();
erasePreview();
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 ||
- myEditCurrentArgument == GroupPoints2->LineEdit1 ||
- getConstructorId() == 2 ) {
- myOkBase = false;
- if ( nbSel > 0 ) {
- GEOMBase::ConvertListOfIOInListOfGO(aSelList, myBaseObjects, true);
- myEditCurrentArgument->setText( aBaseName );
- myOkBase = true;
+ if ( myEditCurrentArgument == GroupPoints->LineEdit1 ||
+ myEditCurrentArgument == GroupPoints2->LineEdit1 ||
+ myEditCurrentArgument == GroupPoints3->LineEdit1 ) {
+ myBaseObjects.clear();
+ QList<GEOM::GeomObjPtr> objects = getSelected( TopAbs_SHAPE, -1 );
+ for ( int i = 0; i < objects.count(); i++ ) {
+ GEOM::shape_type stype = objects[i]->GetMaxShapeType();
+ if ( stype < GEOM::SHELL || stype > GEOM::VERTEX )
+ continue;
+ myBaseObjects << objects[i];
}
- displayPreview();
- return;
- }
-
- if (getConstructorId() == 0)
- {
- if (aSelList.Extent() < 1) {
- if (myEditCurrentArgument == GroupPoints->LineEdit2)
- myOkVec = false;
- return;
+ if ( !myBaseObjects.isEmpty() ) {
+ QString aName = myBaseObjects.count() > 1 ? QString( "%1_objects").arg( myBaseObjects.count() ) : GEOMBase::GetName( myBaseObjects[0].get() );
+ GroupPoints->LineEdit1->setText( aName );
+ GroupPoints2->LineEdit1->setText( aName );
+ GroupPoints3->LineEdit1->setText( aName );
}
-
- 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 {
- aSelectedObject = aFindedObject; // get Object from study
- }
- }
- else { // Global Selection
- if (aShape.ShapeType() != TopAbs_EDGE && myEditCurrentArgument == GroupPoints->LineEdit2) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- myOk = false;
- }
- }
- }
-
- if (myEditCurrentArgument == GroupPoints->LineEdit2 && myOk) {
- myEditCurrentArgument->setText(aName);
- myOkVec = true;
- myVec = aSelectedObject;
+ else {
+ GroupPoints->LineEdit1->setText( "" );
+ GroupPoints2->LineEdit1->setText( "" );
+ GroupPoints3->LineEdit1->setText( "" );
}
}
- else if (getConstructorId() == 1) { // getConstructorId()==1 - extrusion using 2 points
- if (aSelList.Extent() != 1) {
- if (myEditCurrentArgument == GroupPoints2->LineEdit2) {
- myPoint1 = GEOM::GEOM_Object::_nil();
- myOkPnt1 = false;
- }
- else if (myEditCurrentArgument == GroupPoints2->LineEdit3) {
- myPoint2 = GEOM::GEOM_Object::_nil();
- myOkPnt2 = false;
- }
- return;
+ else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
+ myVec = getSelected( TopAbs_EDGE );
+ if ( myVec ) {
+ QString aName = GEOMBase::GetName( myVec.get() );
+ myEditCurrentArgument->setText( aName );
+ if ( myBaseObjects.isEmpty() )
+ GroupPoints->PushButton1->click();
}
-
- 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);
-
- if (myEditCurrentArgument == GroupPoints2->LineEdit2 && myOk) {
- myOkPnt1 = true;
- myPoint1 = aSelectedObject;
- if (!myOkPnt2)
- GroupPoints2->PushButton3->click();
+ }
+ if ( myEditCurrentArgument == GroupPoints2->LineEdit2 ) {
+ myPoint1 = getSelected( TopAbs_VERTEX );
+ if ( myPoint1 ) {
+ QString aName = GEOMBase::GetName( myPoint1.get() );
+ myEditCurrentArgument->setText( aName );
+ if ( !myPoint2 )
+ GroupPoints2->PushButton3->click();
+ else if ( myBaseObjects.isEmpty() )
+ GroupPoints2->PushButton1->click();
}
- else if (myEditCurrentArgument == GroupPoints2->LineEdit3 && myOk) {
- myOkPnt2 = true;
- myPoint2 = aSelectedObject;
- if (!myOkBase)
- 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();
}
-//=================================================================================
-// 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()
// purpose :
//=================================================================================
bool GenerationGUI_PrismDlg::isValid (QString& msg)
{
- bool ok = true;
- if( getConstructorId() == 0 )
- ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- else if( getConstructorId() == 2 )
- {
- ok = GroupPoints3->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupPoints3->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
- ok = GroupPoints3->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
+ bool ok = false;
+ switch ( getConstructorId() ) {
+ case 0:
+ ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ !myBaseObjects.isEmpty() && myVec;
+ break;
+ case 1:
+ 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 (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;
+ return ok;
}
//=================================================================================
bool GenerationGUI_PrismDlg::execute (ObjectList& objects)
{
QStringList aParameters;
- GEOM::GEOM_Object_var anObj, aBaseObj;
+ GEOM::GEOM_Object_var anObj;
GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
- for (int i=0; i < myBaseObjects.length(); i++) {
- aBaseObj = myBaseObjects[i];
-
+ for (int i = 0; i < myBaseObjects.count(); i++) {
switch (getConstructorId()) {
case 0:
- if (!myBothway)
- anObj = anOper->MakePrismVecH(aBaseObj, myVec, getHeight());
+ if (!GroupPoints->CheckButton1->isChecked())
+ anObj = anOper->MakePrismVecH(myBaseObjects[i].get(), myVec.get(), getHeight());
else
- anObj = anOper->MakePrismVecH2Ways(aBaseObj, myVec, getHeight());
+ anObj = anOper->MakePrismVecH2Ways(myBaseObjects[i].get(), myVec.get(), getHeight());
if (!anObj->_is_nil() && !IsPreview()) {
aParameters << GroupPoints->SpinBox_DX->text();
}
break;
case 1:
- if (!myBothway2)
- anObj = anOper->MakePrismTwoPnt(aBaseObj, myPoint1, myPoint2);
+ if (!GroupPoints2->CheckButton1->isChecked())
+ anObj = anOper->MakePrismTwoPnt(myBaseObjects[i].get(), myPoint1.get(), myPoint2.get());
else
- anObj = anOper->MakePrismTwoPnt2Ways(aBaseObj, myPoint1, myPoint2);
+ anObj = anOper->MakePrismTwoPnt2Ways(myBaseObjects[i].get(), myPoint1.get(), myPoint2.get());
break;
case 2:
double dx = GroupPoints3->SpinBox_DX->value();
double dy = GroupPoints3->SpinBox_DY->value();
double dz = GroupPoints3->SpinBox_DZ->value();
- if (!myBothway3)
- anObj = anOper->MakePrismDXDYDZ(aBaseObj, dx, dy, dz);
+ if (!GroupPoints3->CheckButton1->isChecked())
+ anObj = anOper->MakePrismDXDYDZ(myBaseObjects[i].get(), dx, dy, dz);
else
- anObj = anOper->MakePrismDXDYDZ2Ways(aBaseObj, dx, dy, dz);
+ anObj = anOper->MakePrismDXDYDZ2Ways(myBaseObjects[i].get(), dx, dy, dz);
if (!anObj->_is_nil() && !IsPreview()) {
aParameters << GroupPoints3->SpinBox_DX->text();
//=================================================================================
void GenerationGUI_PrismDlg::onBothway()
{
- bool anOldValue;
- switch (getConstructorId()) {
- case 0:
- anOldValue = myBothway;
- myBothway = !anOldValue;
- GroupPoints->CheckButton2->setEnabled(!myBothway);
- displayPreview();
- break;
- case 1:
- anOldValue = myBothway2;
- myBothway2 = !anOldValue;
- displayPreview();
- break;
- case 2:
- anOldValue = myBothway3;
- myBothway3 = !anOldValue;
- displayPreview();
- break;
- }
+ GroupPoints->CheckButton2->setEnabled(!GroupPoints->CheckButton1->isChecked());
+ displayPreview();
}
//=================================================================================
//=================================================================================
void GenerationGUI_PrismDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
switch (getConstructorId()) {
case 0:
- objMap[GroupPoints->LineEdit2->text()] = myVec;
+ GEOMBase::PublishSubObject( myVec.get() );
break;
case 1:
- objMap[GroupPoints2->LineEdit2->text()] = myPoint1;
- objMap[GroupPoints2->LineEdit3->text()] = myPoint2;
+ GEOMBase::PublishSubObject( myPoint1.get() );
+ GEOMBase::PublishSubObject( myPoint2.get() );
+ break;
+ default:
break;
}
- addSubshapesToFather(objMap);
}
//=================================================================================
//=================================================================================
bool GenerationGUI_PrismDlg::extractPrefix() const
{
- return myBaseObjects.length() > 1;
+ return myBaseObjects.count() > 1;
}
#ifndef GENERATIONGUI_PRISMDLG_H
#define GENERATIONGUI_PRISMDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel1Spin2Check;
class DlgRef_3Sel1Check;
double getHeight() const;
private:
- GEOM::ListOfGO myBaseObjects; /* Base shapes */
- GEOM::GEOM_Object_var myVec; /* Vector, defining the direction */
- GEOM::GEOM_Object_var 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;
+ QList<GEOM::GeomObjPtr> myBaseObjects; /* Base shapes */
+ GEOM::GeomObjPtr myVec; /* Vector, defining the direction */
+ GEOM::GeomObjPtr myPoint1, myPoint2; /* Points for extrusion */
DlgRef_2Sel1Spin2Check* GroupPoints;
DlgRef_3Sel1Check* GroupPoints2; // for second layout for extrusion using 2 points
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ConstructorsClicked( int );
mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close();
- myBothway = false;
GroupPoints = new DlgRef_2Sel1Spin2Check(centralWidget());
GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
- myAxis = GEOM::GEOM_Object::_nil();
- myOkBase = myOkAxis = false;
+
+ myBaseObjects.clear();
+ myAxis.nullify();
// signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(GroupPoints->PushButton1, 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->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse()));
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()
// purpose : Called when selection is changed or on dialog initialization or activation
{
erasePreview();
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) {
- myOkBase = false;
- if (aSelList.Extent() > 1)
- aName = QString( "%1_objects").arg( aSelList.Extent() );
-
- if ( aSelList.Extent() > 0 ) {
- GEOMBase::ConvertListOfIOInListOfGO(aSelList, myBaseObjects, true);
- // check base shapes
- for (int i=0; i < myBaseObjects.length(); i++) {
- GEOMBase::GetShape(myBaseObjects[i], S);
- if (!isAcceptableBase(S))
- return;
- }
+
+ if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
+ myBaseObjects.clear();
+ QList<GEOM::GeomObjPtr> objects = getSelected( TopAbs_SHAPE, -1 );
+ for ( int i = 0; i < objects.count(); i++ ) {
+ GEOM::shape_type stype = objects[i]->GetMaxShapeType();
+ if ( stype < GEOM::SHELL || stype > GEOM::VERTEX )
+ continue;
+ myBaseObjects << objects[i];
+ }
+ if ( !myBaseObjects.isEmpty() ) {
+ QString aName = myBaseObjects.count() > 1 ? QString( "%1_objects").arg( myBaseObjects.count() ) : GEOMBase::GetName( myBaseObjects[0].get() );
myEditCurrentArgument->setText( aName );
- myOkBase = true;
}
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
- 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());
- 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;
+ myAxis = getSelected( TopAbs_EDGE );
+ if ( myAxis ) {
+ QString aName = GEOMBase::GetName( myAxis.get() );
+ myEditCurrentArgument->setText( aName );
+ if ( myBaseObjects.isEmpty() )
+ GroupPoints->PushButton1->click();
}
- myEditCurrentArgument->setText(aName);
- if (myOkAxis && !myOkBase)
- GroupPoints->PushButton1->click();
}
-
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()
// purpose :
//=================================================================================
bool GenerationGUI_RevolDlg::isValid (QString& msg)
{
- bool ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() );
- return myOkBase && myOkAxis && ok;
+ return GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && !myBaseObjects.isEmpty() && myAxis;
}
//=================================================================================
//=================================================================================
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());
- for (int i=0; i < myBaseObjects.length(); i++) {
- aBase = myBaseObjects[i];
-
- if (!myBothway)
- anObj = anOper->MakeRevolutionAxisAngle(aBase, myAxis, getAngle() * PI180);
+ for (int i = 0; i < myBaseObjects.count(); i++) {
+ if (!GroupPoints->CheckButton1->isChecked())
+ anObj = anOper->MakeRevolutionAxisAngle(myBaseObjects[i].get(), myAxis.get(), getAngle() * PI180);
else
- anObj = anOper->MakeRevolutionAxisAngle2Ways(aBase, myAxis, getAngle() * PI180);
+ anObj = anOper->MakeRevolutionAxisAngle2Ways(myBaseObjects[i].get(), myAxis.get(), getAngle() * PI180);
if (!anObj->_is_nil()) {
if (!IsPreview()) {
//=================================================================================
void GenerationGUI_RevolDlg::onBothway()
{
- bool anOldValue = myBothway;
- myBothway = !anOldValue;
- GroupPoints->CheckButton2->setEnabled(!myBothway);
+ GroupPoints->CheckButton2->setEnabled(!GroupPoints->CheckButton1->isChecked());
displayPreview();
}
//=================================================================================
void GenerationGUI_RevolDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
- objMap[GroupPoints->LineEdit2->text()] = myAxis;
-
- addSubshapesToFather(objMap);
+ GEOMBase::PublishSubObject( myAxis.get() );
}
//=================================================================================
//=================================================================================
bool GenerationGUI_RevolDlg::extractPrefix() const
{
- return myBaseObjects.length() > 1;
+ return myBaseObjects.count() > 1;
}
#ifndef GENERATIONGUI_REVOLUTIONDLG_H
#define GENERATIONGUI_REVOLUTIONDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel1Spin2Check;
double getAngle() const;
private:
- GEOM::ListOfGO myBaseObjects; /* Base shapes */
- GEOM::GEOM_Object_var myAxis; /* Axis of the revolution */
- bool myOkBase;
- bool myOkAxis;
- bool myBothway;
+ QList<GEOM::GeomObjPtr> myBaseObjects; /* Base shapes */
+ GEOM::GeomObjPtr myAxis; /* Axis of the revolution */
DlgRef_2Sel1Spin2Check* GroupPoints;
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ValueChangedInSpinBox();
#include <TopTools_IndexedMapOfShape.hxx>
#include <GEOMImpl_Types.hxx>
-//#include <ostream>
//=================================================================================
// class : PrimitiveGUI_BoxDlg()
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
- myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
+ myPoint1.nullify();
+ myPoint2.nullify();
double initValue = 200.0;
GroupDimensions->SpinBox_DX->setValue(initValue);
connect(GroupPoints->PushButton1, 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_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) {
- if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil();
+ if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1.nullify();
+ else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2.nullify();
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
+ GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX );
TopoDS_Shape aShape;
- if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
- {
- TColStd_IndexedMapOfInteger aMap;
- aSelMgr->GetIndexes(aSelList.First(), aMap);
- if (aMap.Extent() == 1) // Local Selection
- {
- int anIndex = aMap(1);
- aName.append(":vertex_" + QString::number(anIndex));
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
- //Find SubShape Object in Father
- GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
+ myEditCurrentArgument->setText(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
- }
+ // clear selection
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+ myGeomGUI->getApp()->selectionMgr()->clearSelected();
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
+
+ if (myEditCurrentArgument == GroupPoints->LineEdit1) {
+ myPoint1 = aSelectedObject;
+ if (myPoint1 && !myPoint2)
+ GroupPoints->PushButton2->click();
}
- else // Global Selection
- {
- if (aShape.ShapeType() != TopAbs_VERTEX) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- }
+ else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
+ myPoint2 = aSelectedObject;
+ if (myPoint2 && !myPoint1)
+ GroupPoints->PushButton1->click();
}
+
}
-
- myEditCurrentArgument->setText(aName);
-
- // clear selection
- disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- myGeomGUI->getApp()->selectionMgr()->clearSelected();
- connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
- this, SLOT(SelectionIntoArgument()));
-
- if (myEditCurrentArgument == GroupPoints->LineEdit1) {
- myPoint1 = aSelectedObject;
- if (!myPoint1->_is_nil() && myPoint2->_is_nil())
- GroupPoints->PushButton2->click();
- }
- else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
- myPoint2 = aSelectedObject;
- if (!myPoint2->_is_nil() && myPoint1->_is_nil())
- GroupPoints->PushButton1->click();
- }
-
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()
// purpose :
//=================================================================================
bool PrimitiveGUI_BoxDlg::isValid (QString& msg)
{
- bool ok = true;
+ bool ok = false;
if( getConstructorId() == 1 )
{
- ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
-
- ok = fabs( GroupDimensions->SpinBox_DX->value() ) > Precision::Confusion() && ok;
- ok = fabs( GroupDimensions->SpinBox_DY->value() ) > Precision::Confusion() && ok;
- ok = fabs( GroupDimensions->SpinBox_DZ->value() ) > Precision::Confusion() && ok;
+ ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) &&
+ qAbs( GroupDimensions->SpinBox_DX->value() ) > Precision::Confusion() &&
+ qAbs( GroupDimensions->SpinBox_DY->value() ) > Precision::Confusion() &&
+ qAbs( GroupDimensions->SpinBox_DZ->value() ) > Precision::Confusion();
+ }
+ else
+ {
+ ok = myPoint1 && myPoint2 && myPoint1 != myPoint2;
}
- return getConstructorId() == 0 ? !(myPoint1->_is_nil() || myPoint2->_is_nil()) : ok;
+ return ok;
}
//=================================================================================
switch (getConstructorId()) {
case 0:
{
- if (!CORBA::is_nil(myPoint1) && !CORBA::is_nil(myPoint2)) {
- anObj = anOper->MakeBoxTwoPnt(myPoint1, myPoint2);
+ if ( myPoint1 && myPoint2 ) {
+ anObj = anOper->MakeBoxTwoPnt(myPoint1.get(), myPoint2.get());
res = true;
}
}
void PrimitiveGUI_BoxDlg::addSubshapesToStudy()
{
if (getConstructorId() == 0) {
- QMap<QString, GEOM::GEOM_Object_var> objMap;
- objMap[GroupPoints->LineEdit1->text()] = myPoint1;
- objMap[GroupPoints->LineEdit2->text()] = myPoint2;
- addSubshapesToFather(objMap);
+ GEOMBase::PublishSubObject( myPoint1.get() );
+ GEOMBase::PublishSubObject( myPoint2.get() );
}
}
#ifndef PRIMITIVEGUI_BOXDLG_H
#define PRIMITIVEGUI_BOXDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel;
class DlgRef_3Spin;
void enterEvent( QEvent* );
private:
- GEOM::GEOM_Object_var myPoint1, myPoint2; /* Points containing the vector */
+ GEOM::GeomObjPtr myPoint1, myPoint2; /* Points containing the vector */
DlgRef_2Sel* GroupPoints;
DlgRef_3Spin* GroupDimensions;
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ConstructorsClicked( int );
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
- myPoint = myDir = GEOM::GEOM_Object::_nil();
+ myPoint.nullify();
+ myDir.nullify();
double aRadius1(100.0), aRadius2(0.0), aHeight(300.0);
GroupPoints->SpinBox_DX->setValue(aRadius1);
connect(GroupPoints->PushButton1, 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_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) {
- if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = GEOM::GEOM_Object::_nil();
+ if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint.nullify();
+ else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir.nullify();
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
+ TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupPoints->LineEdit2 ? TopAbs_EDGE : TopAbs_VERTEX;
+ GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
TopoDS_Shape aShape;
- if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
- {
- 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
- }
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+
+ myEditCurrentArgument->setText(aName);
+
+ // clear selection
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+ myGeomGUI->getApp()->selectionMgr()->clearSelected();
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
+
+ if (myEditCurrentArgument == GroupPoints->LineEdit1) {
+ myPoint = aSelectedObject;
+ if (myPoint && !myDir)
+ GroupPoints->PushButton2->click();
}
- else // Global Selection
- {
- if (aShape.ShapeType() != aNeedType) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- }
+ else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
+ myDir = aSelectedObject;
+ if (myDir && !myPoint)
+ GroupPoints->PushButton1->click();
}
}
- myEditCurrentArgument->setText(aName);
-
- // clear selection
- disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- myGeomGUI->getApp()->selectionMgr()->clearSelected();
- connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
- this, SLOT(SelectionIntoArgument()));
-
- if (myEditCurrentArgument == GroupPoints->LineEdit1) {
- myPoint = aSelectedObject;
- if (!myPoint->_is_nil() && myDir->_is_nil())
- GroupPoints->PushButton2->click();
- }
- else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
- myDir = aSelectedObject;
- if (!myDir->_is_nil() && myPoint->_is_nil())
- GroupPoints->PushButton1->click();
- }
-
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()
// purpose :
//=================================================================================
bool PrimitiveGUI_ConeDlg::isValid (QString& msg)
{
- if (!getRadius1() && !getRadius2())
- return false;
-
- bool ok = true;
+ bool ok = false;
if( getConstructorId() == 0 )
{
- ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
- ok = GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
+ GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) &&
+ myPoint && myDir;
}
else if( getConstructorId() == 1 )
{
- ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() );
}
- ok = fabs( getHeight() ) > Precision::Confusion() && ok;
- return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) && ok : ok;
+ ok = ( getRadius1() > 0 || getRadius2() > 0 ) && qAbs( getHeight() ) > Precision::Confusion() && ok;
+ return ok;
}
//=================================================================================
switch (getConstructorId()) {
case 0:
- if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) {
- anObj = anOper->MakeConePntVecR1R2H(myPoint, myDir, getRadius1(), getRadius2(), getHeight());
+ if ( myPoint && myDir ) {
+ anObj = anOper->MakeConePntVecR1R2H(myPoint.get(), myDir.get(), getRadius1(), getRadius2(), getHeight());
if (!anObj->_is_nil() && !IsPreview())
{
QStringList aParameters;
//=================================================================================
void PrimitiveGUI_ConeDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
- switch (getConstructorId()) {
- case 0:
- objMap[GroupPoints->LineEdit1->text()] = myPoint;
- objMap[GroupPoints->LineEdit2->text()] = myDir;
- break;
- case 1:
- return;
+ if ( getConstructorId() == 0 ) {
+ GEOMBase::PublishSubObject( myPoint.get() );
+ GEOMBase::PublishSubObject( myDir.get() );
}
- addSubshapesToFather(objMap);
}
#ifndef PRIMITIVEGUI_CONEDLG_H
#define PRIMITIVEGUI_CONEDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel3Spin;
class DlgRef_3Spin;
double getHeight() const;
private:
- GEOM::GEOM_Object_var myPoint, myDir;
+ GEOM::GeomObjPtr myPoint, myDir;
DlgRef_2Sel3Spin* GroupPoints;
DlgRef_3Spin* GroupDimensions;
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ConstructorsClicked( int );
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
- myPoint = myDir = GEOM::GEOM_Object::_nil();
+ myPoint.nullify();
+ myDir.nullify();
double aRadius(100.0), aHeight(300.0);
GroupPoints->SpinBox_DX->setValue(aRadius);
connect(GroupPoints->PushButton1, 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_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPoints->LineEdit1)
- myPoint = GEOM::GEOM_Object::_nil();
+ myPoint.nullify();
else if (myEditCurrentArgument == GroupPoints->LineEdit2)
- myDir = GEOM::GEOM_Object::_nil();
+ myDir.nullify();
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
+ TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupPoints->LineEdit2 ? TopAbs_EDGE : TopAbs_VERTEX;
+ GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
TopoDS_Shape aShape;
- if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
- {
- 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
- }
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+
+ myEditCurrentArgument->setText(aName);
+
+ // clear selection
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+ myGeomGUI->getApp()->selectionMgr()->clearSelected();
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
+
+ if (myEditCurrentArgument == GroupPoints->LineEdit1) {
+ myPoint = aSelectedObject;
+ if (myPoint && !myDir)
+ GroupPoints->PushButton2->click();
}
- else { // Global Selection
- if (aShape.ShapeType() != aNeedType) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- }
+ else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
+ myDir = aSelectedObject;
+ if (myDir && !myPoint)
+ GroupPoints->PushButton1->click();
}
}
- myEditCurrentArgument->setText(aName);
-
- // clear selection
- disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- myGeomGUI->getApp()->selectionMgr()->clearSelected();
- connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
- this, SLOT(SelectionIntoArgument()));
-
- if (myEditCurrentArgument == GroupPoints->LineEdit1) {
- myPoint = aSelectedObject;
- if (!myPoint->_is_nil() && myDir->_is_nil())
- GroupPoints->PushButton2->click();
- }
- else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
- myDir = aSelectedObject;
- if (!myDir->_is_nil() && myPoint->_is_nil())
- GroupPoints->PushButton1->click();
- }
-
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()
// purpose :
//=================================================================================
bool PrimitiveGUI_CylinderDlg::isValid (QString& msg)
{
- bool ok = true;
+ bool ok = false;
if( getConstructorId() == 0 )
{
- ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
+ myPoint && myDir;
}
else if( getConstructorId() == 1 )
{
- ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() );
}
- ok = fabs( getHeight() ) > Precision::Confusion() && ok;
- return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) && ok : ok;
+ ok = qAbs( getHeight() ) > Precision::Confusion() && ok;
+ return ok;
}
//=================================================================================
switch (getConstructorId()) {
case 0:
- if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) {
- anObj = anOper->MakeCylinderPntVecRH(myPoint, myDir, getRadius(), getHeight());
+ if ( myPoint && myDir ) {
+ anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight());
if (!anObj->_is_nil() && !IsPreview())
{
QStringList aParameters;
//=================================================================================
void PrimitiveGUI_CylinderDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
- switch (getConstructorId()) {
- case 0:
- objMap[GroupPoints->LineEdit1->text()] = myPoint;
- objMap[GroupPoints->LineEdit2->text()] = myDir;
- break;
- case 1:
- return;
+ if ( getConstructorId() == 0 ) {
+ GEOMBase::PublishSubObject( myPoint.get() );
+ GEOMBase::PublishSubObject( myDir.get() );
}
- addSubshapesToFather(objMap);
}
#ifndef PRIMITIVEGUI_CYLINDERDLG_H
#define PRIMITIVEGUI_CYLINDERDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel2Spin;
class DlgRef_2Spin;
double getHeight() const;
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
bool myInitial;
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ConstructorsClicked( int );
Group3Pnts->LineEdit1->setText("");
Group3Pnts->LineEdit2->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);
GroupDimensions->SpinBox_DX->setValue(100);
connect(GroupPntVecR->PushButton1, 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->PushButton2, 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(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) {
- if (myEditCurrentArgument == GroupPntVecR->LineEdit1) myPoint = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) myDir = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == Group3Pnts->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == Group3Pnts->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == Group3Pnts->LineEdit3) myPoint3 = GEOM::GEOM_Object::_nil();
+ if (myEditCurrentArgument == GroupPntVecR->LineEdit1) myPoint.nullify();
+ else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) myDir.nullify();
+ else if (myEditCurrentArgument == Group3Pnts->LineEdit1) myPoint1.nullify();
+ else if (myEditCurrentArgument == Group3Pnts->LineEdit2) myPoint2.nullify();
+ else if (myEditCurrentArgument == Group3Pnts->LineEdit3) myPoint3.nullify();
return;
}
- // nbSel == 1
- Handle(SALOME_InteractiveObject) anIO = aSelList.First();
- 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
+ TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupPntVecR->LineEdit2 ? TopAbs_EDGE : TopAbs_VERTEX;
+ GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
TopoDS_Shape aShape;
- if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
- {
- 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
- }
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+
+ myEditCurrentArgument->setText(aName);
+
+ // clear selection
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+ myGeomGUI->getApp()->selectionMgr()->clearSelected();
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
+
+ if (myEditCurrentArgument == GroupPntVecR->LineEdit1) {
+ myPoint = aSelectedObject;
+ if (myPoint && !myDir)
+ GroupPntVecR->PushButton2->click();
}
- else { // Global Selection
- if (aShape.ShapeType() != aNeedType) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- }
+ else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) {
+ myDir = aSelectedObject;
+ if (myDir && !myPoint)
+ GroupPntVecR->PushButton1->click();
+ }
+ else if (myEditCurrentArgument == Group3Pnts->LineEdit1) {
+ myPoint1 = aSelectedObject;
+ if (myPoint1 && !myPoint2)
+ Group3Pnts->PushButton2->click();
+ }
+ else if (myEditCurrentArgument == Group3Pnts->LineEdit2) {
+ myPoint2 = aSelectedObject;
+ if (myPoint2 && !myPoint3)
+ Group3Pnts->PushButton3->click();
+ }
+ else if (myEditCurrentArgument == Group3Pnts->LineEdit3) {
+ myPoint3 = aSelectedObject;
+ if (myPoint3 && !myPoint1)
+ Group3Pnts->PushButton1->click();
}
- }
-
- myEditCurrentArgument->setText(aName);
-
- // clear selection
- disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- myGeomGUI->getApp()->selectionMgr()->clearSelected();
- connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
- this, SLOT(SelectionIntoArgument()));
-
- if (myEditCurrentArgument == GroupPntVecR->LineEdit1) {
- myPoint = aSelectedObject;
- if (!myPoint->_is_nil() && myDir->_is_nil())
- GroupPntVecR->PushButton2->click();
- }
- else if (myEditCurrentArgument == GroupPntVecR->LineEdit2) {
- myDir = aSelectedObject;
- if (!myDir->_is_nil() && myPoint->_is_nil())
- GroupPntVecR->PushButton1->click();
- }
- else if (myEditCurrentArgument == Group3Pnts->LineEdit1) {
- myPoint1 = aSelectedObject;
- if (!myPoint1->_is_nil() && myPoint2->_is_nil())
- Group3Pnts->PushButton2->click();
- }
- else if (myEditCurrentArgument == Group3Pnts->LineEdit2) {
- myPoint2 = aSelectedObject;
- if (!myPoint2->_is_nil() && myPoint3->_is_nil())
- Group3Pnts->PushButton3->click();
- }
- else if (myEditCurrentArgument == Group3Pnts->LineEdit3) {
- myPoint3 = aSelectedObject;
- if (!myPoint3->_is_nil() && myPoint1->_is_nil())
- Group3Pnts->PushButton1->click();
}
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()
// purpose :
//=================================================================================
bool PrimitiveGUI_DiskDlg::isValid (QString& msg)
{
- bool ok = true;
- if( getConstructorId() == 0 )
- ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- else if( getConstructorId() == 1 )
- ok = GroupPntVecR->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
-
- const int id = getConstructorId();
- if (id == 0)
- 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;
+ bool ok = false;
+ if ( getConstructorId() == 0 )
+ ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && getRadius() > 0;
+ else if ( getConstructorId() == 1 )
+ ok = GroupPntVecR->SpinBox_DX->isValid( msg, !IsPreview() ) && myPoint && myDir && getRadius() > 0;
+ else if ( getConstructorId() == 2 )
+ ok = myPoint1 && myPoint2 && myPoint3 && myPoint1 != myPoint2 && myPoint1 != myPoint3 && myPoint2 != myPoint3;
+ return ok;
}
//=================================================================================
res = true;
break;
case 1:
- anObj = anOper->MakeDiskPntVecR(myPoint, myDir, getRadius());
+ anObj = anOper->MakeDiskPntVecR(myPoint.get(), myDir.get(), getRadius());
if (!anObj->_is_nil() && !IsPreview())
{
aParameters << GroupPntVecR->SpinBox_DX->text();
res = true;
break;
case 2:
- anObj = anOper->MakeDiskThreePnt(myPoint1, myPoint2, myPoint3);
+ anObj = anOper->MakeDiskThreePnt(myPoint1.get(), myPoint2.get(), myPoint3.get());
res = true;
break;
}
//=================================================================================
void PrimitiveGUI_DiskDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
switch (getConstructorId()) {
case 1:
- objMap[GroupPntVecR->LineEdit1->text()] = myPoint;
- objMap[GroupPntVecR->LineEdit2->text()] = myDir;
+ GEOMBase::PublishSubObject( myPoint.get() );
+ GEOMBase::PublishSubObject( myDir.get() );
break;
case 2:
- objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
- objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
- objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
+ GEOMBase::PublishSubObject( myPoint1.get() );
+ GEOMBase::PublishSubObject( myPoint2.get() );
+ GEOMBase::PublishSubObject( myPoint3.get() );
+ break;
+ default:
break;
}
- addSubshapesToFather(objMap);
}
#ifndef BASICGUI_DISKDLG_H
#define BASICGUI_DISKDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_3Sel;
class DlgRef_2Sel1Spin;
int myOrientationType;
private:
- GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3;
+ GEOM::GeomObjPtr myPoint, myDir, myPoint1, myPoint2, myPoint3;
DlgRef_2Sel1Spin* GroupPntVecR;
DlgRef_3Sel* Group3Pnts;
void SelectionIntoArgument();
void ConstructorsClicked( int );
- void LineEditReturnPressed();
void SetEditCurrentArgument();
void ValueChangedInSpinBox();
void SetDoubleSpinBoxStep( double );
/* init variables */
myEditCurrentArgument = GroupPlane->LineEdit1;
GroupType->RadioButton1->setChecked(true);
- myEdge = GEOM::GEOM_Object::_nil();
- myFace = GEOM::GEOM_Object::_nil();
+ myEdge.nullify();
+ myFace.nullify();
globalSelection(); // close local contexts, if any
// localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
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_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
GroupPlane->TextLabel1->setText( tr( "GEOM_FACE" ) );
}
+ myEditCurrentArgument = GroupPlane->LineEdit1;
+ myEditCurrentArgument->setText( "" );
+ myEdge.nullify();
+ myFace.nullify();
}
//=================================================================================
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
myEditCurrentArgument = GroupPlane->LineEdit1;
myEditCurrentArgument->setText("");
- myEdge = GEOM::GEOM_Object::_nil();
- myFace = GEOM::GEOM_Object::_nil();
+ myEdge.nullify();
+ myFace.nullify();
GroupType->RadioButton1->setChecked( true );
TypeButtonClicked();
GroupDimensions->hide();
aSelMgr->selectedObjects(aSelList);
if ( aSelList.Extent() != 1 ) {
- if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myEdge = GEOM::GEOM_Object::_nil();
+ if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myEdge.nullify();
return;
}
- // nbSel == 1
- TopAbs_ShapeEnum aNeedType = TopAbs_EDGE;
- GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
- if ( !CORBA::is_nil( aSelectedObject ) ) {
- QString aName = GEOMBase::GetName( aSelectedObject );
-
- TopoDS_Shape aShape;
- if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
- if (GroupType->RadioButton2->isChecked())
- 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 = "";
- }
- }
- }
+ TopAbs_ShapeEnum aNeedType = GroupType->RadioButton2->isChecked() ? TopAbs_FACE : TopAbs_EDGE;
+ GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
myEditCurrentArgument->setText( aName );
+
if ( myEditCurrentArgument == GroupPlane->LineEdit1 && aNeedType == TopAbs_EDGE )
myEdge = aSelectedObject;
else if ( myEditCurrentArgument == GroupPlane->LineEdit1 && aNeedType == TopAbs_FACE )
myFace = aSelectedObject;
}
+
displayPreview();
}
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()
// purpose :
//=================================================================================
bool PrimitiveGUI_FaceDlg::isValid( QString& msg )
{
- bool ok = true;
+ bool ok = false;
if( getConstructorId() == 0 )
{
- ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() );
}
else if( getConstructorId() == 1 )
{
- ok = GroupPlane->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupPlane->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupPlane->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupPlane->SpinBox_DY->isValid( msg, !IsPreview() ) &&
+ ( GroupType->RadioButton1->isChecked() ? myEdge : myFace );
}
-
- const int id = getConstructorId();
- if ( id == 0 )
- 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;
+ return ok;
}
//=================================================================================
break;
case 1:
anObj = GroupType->RadioButton1->isChecked() ?
- anOper->MakeFaceObjHW(myEdge, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value()) :
- anOper->MakeFaceObjHW(myFace, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value());
+ anOper->MakeFaceObjHW(myEdge.get(), 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())
{
aParameters << GroupPlane->SpinBox_DX->text();
//=================================================================================
void PrimitiveGUI_FaceDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
- switch ( getConstructorId() ) {
- case 1 :
+ if ( getConstructorId() == 1 ) {
if ( GroupType->RadioButton1->isChecked() )
- objMap[GroupPlane->LineEdit1->text()] = myEdge;
+ GEOMBase::PublishSubObject( myEdge.get() );
if ( GroupType->RadioButton2->isChecked() )
- objMap[GroupPlane->LineEdit1->text()] = myFace;
- break;
+ GEOMBase::PublishSubObject( myFace.get() );
}
- addSubshapesToFather( objMap );
}
#ifndef BASICGUI_FACEDLG_H
#define BASICGUI_FACEDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_2Spin;
class DlgRef_1Sel2Spin;
void enterEvent( QEvent* );
private:
- GEOM::GEOM_Object_var myEdge;
- GEOM::GEOM_Object_var myFace;
+ GEOM::GeomObjPtr myEdge;
+ GEOM::GeomObjPtr myFace;
int myOrientationType;
void DeactivateActiveDialog();
void ConstructorsClicked( int );
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ValueChangedInSpinBox( double );
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setReadOnly( true );
- myPoint = GEOM::GEOM_Object::_nil();
+ myPoint.nullify();
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
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( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setText( "" );
- myPoint = GEOM::GEOM_Object::_nil();
+ myPoint.nullify();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) {
- myPoint = GEOM::GEOM_Object::_nil();
+ myPoint.nullify();
return;
}
- /* nbSel == 1 ! */
- GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
-
- if ( CORBA::is_nil( aSelectedObject ) )
- return;
-
- QString aName = GEOMBase::GetName( aSelectedObject );
+ GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX );
TopoDS_Shape aShape;
- if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull() ) {
- 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 = 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 = "";
- }
- }
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+ myEditCurrentArgument->setText( aName );
+ myPoint = aSelectedObject;
}
- myEditCurrentArgument->setText( aName );
- myPoint = aSelectedObject;
-
displayPreview();
}
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void PrimitiveGUI_SphereDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if ( send == GroupPoints->LineEdit1 ) {
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
-}
-
-
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
bool PrimitiveGUI_SphereDlg::isValid( QString& msg )
{
- bool ok = true;
+ bool ok = false;
if( getConstructorId() == 0 )
- ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && myPoint;
else if( getConstructorId() == 1 )
- ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- return getConstructorId() == 0 ? !myPoint->_is_nil() && ok : ok;
+ ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() );
+ return ok;
}
//=================================================================================
switch ( getConstructorId() ) {
case 0 :
{
- if ( !CORBA::is_nil( myPoint ) ) {
- anObj = anOper->MakeSpherePntR( myPoint, getRadius() );
+ if ( myPoint ) {
+ anObj = anOper->MakeSpherePntR( myPoint.get(), getRadius() );
if (!anObj->_is_nil() && !IsPreview())
{
QStringList aParameters;
//=================================================================================
void PrimitiveGUI_SphereDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
- switch ( getConstructorId() ) {
- case 0:
- objMap[GroupPoints->LineEdit1->text()] = myPoint;
- break;
- case 1:
- return;
+ if ( getConstructorId() == 0 ) {
+ GEOMBase::PublishSubObject( myPoint.get() );
}
- addSubshapesToFather( objMap );
}
#ifndef PRIMITIVEGUI_SPHEREDLG_H
#define PRIMITIVEGUI_SPHEREDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel1Spin;
class DlgRef_1Spin;
double getRadius() const;
private:
- GEOM::GEOM_Object_var myPoint; /* Center point */
+ GEOM::GeomObjPtr myPoint; /* Center point */
DlgRef_1Sel1Spin* GroupPoints;
DlgRef_1Spin* GroupDimensions;
bool ClickOnApply();
void ActivateThisDialog();
void DeactivateActiveDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ConstructorsClicked( int );
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
- myPoint = myDir = GEOM::GEOM_Object::_nil();
+ myPoint.nullify();
+ myDir.nullify();
GroupPoints->SpinBox_DX->setValue(300.0);
GroupPoints->SpinBox_DY->setValue(100.0);
connect(GroupPoints->PushButton1, 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_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
erasePreview();
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();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
- if (aSelList.Extent() != 1)
- return;
-
- // nbSel == 1
- GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
-
- if ( CORBA::is_nil(aSelectedObject) )
+ if (aSelList.Extent() != 1) {
+ if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint.nullify();
+ else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir.nullify();
return;
+ }
- QString aName = GEOMBase::GetName(aSelectedObject);
-
- // Get Selected object if selected subshape
+ TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupPoints->LineEdit2 ? TopAbs_EDGE : TopAbs_VERTEX;
+ GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
TopoDS_Shape aShape;
- if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
- {
- 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
- }
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+
+ myEditCurrentArgument->setText(aName);
+
+ // clear selection
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+ myGeomGUI->getApp()->selectionMgr()->clearSelected();
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
+
+ if (myEditCurrentArgument == GroupPoints->LineEdit1) {
+ myPoint = aSelectedObject;
+ if (myPoint && !myDir)
+ GroupPoints->PushButton2->click();
}
- else { // Global Selection
- if (aShape.ShapeType() != aNeedType) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- }
+ else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
+ myDir = aSelectedObject;
+ if (myDir && !myPoint)
+ GroupPoints->PushButton1->click();
}
}
- myEditCurrentArgument->setText(aName);
-
- // clear selection
- disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- myGeomGUI->getApp()->selectionMgr()->clearSelected();
- connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
- this, SLOT(SelectionIntoArgument()));
-
- if (myEditCurrentArgument == GroupPoints->LineEdit1) {
- myPoint = aSelectedObject;
- if (!myPoint->_is_nil() && myDir->_is_nil())
- GroupPoints->PushButton2->click();
- }
- else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
- myDir = aSelectedObject;
- if (!myDir->_is_nil() && myPoint->_is_nil())
- GroupPoints->PushButton1->click();
- }
-
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()
// purpose :
//=================================================================================
bool PrimitiveGUI_TorusDlg::isValid (QString& msg)
{
- bool ok = true;
+ bool ok = false;
if( getConstructorId() == 0 )
{
- ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
+ myPoint && myDir;
}
else if( getConstructorId() == 1 )
{
- ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() );
}
- return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) && ok : ok;
+ return ok;
}
//=================================================================================
switch (getConstructorId()) {
case 0:
- if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) {
- anObj = anOper->MakeTorusPntVecRR(myPoint, myDir, getRadius1(), getRadius2());
+ if ( myPoint && myDir ) {
+ anObj = anOper->MakeTorusPntVecRR(myPoint.get(), myDir.get(), getRadius1(), getRadius2());
if (!anObj->_is_nil() && !IsPreview())
{
QStringList aParameters;
//=================================================================================
void PrimitiveGUI_TorusDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
- switch (getConstructorId()) {
- case 0:
- objMap[GroupPoints->LineEdit1->text()] = myPoint;
- objMap[GroupPoints->LineEdit2->text()] = myDir;
- break;
- case 1:
- return;
+ if ( getConstructorId() == 0 ) {
+ GEOMBase::PublishSubObject( myPoint.get() );
+ GEOMBase::PublishSubObject( myDir.get() );
}
- addSubshapesToFather(objMap);
}
#ifndef PRIMITIVEGUI_TORUSDLG_H
#define PRIMITIVEGUI_TORUSDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel2Spin;
class DlgRef_2Spin;
double getRadius2() const;
private:
- GEOM::GEOM_Object_var myPoint, myDir;
+ GEOM::GeomObjPtr myPoint, myDir;
DlgRef_2Sel2Spin* GroupPoints;
DlgRef_2Spin* GroupDimensions;
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ConstructorsClicked( int );