// Activate Create a Copy mode
GroupPoints->CheckButton1->setChecked(true);
- CreateCopyModeChanged(true);
+ CreateCopyModeChanged();
Init();
}
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
- myArgument = GEOM::GEOM_Object::_nil();
+ myObjects.clear();
+ myArgument.nullify();
mainFrame()->GroupBoxPublish->show();
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->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
+ connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged()));
initName(tr("GEOM_MIRROR"));
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
GroupPoints->LineEdit2->clear();
- myArgument = GEOM::GEOM_Object::_nil();
+ myArgument.nullify();
switch (constructorId) {
case 0: // mirror an object by point
initName();
- myObjects.length(0);
+ myObjects.clear();
myEditCurrentArgument = GroupPoints->LineEdit1;
myEditCurrentArgument->setText("");
myGeomGUI->getApp()->selectionMgr()->clearSelected();
void TransformationGUI_MirrorDlg::SelectionIntoArgument()
{
erasePreview();
- myEditCurrentArgument->setText("");
-
- if (myEditCurrentArgument == GroupPoints->LineEdit1)
- myObjects.length(0);
- else if (myEditCurrentArgument == GroupPoints->LineEdit2)
- myArgument = GEOM::GEOM_Object::_nil();
-
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
-
- QString aName;
- if (myEditCurrentArgument == GroupPoints->LineEdit1) {
- int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
- if (aNbSel < 1)
- return;
-
- GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
- if (!myObjects.length())
- return;
- else
- myEditCurrentArgument->setText(aName);
+ if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
+ myObjects = getSelected( TopAbs_SHAPE, -1 );
+ if ( !myObjects.isEmpty() ) {
+ QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
+ myEditCurrentArgument->setText( aName );
+ }
+ else {
+ myEditCurrentArgument->setText("");
+ }
}
- else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
- if (aSelList.Extent() != 1)
- return;
-
- // nbSel == 1
- myArgument = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
- if ( CORBA::is_nil(myArgument) )
- return;
-
- aName = GEOMBase::GetName(myArgument);
-
+ else {
+ TopAbs_ShapeEnum aNeedType = ( getConstructorId() == 1 ) ?
+ TopAbs_EDGE : ( ( getConstructorId() == 2 ) ? TopAbs_FACE : TopAbs_VERTEX );
+ GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
TopoDS_Shape aShape;
- if (GEOMBase::GetShape(myArgument, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
- TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
- if (getConstructorId() == 1)
- aNeedType = TopAbs_EDGE;
- else if (getConstructorId() == 2)
- aNeedType = TopAbs_FACE;
-
- TColStd_IndexedMapOfInteger aMap;
- aSelMgr->GetIndexes(aSelList.First(), aMap);
- if (aMap.Extent() == 1) {
- int anIndex = aMap(1);
- if (aNeedType == 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 = findObjectInFather(myArgument, aName);
-
- if (aFindedObject->_is_nil()) { // Object not found in study
- GEOM::GEOM_IShapesOperations_var aShapesOp =
- getGeomEngine()->GetIShapesOperations(getStudyId());
- myArgument = aShapesOp->GetSubShape(myArgument, anIndex);
- }
- else {
- myArgument = aFindedObject; // get Object from study
- }
- }
- else {
- if (aShape.ShapeType() != aNeedType) {
- myArgument = GEOM::GEOM_Object::_nil();
- aName = "";
- }
- }
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+ myEditCurrentArgument->setText( aName );
+ myArgument = aSelectedObject;
+ if ( myObjects.isEmpty() )
+ GroupPoints->PushButton1->click();
+ }
+ else {
+ if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
+ myArgument.nullify();
+ myEditCurrentArgument->setText("");
}
- myEditCurrentArgument->setText(aName);
-
- if (!myArgument->_is_nil() && !myObjects.length())
- GroupPoints->PushButton1->click();
}
- // clear selection
- /* disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- myGeomGUI->getApp()->selectionMgr()->clearSelected();
- connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
- this, SLOT(SelectionIntoArgument()));*/
- // here commented, because multiple objects can be selected IPAL 21437
-
displayPreview();
}
break;
case 2:
globalSelection(GEOM_PLANE);
+ localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE);
break;
}
displayPreview();
}
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void TransformationGUI_MirrorDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if (send == GroupPoints->LineEdit1 ||
- send == GroupPoints->LineEdit2) {
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
-}
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
bool TransformationGUI_MirrorDlg::isValid (QString& /*msg*/)
{
- return !(myObjects.length() == 0 || myArgument->_is_nil());
+ return !myObjects.isEmpty() && myArgument;
}
//=================================================================================
case 0:
{
if (toCreateCopy) {
- for (int i = 0; i < myObjects.length(); i++) {
- anObj = anOper->MirrorPointCopy(myObjects[i], myArgument);
+ for (int i = 0; i < myObjects.count(); i++) {
+ anObj = anOper->MirrorPointCopy(myObjects[i].get(), myArgument.get());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
}
else {
- for (int i = 0; i < myObjects.length(); i++) {
- anObj = anOper->MirrorPoint(myObjects[i], myArgument);
+ for (int i = 0; i < myObjects.count(); i++) {
+ anObj = anOper->MirrorPoint(myObjects[i].get(), myArgument.get());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
case 1:
{
if (toCreateCopy) {
- for (int i = 0; i < myObjects.length(); i++) {
- anObj = anOper->MirrorAxisCopy(myObjects[i], myArgument);
+ for (int i = 0; i < myObjects.count(); i++) {
+ anObj = anOper->MirrorAxisCopy(myObjects[i].get(), myArgument.get());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
}
else {
- for (int i = 0; i < myObjects.length(); i++) {
- anObj = anOper->MirrorAxis(myObjects[i], myArgument);
+ for (int i = 0; i < myObjects.count(); i++) {
+ anObj = anOper->MirrorAxis(myObjects[i].get(), myArgument.get());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
case 2:
{
if (toCreateCopy) {
- for (int i = 0; i < myObjects.length(); i++) {
- anObj = anOper->MirrorPlaneCopy(myObjects[i], myArgument);
+ for (int i = 0; i < myObjects.count(); i++) {
+ anObj = anOper->MirrorPlaneCopy(myObjects[i].get(), myArgument.get());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
}
else {
- for (int i = 0; i < myObjects.length(); i++) {
- anObj = anOper->MirrorPlane(myObjects[i], myArgument);
+ for (int i = 0; i < myObjects.count(); i++) {
+ anObj = anOper->MirrorPlane(myObjects[i].get(), myArgument.get());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
// function : CreateCopyModeChanged()
// purpose :
//=================================================================================
-void TransformationGUI_MirrorDlg::CreateCopyModeChanged (bool isCreateCopy)
+void TransformationGUI_MirrorDlg::CreateCopyModeChanged()
{
- mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
+ mainFrame()->GroupBoxName->setEnabled(GroupPoints->CheckButton1->isChecked());
}
//=================================================================================
{
bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
if (toCreateCopy) {
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
switch (getConstructorId()) {
case 0:
- objMap[GroupPoints->LineEdit2->text()] = myArgument;
- break;
case 1:
- objMap[GroupPoints->LineEdit2->text()] = myArgument;
- break;
case 2:
- return;
- }
- addSubshapesToFather(objMap);
+ GEOMBase::PublishSubObject( myArgument.get() );
+ break;
+ default:
+ break;
}
+ }
}
#ifndef TRANSFORMATIONGUI_MIRRORDLG_H
#define TRANSFORMATIONGUI_MIRRORDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel1Spin2Check;
void enterEvent( QEvent* );
private:
- GEOM::GEOM_Object_var myArgument;
- GEOM::ListOfGO myObjects;
+ GEOM::GeomObjPtr myArgument;
+ QList<GEOM::GeomObjPtr> myObjects;
// 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 );
- void CreateCopyModeChanged( bool );
+ void CreateCopyModeChanged();
};
#endif // TRANSFORMATIONGUI_MIRRORDLG_H
int SpecificStep1 = 5;
int SpecificStep2 = 1;
+ // init variables
+ myAng = 45.0;
+ myStep = 50.0;
+ myNbTimes1 = myNbTimes2 = 2;
+
// min, max, step and decimals for spin boxes & initial values
initSpinBox(GroupPoints->SpinBox_DX, 1, 999, SpecificStep2);
GroupPoints->SpinBox_DX->setValue(myNbTimes1);
GroupDimensions->SpinBox_DX2->setValue(myStep);
GroupDimensions->SpinBox_DY2->setValue(myNbTimes2);
- // init variables
- myAng = 45.0;
- myStep = 50.0;
- myNbTimes1 = myNbTimes2 = 2;
-
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
GroupDimensions->LineEdit1->setText("");
GroupDimensions->LineEdit2->setText("");
- myBase = myVector = GEOM::GEOM_Object::_nil();
+ myBase.nullify();
+ myVector.nullify();
mainFrame()->GroupBoxPublish->show();
connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupDimensions->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- connect(GroupDimensions->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- connect(GroupDimensions->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-
connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
connect(GroupDimensions->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(GroupDimensions->SpinBox_DY1, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
- myBase = myVector = GEOM::GEOM_Object::_nil();
+ myBase.nullify();
+ myVector.nullify();
GroupPoints->SpinBox_DX->setValue(myNbTimes1);
GroupDimensions->LineEdit1->setText("");
GroupDimensions->LineEdit2->setText("");
- myBase = myVector = GEOM::GEOM_Object::_nil();
+ myBase.nullify();
+ myVector.nullify();
GroupDimensions->SpinBox_DX1->setValue(myAng);
GroupDimensions->SpinBox_DY1->setValue(myNbTimes1);
void TransformationGUI_MultiRotationDlg::SelectionIntoArgument()
{
erasePreview();
- myEditCurrentArgument->setText("");
-
- if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
- myEditCurrentArgument == GroupDimensions->LineEdit1)
- myBase = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
- myEditCurrentArgument == GroupDimensions->LineEdit2)
- myVector = 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 ( !GEOMBase::IsShape(aSelectedObject) )
- return;
-
- QString aName = GEOMBase::GetName(aSelectedObject);
-
- if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
- myEditCurrentArgument == GroupDimensions->LineEdit1)
- myBase = aSelectedObject;
- else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
- myEditCurrentArgument == GroupDimensions->LineEdit2) {
- 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 += QString(":edge_%1").arg(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());
- myVector = aShapesOp->GetSubShape(aSelectedObject, anIndex);
- }
- else {
- myVector = aFindedObject; // get existing object
- }
- }
- else {
- if (aShape.ShapeType() != TopAbs_EDGE) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- }
- myVector = aSelectedObject;
- }
- }
- }
- myEditCurrentArgument->setText(aName);
- if (myEditCurrentArgument == GroupPoints->LineEdit1) {
- if (!myBase->_is_nil() && myVector->_is_nil())
- GroupPoints->PushButton2->click();
- }
- else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
- if (!myVector->_is_nil() && myBase->_is_nil())
- GroupPoints->PushButton1->click();
- }
- else if (myEditCurrentArgument == GroupDimensions->LineEdit1) {
- if (!myBase->_is_nil() && myVector->_is_nil())
- GroupDimensions->PushButton2->click();
+ TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
+ myEditCurrentArgument == GroupDimensions->LineEdit2 ) ?
+ TopAbs_EDGE : TopAbs_SHAPE;
+ 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 == GroupPoints->LineEdit1 ) {
+ myBase = aSelectedObject;
+ if ( !myVector )
+ GroupPoints->PushButton2->click();
+ }
+ else if ( myEditCurrentArgument == GroupPoints->LineEdit2) {
+ myVector = aSelectedObject;
+ if ( !myBase )
+ GroupPoints->PushButton1->click();
+ }
+ else if ( myEditCurrentArgument == GroupDimensions->LineEdit1 ) {
+ myBase = aSelectedObject;
+ if ( !myVector )
+ GroupDimensions->PushButton2->click();
+ }
+ else if ( myEditCurrentArgument == GroupDimensions->LineEdit2 ) {
+ myVector = aSelectedObject;
+ if ( !myBase )
+ GroupDimensions->PushButton1->click();
+ }
+
+ // clear selection
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+ myGeomGUI->getApp()->selectionMgr()->clearSelected();
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
}
- else if (myEditCurrentArgument == GroupDimensions->LineEdit2) {
- if (!myVector->_is_nil() && myBase->_is_nil())
- GroupDimensions->PushButton1->click();
+ else {
+ if ( myEditCurrentArgument == GroupPoints->LineEdit1 ||
+ myEditCurrentArgument == GroupDimensions->LineEdit1 )
+ myBase.nullify();
+ else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
+ myEditCurrentArgument == GroupDimensions->LineEdit2 )
+ myVector.nullify();
+ myEditCurrentArgument->setText("");
}
- // clear selection
- disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- myGeomGUI->getApp()->selectionMgr()->clearSelected();
- connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
- this, SLOT(SelectionIntoArgument()));
-
displayPreview();
}
displayPreview();
}
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void TransformationGUI_MultiRotationDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if (send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 ||
- send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2) {
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
-}
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
bool TransformationGUI_MultiRotationDlg::isValid (QString& msg)
{
- bool ok = true;
+ bool ok = false;
switch(getConstructorId()){
case 0:
- ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && myBase && myVector;
break;
case 1:
- ok = GroupDimensions->SpinBox_DX1->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DY1->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DX2->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DY2->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupDimensions->SpinBox_DX1->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DY1->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DX2->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DY2->isValid( msg, !IsPreview() ) &&
+ myBase && myVector;
+ break;
+ default:
break;
}
- return !(myBase->_is_nil() || myVector->_is_nil()) && ok;
+ return ok;
}
//=================================================================================
switch (getConstructorId()) {
case 0:
- if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVector)) {
- anObj = anOper->MultiRotate1D(myBase, myVector, myNbTimes1);
+ if ( myBase && myVector ) {
+ anObj = anOper->MultiRotate1D(myBase.get(), myVector.get(), myNbTimes1);
if(!IsPreview())
aParameters<<GroupPoints->SpinBox_DX->text();
res = true;
}
break;
case 1:
- if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVector)) {
- anObj = anOper->MultiRotate2D(myBase, myVector, myAng, myNbTimes1, myStep, myNbTimes2);
+ if ( myBase && myVector ) {
+ anObj = anOper->MultiRotate2D(myBase.get(), myVector.get(), myAng, myNbTimes1, myStep, myNbTimes2);
if(!IsPreview()) {
aParameters<<GroupDimensions->SpinBox_DX1->text();
aParameters<<GroupDimensions->SpinBox_DY1->text();
//=================================================================================
void TransformationGUI_MultiRotationDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
switch (getConstructorId()) {
case 0:
- objMap[GroupPoints->LineEdit2->text()] = myVector;
- break;
case 1:
- objMap[GroupDimensions->LineEdit2->text()] = myVector;
+ GEOMBase::PublishSubObject( myVector.get() );
+ break;
+ default:
break;
}
- addSubshapesToFather(objMap);
}
//=================================================================================
// and we need to point the first argument directly
GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
anArgs->length(1);
- anArgs[0] = myBase;
+ anArgs[0] = myBase.copy();
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
/*theFindMethod=*/GEOM::FSM_MultiTransformed,
/*theInheritFirstArg=*/true,
#ifndef TRANSFORMATIONGUI_MULTIROTATIONDLG_H
#define TRANSFORMATIONGUI_MULTIROTATIONDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel4Spin1Check;
class DlgRef_2Sel1SpinInt;
void enterEvent( QEvent* );
private:
- GEOM::GEOM_Object_var myBase, myVector;
+ GEOM::GeomObjPtr myBase, myVector;
int myNbTimes1;
int myNbTimes2;
Standard_Real myAng;
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ReverseAngle();
double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
int SpecificStep = 1;
+ // init variables
+ myStepU = myStepV = 50.0;
+ myNbTimesU = myNbTimesV = 2;
+
// min, max, step and decimals for spin boxes & initial values
initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
initSpinBox(GroupPoints->SpinBox_DY, 1, 999, SpecificStep);
GroupDimensions->SpinBox_DX2->setValue(myStepV);
GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
- // init variables
- myStepU = myStepV = 50.0;
- myNbTimesU = myNbTimesV = 2;
-
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
GroupDimensions->LineEdit2->setText("");
GroupDimensions->LineEdit3->setText("");
- myBase = myVectorU = myVectorV = GEOM::GEOM_Object::_nil();
+ myBase.nullify();
+ myVectorU.nullify();
+ myVectorV.nullify();
mainFrame()->GroupBoxPublish->show();
connect(GroupDimensions->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupDimensions->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- connect(GroupDimensions->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- connect(GroupDimensions->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- connect(GroupDimensions->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-
connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
connect(GroupDimensions->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
- myBase = myVectorU = GEOM::GEOM_Object::_nil();
+ myBase.nullify();
+ myVectorU.nullify();
GroupPoints->SpinBox_DX->setValue(myStepU);
GroupPoints->SpinBox_DY->setValue(myNbTimesU);
GroupDimensions->LineEdit1->setText("");
GroupDimensions->LineEdit2->setText("");
GroupDimensions->LineEdit3->setText("");
- myBase = myVectorU = myVectorV = GEOM::GEOM_Object::_nil();
+ myBase.nullify();
+ myVectorU.nullify();
+ myVectorV.nullify();
GroupDimensions->SpinBox_DX1->setValue(myStepU);
GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument()
{
erasePreview();
- myEditCurrentArgument->setText("");
-
- if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
- myEditCurrentArgument == GroupDimensions->LineEdit1)
- myBase = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
- myEditCurrentArgument == GroupDimensions->LineEdit2)
- myVectorU = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupDimensions->LineEdit3)
- myVectorV = 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 ( !GEOMBase::IsShape(aSelectedObject) )
- return;
-
- QString aName = GEOMBase::GetName(aSelectedObject);
-
- if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
- myEditCurrentArgument == GroupDimensions->LineEdit1)
- myBase = aSelectedObject;
- else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
- myEditCurrentArgument == GroupDimensions->LineEdit2 ||
- myEditCurrentArgument == GroupDimensions->LineEdit3) {
- 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 += QString(":edge_%1").arg(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());
- if (myEditCurrentArgument == GroupDimensions->LineEdit3)
- myVectorV = aShapesOp->GetSubShape(aSelectedObject, anIndex);
- else
- myVectorU = aShapesOp->GetSubShape(aSelectedObject, anIndex);
- }
- else {
- if (myEditCurrentArgument == GroupDimensions->LineEdit3)
- myVectorV = aFindedObject;
- else
- myVectorU = aFindedObject;
- }
- }
- else {
- if (aShape.ShapeType() != TopAbs_EDGE) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- }
- if (myEditCurrentArgument == GroupDimensions->LineEdit3)
- myVectorV = aSelectedObject;
- else
- myVectorU = aSelectedObject;
- }
+ TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
+ myEditCurrentArgument == GroupDimensions->LineEdit2 ||
+ myEditCurrentArgument == GroupDimensions->LineEdit3 ) ?
+ TopAbs_EDGE : TopAbs_SHAPE;
+ 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 == GroupPoints->LineEdit1 ) {
+ myBase = aSelectedObject;
+ if ( !myVectorU )
+ GroupPoints->PushButton2->click();
+ }
+ else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
+ myVectorU = aSelectedObject;
+ if ( !myBase )
+ GroupPoints->PushButton1->click();
+ }
+ else if ( myEditCurrentArgument == GroupDimensions->LineEdit1 ) {
+ myBase = aSelectedObject;
+ if ( !myVectorU )
+ GroupDimensions->PushButton2->click();
+ else if ( !myVectorV )
+ GroupDimensions->PushButton3->click();
+ }
+ else if ( myEditCurrentArgument == GroupDimensions->LineEdit2 ) {
+ myVectorU = aSelectedObject;
+ if ( !myVectorV )
+ GroupDimensions->PushButton3->click();
+ else if ( !myBase )
+ GroupDimensions->PushButton1->click();
+ }
+ else if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) {
+ myVectorV = aSelectedObject;
+ if ( !myBase )
+ GroupDimensions->PushButton1->click();
+ else if ( !myVectorU )
+ GroupDimensions->PushButton2->click();
}
- }
- myEditCurrentArgument->setText(aName);
- if (myEditCurrentArgument == GroupPoints->LineEdit1) {
- if (!myBase->_is_nil() && myVectorU->_is_nil())
- GroupPoints->PushButton2->click();
+ // clear selection
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+ myGeomGUI->getApp()->selectionMgr()->clearSelected();
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
}
- else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
- if (!myVectorU->_is_nil() && myBase->_is_nil())
- GroupPoints->PushButton1->click();
- }
- else if (myEditCurrentArgument == GroupDimensions->LineEdit1) {
- if (!myBase->_is_nil() && myVectorU->_is_nil())
- GroupDimensions->PushButton2->click();
- }
- else if (myEditCurrentArgument == GroupDimensions->LineEdit2) {
- if (!myVectorU->_is_nil() && myVectorV->_is_nil())
- GroupDimensions->PushButton3->click();
- }
- else if (myEditCurrentArgument == GroupDimensions->LineEdit3) {
- if (!myVectorV->_is_nil() && myBase->_is_nil())
- GroupDimensions->PushButton1->click();
+ else {
+ if ( myEditCurrentArgument == GroupPoints->LineEdit1 ||
+ myEditCurrentArgument == GroupDimensions->LineEdit1 )
+ myBase.nullify();
+ else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
+ myEditCurrentArgument == GroupDimensions->LineEdit2 )
+ myVectorU.nullify();
+ else if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
+ myVectorV.nullify();
+ myEditCurrentArgument->setText("");
}
- // clear selection
- disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- myGeomGUI->getApp()->selectionMgr()->clearSelected();
- connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
- this, SLOT(SelectionIntoArgument()));
-
displayPreview();
}
displayPreview();
}
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void TransformationGUI_MultiTranslationDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if (send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 ||
- send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2 ||
- send == GroupDimensions->LineEdit3) {
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
-}
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
bool TransformationGUI_MultiTranslationDlg::isValid (QString& msg)
{
- int aConstructorId = getConstructorId();
-
- if (aConstructorId == 0) {
- bool ok = true;
- ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
- return !(myBase->_is_nil() || myVectorU->_is_nil()) && ok;
- }
- else if (aConstructorId == 1) {
- bool ok = true;
- ok = GroupDimensions->SpinBox_DX1->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DY1->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DX2->isValid( msg, !IsPreview() ) && ok;
- ok = GroupDimensions->SpinBox_DY2->isValid( msg, !IsPreview() ) && ok;
- return !(myBase->_is_nil() || myVectorU->_is_nil() || myVectorV->_is_nil()) && ok;
+ bool ok = false;
+ switch ( getConstructorId() ) {
+ case 0:
+ ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
+ GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
+ myBase && myVectorU;
+ break;
+ case 1:
+ ok = GroupDimensions->SpinBox_DX1->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DY1->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DX2->isValid( msg, !IsPreview() ) &&
+ GroupDimensions->SpinBox_DY2->isValid( msg, !IsPreview() ) &&
+ myBase && myVectorU && myVectorV;
+ break;
+ default:
+ break;
}
- return 0;
+ return ok;
}
//=================================================================================
switch (getConstructorId()) {
case 0:
- if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU)) {
- createPathPreview ( myVectorU );
- anObj = anOper->MultiTranslate1D(myBase, myVectorU, myStepU, myNbTimesU);
+ if ( myBase && myVectorU ) {
+ createPathPreview ( myVectorU.get() );
+ anObj = anOper->MultiTranslate1D(myBase.get(), myVectorU.get(), myStepU, myNbTimesU);
if(!IsPreview()) {
aParameters<<GroupPoints->SpinBox_DX->text();
aParameters<<GroupPoints->SpinBox_DY->text();
}
break;
case 1:
- if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU) &&
- !CORBA::is_nil(myVectorV)) {
- createPathPreview ( myVectorU );
- createPathPreview ( myVectorV );
- anObj = anOper->MultiTranslate2D(myBase,
- myVectorU, myStepU, myNbTimesU,
- myVectorV, myStepV, myNbTimesV);
+ if ( myBase && myVectorU && myVectorV ) {
+ createPathPreview ( myVectorU.get() );
+ createPathPreview ( myVectorV.get() );
+ anObj = anOper->MultiTranslate2D(myBase.get(),
+ myVectorU.get(), myStepU, myNbTimesU,
+ myVectorV.get(), myStepV, myNbTimesV);
if(!IsPreview()) {
aParameters<<GroupDimensions->SpinBox_DX1->text();
aParameters<<GroupDimensions->SpinBox_DY1->text();
//=================================================================================
void TransformationGUI_MultiTranslationDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
switch (getConstructorId()) {
case 0:
- objMap[GroupPoints->LineEdit2->text()] = myVectorU;
+ GEOMBase::PublishSubObject( myVectorU.get() );
break;
case 1:
- objMap[GroupDimensions->LineEdit2->text()] = myVectorU;
- objMap[GroupDimensions->LineEdit3->text()] = myVectorV;
+ GEOMBase::PublishSubObject( myVectorU.get() );
+ GEOMBase::PublishSubObject( myVectorV.get() );
+ break;
+ default:
break;
}
- addSubshapesToFather(objMap);
}
//=================================================================================
// and we need to point the first argument directly
GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
anArgs->length(1);
- anArgs[0] = myBase;
+ anArgs[0] = myBase.copy();
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
/*theFindMethod=*/GEOM::FSM_MultiTransformed,
/*theInheritFirstArg=*/true,
// function : createPathPreview
// purpose :
//=================================================================================
-void TransformationGUI_MultiTranslationDlg::createPathPreview ( GEOM::GEOM_Object_var thePath )
+void TransformationGUI_MultiTranslationDlg::createPathPreview ( GEOM::GEOM_Object_ptr thePath )
{
if ( IsPreview() ) {
TopoDS_Shape aShape;
#ifndef TRANSFORMATIONGUI_MULTITRANSLATIONDLG_H
#define TRANSFORMATIONGUI_MULTITRANSLATIONDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_2Sel2Spin1Check;
class DlgRef_3Sel4Spin2Check;
private:
void Init();
void enterEvent( QEvent* );
- void createPathPreview( GEOM::GEOM_Object_var );
+ void createPathPreview( GEOM::GEOM_Object_ptr );
private:
- GEOM::GEOM_Object_var myBase, myVectorU, myVectorV;
+ GEOM::GeomObjPtr myBase, myVectorU, myVectorV;
int myNbTimesU;
int myNbTimesV;
Standard_Real myStepU;
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
- void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ReverseStepU();
/* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setReadOnly( true );
+
+ myObjects.clear();
/* Get setting of step value from file configuration */
double step = 1;
// Activate Create a Copy mode
GroupPoints->CheckButton1->setChecked( true );
- CreateCopyModeChanged( true );
+ CreateCopyModeChanged();
mainFrame()->GroupBoxPublish->show();
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
- connect( GroupPoints->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( CreateCopyModeChanged( bool ) ) );
+ connect( GroupPoints->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( CreateCopyModeChanged() ) );
initName( tr( "GEOM_OFFSET" ) );
//=================================================================================
void TransformationGUI_OffsetDlg::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 ) {
- myObjects.length( 0 );
- return;
+ myObjects = getSelected( TopAbs_SHAPE, -1 );
+ if ( !myObjects.isEmpty() ) {
+ QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
+ myEditCurrentArgument->setText( aName );
+ }
+ else {
+ myEditCurrentArgument->setText("");
}
-
- // nbSel > 0
- GEOMBase::ConvertListOfIOInListOfGO (aSelList, myObjects);
- if (!myObjects.length())
- return;
-
- myEditCurrentArgument->setText(aName);
displayPreview();
}
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void TransformationGUI_OffsetDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if ( send == GroupPoints->LineEdit1 ) {
- myEditCurrentArgument = GroupPoints->LineEdit1;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
-}
-
-
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
bool TransformationGUI_OffsetDlg::isValid( QString& msg )
{
- //return !(myObjects.length() == 0);
- if ( myObjects.length() == 0 ) return false;
-
- for ( int i = 0; i < myObjects.length(); i++ ) {
+ bool ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && !myObjects.isEmpty();
+ for ( int i = 0; i < myObjects.count() && ok; i++ ) {
GEOM::shape_type aType = myObjects[i]->GetShapeType();
- if ( aType != GEOM::FACE && aType != GEOM::SHELL && aType != GEOM::SOLID ) {
+ ok = aType == GEOM::FACE || aType == GEOM::SHELL || aType == GEOM::SOLID;
+ if ( !ok )
msg = tr( "ERROR_SHAPE_TYPE" );
- return false;
- }
}
- return GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() );
+ return ok;
}
//=================================================================================
GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation());
if ( GroupPoints->CheckButton1->isChecked() || IsPreview() ) {
- for ( int i = 0; i < myObjects.length(); i++ ) {
+ for ( int i = 0; i < myObjects.count(); i++ ) {
- anObj = anOper->OffsetShapeCopy( myObjects[i], GetOffset() );
+ anObj = anOper->OffsetShapeCopy( myObjects[i].get(), GetOffset() );
if ( !anObj->_is_nil() ) {
if(!IsPreview()) {
anObj->SetParameters(GroupPoints->SpinBox_DX->text().toLatin1().constData());
}
}
else {
- for ( int i = 0; i < myObjects.length(); i++ ) {
- anObj = anOper->OffsetShape( myObjects[i], GetOffset() );
+ for ( int i = 0; i < myObjects.count(); i++ ) {
+ anObj = anOper->OffsetShape( myObjects[i].get(), GetOffset() );
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
}
// function : CreateCopyModeChanged()
// purpose :
//=================================================================================
-void TransformationGUI_OffsetDlg::CreateCopyModeChanged( bool isCreateCopy )
+void TransformationGUI_OffsetDlg::CreateCopyModeChanged()
{
- mainFrame()->GroupBoxName->setEnabled( isCreateCopy );
+ mainFrame()->GroupBoxName->setEnabled( GroupPoints->CheckButton1->isChecked() );
}
#ifndef TRANSFORMATIONGUI_OFFSETDLG_H
#define TRANSFORMATIONGUI_OFFSETDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_1Sel1Spin1Check;
double GetOffset() const;
private:
- GEOM::ListOfGO myObjects;
+ QList<GEOM::GeomObjPtr> myObjects;
DlgRef_1Sel1Spin1Check* GroupPoints;
bool ClickOnApply();
void ActivateThisDialog();
void SelectionIntoArgument();
- void LineEditReturnPressed();
void SetEditCurrentArgument();
void ValueChangedInSpinBox();
- void CreateCopyModeChanged( bool );
+ void CreateCopyModeChanged();
};
#endif // TRANSFORMATIONGUI_OFFSETDLG_H
// Activate Create a Copy mode
Group1->CheckButton1->setChecked(true);
- CreateCopyModeChanged(true);
+ CreateCopyModeChanged();
Init();
}
Group1->CheckButton2->setEnabled(false);
- myStartLCS = myEndLCS = GEOM::GEOM_Object::_nil();
+ myObjects.clear();
+ myStartLCS.nullify();
+ myEndLCS.nullify();
+ myPath.nullify();
mainFrame()->GroupBoxPublish->show();
connect(Group1->PushButton4, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(Group1->PushButton5, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- connect(Group1->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- connect(Group1->LineEdit4, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- connect(Group1->LineEdit5, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-
- connect(Group1->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
+ connect(Group1->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged()));
connect(Group1->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(Group1->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(SelectionTypeButtonClicked()));
Group1->LineEdit2->clear();
Group1->LineEdit4->clear();
Group1->LineEdit5->clear();
- myStartLCS = GEOM::GEOM_Object::_nil();
- myEndLCS = GEOM::GEOM_Object::_nil();
- myPath = GEOM::GEOM_Object::_nil();
+ myStartLCS.nullify();
+ myEndLCS.nullify();
+ myPath.nullify();
switch (constructorId) {
case 0:
initName();
- myObjects.length(0);
+ myObjects.clear();
myEditCurrentArgument = Group1->LineEdit1;
myEditCurrentArgument->setText("");
myGeomGUI->getApp()->selectionMgr()->clearSelected();
erasePreview();
myEditCurrentArgument->setText("");
- if (myEditCurrentArgument == Group1->LineEdit1)
- myObjects.length(0);
- else if (myEditCurrentArgument == Group1->LineEdit2)
- myStartLCS = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == Group1->LineEdit4)
- myEndLCS = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == Group1->LineEdit5)
- myPath = GEOM::GEOM_Object::_nil();
-
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
-
- QString aName;
-
- if (myEditCurrentArgument == Group1->LineEdit1) {
- int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
- if (aNbSel < 1)
- return;
-
- GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
- if (!myObjects.length())
- return;
- else
- myEditCurrentArgument->setText(aName);
-
- /* if (getConstructorId() == 2)
- Group1->PushButton5->click();*/
- }
- else if (myEditCurrentArgument == Group1->LineEdit2) {
- if (aSelList.Extent() != 1)
- return;
-
- // nbSel == 1
- myStartLCS = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
- if ( CORBA::is_nil(myStartLCS) )
- return;
-
- aName = GEOMBase::GetName(myStartLCS);
- myEditCurrentArgument->setText(aName);
-
- if (!myStartLCS->_is_nil() && myEndLCS->_is_nil())
- Group1->PushButton4->click();
+ if ( myEditCurrentArgument == Group1->LineEdit1 ) {
+ myObjects = getSelected( TopAbs_SHAPE, -1 );
+ if ( !myObjects.isEmpty() ) {
+ QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
+ myEditCurrentArgument->setText( aName );
+ }
}
- else if (myEditCurrentArgument == Group1->LineEdit4) {
- myEndLCS = GEOM::GEOM_Object::_nil();
- if (aSelList.Extent() != 1)
- return;
-
- myEndLCS = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
- if ( CORBA::is_nil(myEndLCS) )
- return;
-
- aName = GEOMBase::GetName(myEndLCS);
- myEditCurrentArgument->setText(aName);
-
- if (!myEndLCS->_is_nil() && !myObjects.length())
- Group1->PushButton1->click();
+ else if ( myEditCurrentArgument == Group1->LineEdit5 ) {
+ QList<TopAbs_ShapeEnum> types;
+ types << TopAbs_EDGE << TopAbs_WIRE;
+ GEOM::GeomObjPtr aSelectedObject = getSelected( types );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+ myEditCurrentArgument->setText( aName );
+ myPath = aSelectedObject;
+ if ( myObjects.isEmpty() )
+ Group1->PushButton1->click();
+ }
+ else {
+ myPath.nullify();
+ }
}
- else if (myEditCurrentArgument == Group1->LineEdit5) {
- myPath = GEOM::GEOM_Object::_nil();
- if (aSelList.Extent() != 1)
- return;
-
- GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
- if ( aSelectedObject->_is_nil() )
- return;
-
- aName = GEOMBase::GetName(myPath);
- // Local Selection
- TopoDS_Shape S;
- if (!GEOMBase::GetShape(aSelectedObject, S))
- return;
-
- TColStd_IndexedMapOfInteger aMap;
- aSelMgr->GetIndexes(aSelList.First(), aMap);
- aName = GEOMBase::GetName(aSelectedObject);
- 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 {
+ 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 );
+ if ( myEditCurrentArgument == Group1->LineEdit2 ) {
+ myStartLCS = aSelectedObject;
+ if ( !myEndLCS )
+ Group1->PushButton4->click();
+ else if ( myObjects.isEmpty() )
+ Group1->PushButton1->click();
}
- else { // get Object from study
- aSelectedObject = aFindedObject;
+ else if ( myEditCurrentArgument == Group1->LineEdit4 ) {
+ myEndLCS = aSelectedObject;
+ if ( myObjects.isEmpty() )
+ Group1->PushButton1->click();
+ else if ( getConstructorId() == 1 && !myStartLCS )
+ Group1->PushButton2->click();
}
}
else {
- if (S.ShapeType() != TopAbs_EDGE && S.ShapeType() != TopAbs_WIRE) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- return;
- }
+ if ( myEditCurrentArgument == Group1->LineEdit2 )
+ myStartLCS.nullify();
+ else if ( myEditCurrentArgument == Group1->LineEdit4 )
+ myEndLCS.nullify();
}
-
- myEditCurrentArgument->setText(aName);
- myPath = aSelectedObject;
-
- if (!myPath->_is_nil() && !myObjects.length())
- Group1->PushButton1->click();
}
- // clear selection
- /* disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- myGeomGUI->getApp()->selectionMgr()->clearSelected();
- connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
- this, SLOT(SelectionIntoArgument()));*/
- // here commented, because multiple objects can be selected IPAL 21437
-
displayPreview();
}
displayPreview();
}
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void TransformationGUI_PositionDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if (send == Group1->LineEdit1 ||
- send == Group1->LineEdit2 ||
- send == Group1->LineEdit4 ||
- send == Group1->LineEdit5 ) {
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
-
- if (send == Group1->LineEdit5)
- Group1->CheckButton2->setEnabled(true);
- else
- Group1->CheckButton2->setEnabled(false);
-}
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
bool TransformationGUI_PositionDlg::isValid (QString& /*msg*/)
{
- bool res;
- if (getConstructorId() == 0)
- res = !(myObjects.length() == 0 || myEndLCS->_is_nil());
- else if ( getConstructorId() == 1 )
- res = !(myObjects.length() == 0 || myStartLCS->_is_nil() || myEndLCS->_is_nil());
- else if ( getConstructorId() == 2 )
- res = !(myObjects.length() == 0 || myPath->_is_nil());
-
- return res;
+ bool ok = false;
+ switch (getConstructorId()) {
+ case 0:
+ ok = !myObjects.isEmpty() && myEndLCS;
+ break;
+ case 1:
+ ok = !myObjects.isEmpty() && myStartLCS && myEndLCS;
+ break;
+ case 2:
+ ok = !myObjects.isEmpty() && myPath;
+ break;
+ default:
+ break;
+ }
+ return ok;
}
//=================================================================================
switch (getConstructorId()) {
case 0:
{
- for (int i = 0; i < myObjects.length(); i++) {
+ for (int i = 0; i < myObjects.count(); i++) {
anObj = toCreateCopy ?
- anOper->PositionShapeCopy(myObjects[i], myObjects[i], myEndLCS) :
- anOper->PositionShape(myObjects[i], myObjects[i], myEndLCS);
+ anOper->PositionShapeCopy(myObjects[i].get(), myObjects[i].get(), myEndLCS.get()) :
+ anOper->PositionShape(myObjects[i].get(), myObjects[i].get(), myEndLCS.get());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
case 1:
{
- for (int i = 0; i < myObjects.length(); i++) {
+ for (int i = 0; i < myObjects.count(); i++) {
anObj = toCreateCopy ?
- anOper->PositionShapeCopy(myObjects[i], myStartLCS, myEndLCS) :
- anOper->PositionShape(myObjects[i], myStartLCS, myEndLCS);
+ anOper->PositionShapeCopy(myObjects[i].get(), myStartLCS.get(), myEndLCS.get()) :
+ anOper->PositionShape(myObjects[i].get(), myStartLCS.get(), myEndLCS.get());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
{
double aDistance = Group1->SpinBox_DX->value();
bool toReverse = Group1->CheckButton3->isChecked();
- for (int i = 0; i < myObjects.length(); i++) {
- anObj = anOper->PositionAlongPath(myObjects[i], myPath, aDistance, toCreateCopy, toReverse);
+ for (int i = 0; i < myObjects.count(); i++) {
+ anObj = anOper->PositionAlongPath(myObjects[i].get(), myPath.get(), aDistance, toCreateCopy, toReverse);
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
// function : CreateCopyModeChanged()
// purpose :
//=================================================================================
-void TransformationGUI_PositionDlg::CreateCopyModeChanged (bool isCreateCopy)
+void TransformationGUI_PositionDlg::CreateCopyModeChanged()
{
- mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
+ mainFrame()->GroupBoxName->setEnabled(Group1->CheckButton1->isChecked());
}
//=================================================================================
//=================================================================================
void TransformationGUI_PositionDlg::addSubshapesToStudy()
{
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
- objMap[Group1->LineEdit5->text()] = myPath;
-
- addSubshapesToFather(objMap);
+ if ( getConstructorId() == 2 )
+ GEOMBase::PublishSubObject( myPath.get() );
}
#ifndef TRANSFORMATIONGUI_POSITIONDLG_H
#define TRANSFORMATIONGUI_POSITIONDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_4Sel1Spin3Check;
void enterEvent( QEvent* );
private:
- GEOM::GEOM_Object_var myStartLCS;
- GEOM::GEOM_Object_var myEndLCS;
- GEOM::ListOfGO myObjects;
- GEOM::GEOM_Object_var myPath;
+ GEOM::GeomObjPtr myStartLCS;
+ GEOM::GeomObjPtr myEndLCS;
+ QList<GEOM::GeomObjPtr> myObjects;
+ GEOM::GeomObjPtr myPath;
// 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 );
- void CreateCopyModeChanged( bool );
+ void CreateCopyModeChanged();
void ValueChangedInSpinBox();
void SelectionTypeButtonClicked();
};
// Activate Create a Copy mode
GroupPoints->CheckButton1->setChecked(true);
- CreateCopyModeChanged(true);
+ CreateCopyModeChanged();
Init();
}
GroupPoints->LineEdit4->setText("");
GroupPoints->LineEdit5->setText("");
- myAxis = myCentPoint = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
+ myObjects.clear();
+ myAxis.nullify();
+ myCentPoint.nullify();
+ myPoint1.nullify();
+ myPoint2.nullify();
mainFrame()->GroupBoxPublish->show();
connect(GroupPoints->PushButton4, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton5, 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(textChanged( const QString& )),
this, SLOT(TextValueChangedInSpinBox( const QString&)));
- connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
+ connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged()));
connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse()));
initName(tr("GEOM_ROTATION"));
GroupPoints->LineEdit2->clear();
GroupPoints->ShowRows(4, 4, true);
- myAxis = GEOM::GEOM_Object::_nil();
+ myAxis.nullify();
GroupPoints->PushButton1->click();
}
GroupPoints->LineEdit4->clear();
GroupPoints->LineEdit5->clear();
- myCentPoint = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
+ myCentPoint.nullify();
+ myPoint1.nullify();
+ myPoint2.nullify();
GroupPoints->PushButton1->click();
}
initName();
- myObjects.length(0);
+ myObjects.clear();
myEditCurrentArgument = GroupPoints->LineEdit1;
myEditCurrentArgument->setText("");
myGeomGUI->getApp()->selectionMgr()->clearSelected();
void TransformationGUI_RotationDlg::SelectionIntoArgument()
{
erasePreview();
- myEditCurrentArgument->setText("");
- if (myEditCurrentArgument == GroupPoints->LineEdit1)
- myObjects.length(0);
- else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0)
- myAxis = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1)
- myCentPoint = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPoints->LineEdit4)
- myPoint1 = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPoints->LineEdit5)
- myPoint2 = GEOM::GEOM_Object::_nil();
-
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
- GEOM::GEOM_Object_var aSelectedObject;
-
- QString aName;
-
- if (myEditCurrentArgument == GroupPoints->LineEdit1) {
- int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
- if (aNbSel < 1)
- return;
-
- GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
- if (!myObjects.length())
- return;
+ if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
+ myObjects = getSelected( TopAbs_SHAPE, -1 );
+ if ( !myObjects.isEmpty() ) {
+ QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
+ myEditCurrentArgument->setText( aName );
+ }
+ else {
+ myEditCurrentArgument->setText("");
+ }
}
else {
- if (aSelList.Extent() != 1)
- return;
-
- // nbSel == 1
- aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
-
- if ( CORBA::is_nil(aSelectedObject) )
- return;
-
- aName = GEOMBase::GetName(aSelectedObject);
-
- // Get Selected object if selected subshape
+ TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0 ) ?
+ 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 && getConstructorId() == 0)
- aNeedType = TopAbs_EDGE;
-
- TColStd_IndexedMapOfInteger aMap;
- aSelMgr->GetIndexes(aSelList.First(), 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 = 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 == GroupPoints->LineEdit2 ) {
+ if ( getConstructorId() == 0 ) {
+ myAxis = aSelectedObject;
+ if ( myObjects.isEmpty() )
+ GroupPoints->PushButton1->click();
+ }
+ else if ( getConstructorId() == 1 ) {
+ myCentPoint = aSelectedObject;
+ if ( !myPoint1 )
+ GroupPoints->PushButton4->click();
+ else if ( !myPoint2 )
+ GroupPoints->PushButton5->click();
+ else if ( myObjects.isEmpty() )
+ GroupPoints->PushButton1->click();
+ }
}
- else // Global Selection
- {
- if (aShape.ShapeType() != aNeedType) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- }
+ else if ( myEditCurrentArgument == GroupPoints->LineEdit4 ) {
+ myPoint1 = aSelectedObject;
+ if ( !myPoint2 )
+ GroupPoints->PushButton5->click();
+ else if ( myObjects.isEmpty() )
+ GroupPoints->PushButton1->click();
+ else if ( !myCentPoint )
+ GroupPoints->PushButton2->click();
+ }
+ else if ( myEditCurrentArgument == GroupPoints->LineEdit5 ) {
+ myPoint2 = aSelectedObject;
+ if ( myObjects.isEmpty() )
+ GroupPoints->PushButton1->click();
+ else if ( !myCentPoint )
+ GroupPoints->PushButton2->click();
+ else if ( !myPoint1 )
+ GroupPoints->PushButton4->click();
}
}
- }
-
- myEditCurrentArgument->setText(aName);
-
- if (myEditCurrentArgument == GroupPoints->LineEdit1) {
- /* if (myObjects.length()) {
- if (getConstructorId() == 0 && myAxis->_is_nil() || getConstructorId() == 1 && myCentPoint->_is_nil() )
- GroupPoints->PushButton2->click();
- }*/ // here commented, because multiple objects can be selected IPAL 21437
- }
- else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0) {
- myAxis = aSelectedObject;
- if (!myAxis->_is_nil() && !myObjects.length())
- GroupPoints->PushButton1->click();
- }
- else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) {
- myCentPoint = aSelectedObject;
- if (!myCentPoint->_is_nil() && myPoint1->_is_nil())
- GroupPoints->PushButton4->click();
- }
- else if (myEditCurrentArgument == GroupPoints->LineEdit4) {
- myPoint1 = aSelectedObject;
- if (!myPoint1->_is_nil() && myPoint2->_is_nil())
- GroupPoints->PushButton5->click();
- }
- else if (myEditCurrentArgument == GroupPoints->LineEdit5) {
- myPoint2 = aSelectedObject;
- if (!myPoint2->_is_nil() && !myObjects.length())
- GroupPoints->PushButton1->click();
+ else {
+ if (myEditCurrentArgument == GroupPoints->LineEdit2 ) {
+ if ( getConstructorId() == 0 )
+ myAxis.nullify();
+ else if ( getConstructorId() == 1 )
+ myCentPoint.nullify();
+ }
+ else if ( myEditCurrentArgument == GroupPoints->LineEdit4 ) {
+ myPoint1.nullify();
+ }
+ else if ( myEditCurrentArgument == GroupPoints->LineEdit5 ) {
+ myPoint2.nullify();
+ }
+ myEditCurrentArgument->setText("");
+ }
}
- // clear selection
- /* disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- myGeomGUI->getApp()->selectionMgr()->clearSelected();
- connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
- this, SLOT(SelectionIntoArgument()));*/
- // here commented, because multiple objects can be selected IPAL 21437
-
displayPreview();
}
displayPreview();
}
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void TransformationGUI_RotationDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if (send == GroupPoints->LineEdit1 ||
- send == GroupPoints->LineEdit2) {
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
-}
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
bool TransformationGUI_RotationDlg::isValid (QString& msg)
{
+ bool ok = false;
switch (getConstructorId()) {
- case 0: {
- bool ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() );
- return myObjects.length() > 0 && !(myAxis->_is_nil()) && ok;
+ case 0:
+ ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && !myObjects.isEmpty() && myAxis;
break;
- }
case 1:
- return myObjects.length() > 0 && !(myCentPoint->_is_nil() || myPoint1->_is_nil() || myPoint2->_is_nil());
+ ok = !myObjects.isEmpty() && myCentPoint && myPoint1 && myPoint2;
break;
default:
break;
}
- return false;
+ return ok;
}
//=================================================================================
QStringList aParameters;
aParameters<<GroupPoints->SpinBox_DX->text();
if (toCreateCopy) {
- for (int i = 0; i < myObjects.length(); i++) {
+ for (int i = 0; i < myObjects.count(); i++) {
myCurrObject = myObjects[i];
- anObj = anOper->RotateCopy(myObjects[i], myAxis, GetAngle() * PI180);
+ anObj = anOper->RotateCopy(myObjects[i].get(), myAxis.get(), GetAngle() * PI180);
if (!anObj->_is_nil()) {
if(!IsPreview()) {
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
}
}
else {
- for (int i = 0; i < myObjects.length(); i++) {
+ for (int i = 0; i < myObjects.count(); i++) {
myCurrObject = myObjects[i];
- anObj = anOper->Rotate(myObjects[i], myAxis, GetAngle() * PI180);
+ anObj = anOper->Rotate(myObjects[i].get(), myAxis.get(), GetAngle() * PI180);
if (!anObj->_is_nil()) {
if(!IsPreview()) {
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
case 1:
{
if (toCreateCopy) {
- for (int i = 0; i < myObjects.length(); i++) {
+ for (int i = 0; i < myObjects.count(); i++) {
myCurrObject = myObjects[i];
- anObj = anOper->RotateThreePointsCopy(myObjects[i], myCentPoint, myPoint1, myPoint2);
+ anObj = anOper->RotateThreePointsCopy(myObjects[i].get(), myCentPoint.get(), myPoint1.get(), myPoint2.get());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
}
else {
- for (int i = 0; i < myObjects.length(); i++) {
+ for (int i = 0; i < myObjects.count(); i++) {
myCurrObject = myObjects[i];
- anObj = anOper->RotateThreePoints(myObjects[i], myCentPoint, myPoint1, myPoint2);
+ anObj = anOper->RotateThreePoints(myObjects[i].get(), myCentPoint.get(), myPoint1.get(), myPoint2.get());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
// and we need to point the first argument directly
GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
anArgs->length(1);
- anArgs[0] = myCurrObject;
+ anArgs[0] = myCurrObject.copy();
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
/*theFindMethod=*/GEOM::FSM_Transformed,
/*theInheritFirstArg=*/true,
// function : CreateCopyModeChanged()
// purpose :
//=================================================================================
-void TransformationGUI_RotationDlg::CreateCopyModeChanged (bool isCreateCopy)
+void TransformationGUI_RotationDlg::CreateCopyModeChanged()
{
- mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
+ mainFrame()->GroupBoxName->setEnabled(GroupPoints->CheckButton1->isChecked());
}
//=================================================================================
{
bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
if (toCreateCopy) {
- QMap<QString, GEOM::GEOM_Object_var> objMap;
switch (getConstructorId()) {
case 0:
- objMap[GroupPoints->LineEdit2->text()] = myAxis;
+ GEOMBase::PublishSubObject( myAxis.get() );
break;
case 1:
- objMap[GroupPoints->LineEdit2->text()] = myCentPoint;
- objMap[GroupPoints->LineEdit4->text()] = myPoint1;
- objMap[GroupPoints->LineEdit5->text()] = myPoint2;
+ GEOMBase::PublishSubObject( myCentPoint.get() );
+ GEOMBase::PublishSubObject( myPoint1.get() );
+ GEOMBase::PublishSubObject( myPoint2.get() );
+ break;
+ default:
break;
}
- addSubshapesToFather(objMap);
}
}
#ifndef TRANSFORMATIONGUI_ROTATIONDLG_H
#define TRANSFORMATIONGUI_ROTATIONDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_4Sel1Spin2Check;
double GetAngle() const;
private:
- GEOM::ListOfGO myObjects;
- GEOM::GEOM_Object_var myCurrObject;
- GEOM::GEOM_Object_var myAxis, myCentPoint, myPoint1, myPoint2;
+ QList<GEOM::GeomObjPtr> myObjects;
+ GEOM::GeomObjPtr myCurrObject;
+ GEOM::GeomObjPtr myAxis, myCentPoint, myPoint1, myPoint2;
// 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 ValueChangedInSpinBox();
void TextValueChangedInSpinBox( const QString& );
- void CreateCopyModeChanged( bool );
+ void CreateCopyModeChanged();
void ConstructorsClicked( int );
void onReverse();
};
CheckBoxCopy->hide();
// Activate Create a Copy mode
- CreateCopyModeChanged(true);
+ CreateCopyModeChanged();
// Allowed inheritance of children and visual properties by the scaling result
mainFrame()->GroupBoxPublish->show();
LineEdit1->setText("");
LineEdit2->setText("");
- myPoint = GEOM::GEOM_Object::_nil();
+ myObjects.clear();
+ myPoint.nullify();
// Signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect(LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- connect(LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-
connect(SpinBox_FX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(SpinBox_FY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(SpinBox_FZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
// san : Commented so as not to override specific step settings
//connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
- connect(CheckBoxCopy, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
+ connect(CheckBoxCopy, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged()));
initName(tr("GEOM_SCALE"));
{
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- myPoint = GEOM::GEOM_Object::_nil();
+ myPoint.nullify();
LineEdit2->clear();
switch (constructorId) {
initName(tr("GEOM_SCALE"));
- myObjects.length(0);
+ myObjects.clear();
myEditCurrentArgument = LineEdit1;
myEditCurrentArgument->setText("");
myGeomGUI->getApp()->selectionMgr()->clearSelected();
void TransformationGUI_ScaleDlg::SelectionIntoArgument()
{
erasePreview();
- myEditCurrentArgument->setText("");
-
- if (myEditCurrentArgument == LineEdit1)
- myObjects.length(0);
- else if (myEditCurrentArgument == LineEdit2)
- myPoint = GEOM::GEOM_Object::_nil();
-
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
-
- QString aName;
- if (myEditCurrentArgument == LineEdit1)
- {
- int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
- if (aNbSel < 1)
- return;
-
- GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
- if (!myObjects.length())
- return;
- else
- myEditCurrentArgument->setText(aName);
+ if ( myEditCurrentArgument == LineEdit1 ) {
+ myObjects = getSelected( TopAbs_SHAPE, -1 );
+ if ( !myObjects.isEmpty() ) {
+ QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
+ myEditCurrentArgument->setText( aName );
+ }
+ else {
+ myEditCurrentArgument->setText("");
+ }
}
- else if (myEditCurrentArgument == LineEdit2)
- {
- GEOM::GEOM_Object_var aSelectedObject = GEOM::GEOM_Object::_nil();
- if (aSelList.Extent() == 1)
- {
- aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
- if ( !CORBA::is_nil( aSelectedObject ) )
- {
- 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)
- {
- int anIndex = aMap(1);
- aName += QString(":vertex_%1").arg(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 = "";
- }
- }
- }
- }
+ else {
+ 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 );
+ myPoint = aSelectedObject;
+ if ( myObjects.isEmpty() )
+ PushButton1->click();
+ }
+ else {
+ myPoint.nullify();
+ myEditCurrentArgument->setText("");
}
-
- myPoint = aSelectedObject;
- myEditCurrentArgument->setText(aName);
-
- if (!myPoint->_is_nil() && !myObjects.length())
- PushButton1->click();
}
- // clear selection
- /* disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- myGeomGUI->getApp()->selectionMgr()->clearSelected();
- connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
- this, SLOT(SelectionIntoArgument()));*/
- // here commented, because multiple objects can be selected IPAL 21437
-
displayPreview();
}
displayPreview();
}
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void TransformationGUI_ScaleDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if (send == LineEdit1 || send == LineEdit2)
- {
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
-}
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
bool TransformationGUI_ScaleDlg::isValid (QString& msg)
{
- // && !myPoint->_is_nil()
- if (getConstructorId() == 0) {
- bool ok = SpinBox_FX->isValid( msg, !IsPreview() );
- return myObjects.length() > 0 && fabs(SpinBox_FX->value()) > 0.00001 && ok;
+ bool ok = false;
+ if ( getConstructorId() == 0 ) {
+ ok = SpinBox_FX->isValid( msg, !IsPreview() ) &&
+ !myObjects.isEmpty() &&
+ qAbs( SpinBox_FX->value() ) > 0.00001;
}
-
- bool ok = true;
- ok = SpinBox_FX->isValid( msg, !IsPreview() ) && ok;
- ok = SpinBox_FY->isValid( msg, !IsPreview() ) && ok;
- ok = SpinBox_FZ->isValid( msg, !IsPreview() ) && ok;
- return myObjects.length() > 0 &&
- fabs(SpinBox_FX->value()) > 0.00001 &&
- fabs(SpinBox_FY->value()) > 0.00001 &&
- fabs(SpinBox_FZ->value()) > 0.00001 && ok;
+ else {
+ ok = SpinBox_FX->isValid( msg, !IsPreview() ) &&
+ SpinBox_FY->isValid( msg, !IsPreview() ) &&
+ SpinBox_FZ->isValid( msg, !IsPreview() ) &&
+ !myObjects.isEmpty() &&
+ qAbs( SpinBox_FX->value() ) > 0.00001 &&
+ qAbs( SpinBox_FY->value() ) > 0.00001 &&
+ qAbs( SpinBox_FZ->value() ) > 0.00001;
+ }
+ return ok;
}
//=================================================================================
{
if (toCreateCopy)
{
- for (int i = 0; i < myObjects.length(); i++)
+ for (int i = 0; i < myObjects.count(); i++)
{
- anObj = anOper->ScaleShapeCopy(myObjects[i], myPoint, SpinBox_FX->value());
+ anObj = anOper->ScaleShapeCopy(myObjects[i].get(), myPoint.get(), SpinBox_FX->value());
if (!anObj->_is_nil()) {
if(!IsPreview())
anObj->SetParameters(SpinBox_FX->text().toLatin1().constData());
}
else
{
- for (int i = 0; i < myObjects.length(); i++)
+ for (int i = 0; i < myObjects.count(); i++)
{
- anObj = anOper->ScaleShape(myObjects[i], myPoint, SpinBox_FX->value());
+ anObj = anOper->ScaleShape(myObjects[i].get(), myPoint.get(), SpinBox_FX->value());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
{
if (toCreateCopy)
{
- for (int i = 0; i < myObjects.length(); i++)
+ for (int i = 0; i < myObjects.count(); i++)
{
- anObj = anOper->ScaleShapeAlongAxesCopy(myObjects[i], myPoint, SpinBox_FX->value(),
+ anObj = anOper->ScaleShapeAlongAxesCopy(myObjects[i].get(), myPoint.get(), SpinBox_FX->value(),
SpinBox_FY->value(), SpinBox_FZ->value());
if (!anObj->_is_nil())
if(!IsPreview()) {
}
else
{
- for (int i = 0; i < myObjects.length(); i++)
+ for (int i = 0; i < myObjects.count(); i++)
{
- anObj = anOper->ScaleShapeAlongAxes(myObjects[i], myPoint, SpinBox_FX->value(),
+ anObj = anOper->ScaleShapeAlongAxes(myObjects[i].get(), myPoint.get(), SpinBox_FX->value(),
SpinBox_FY->value(), SpinBox_FZ->value());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
// function : CreateCopyModeChanged()
// purpose :
//=================================================================================
-void TransformationGUI_ScaleDlg::CreateCopyModeChanged (bool isCreateCopy)
+void TransformationGUI_ScaleDlg::CreateCopyModeChanged()
{
- mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
+ mainFrame()->GroupBoxName->setEnabled(CheckBoxCopy->isChecked());
}
//=================================================================================
bool toCreateCopy = IsPreview() || CheckBoxCopy->isChecked();
if (toCreateCopy)
{
- if (!myPoint->_is_nil())
- {
- QMap<QString, GEOM::GEOM_Object_var> objMap;
- objMap[LineEdit2->text()] = myPoint;
- addSubshapesToFather(objMap);
- }
+ GEOMBase::PublishSubObject( myPoint.get() );
}
}
#ifndef TRANSFORMATIONGUI_SCALEDLG_H
#define TRANSFORMATIONGUI_SCALEDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class QCheckBox;
class QGroupBox;
void enterEvent( QEvent* );
private:
- GEOM::ListOfGO myObjects;
- GEOM::GEOM_Object_var myPoint; /* Central Point */
+ QList<GEOM::GeomObjPtr> myObjects;
+ GEOM::GeomObjPtr myPoint; /* Central Point */
// 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 );
void ValueChangedInSpinBox();
- void CreateCopyModeChanged( bool );
+ void CreateCopyModeChanged();
void SetDoubleSpinBoxStep( double );
};
// Activate Create a Copy mode
GroupPoints->CheckBox2->setChecked(true);
- CreateCopyModeChanged(true);
+ CreateCopyModeChanged();
Init();
}
GroupPoints->LineEdit2->setText("");
GroupPoints->LineEdit3->setText("");
- myVector = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
+ myObjects.clear();
+ myVector.nullify();
+ myPoint1.nullify();
+ myPoint2.nullify();
mainFrame()->GroupBoxPublish->show();
connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); //@ Delete ?
-
connect(GroupPoints->SpinBox1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupPoints->SpinBox2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupPoints->SpinBox3, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
- connect(GroupPoints->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(ActivateDistanceChanged(bool)));
- connect(GroupPoints->CheckBox2, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
+ connect(GroupPoints->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(ActivateDistanceChanged()));
+ connect(GroupPoints->CheckBox2, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged()));
initName(tr("GEOM_TRANSLATION"));
GroupPoints->CheckBox1->hide();
- myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
+ myPoint1.nullify();
+ myPoint2.nullify();
GroupPoints->PushButton1->click();
}
GroupPoints->CheckBox1->show();
- myVector = GEOM::GEOM_Object::_nil();
- ActivateDistanceChanged(GroupPoints->CheckBox1->isChecked());
+ myVector.nullify();
+ ActivateDistanceChanged();
GroupPoints->PushButton1->click();
}
initName();
- myObjects.length(0);
+ myObjects.clear();
myEditCurrentArgument = GroupPoints->LineEdit1;
myEditCurrentArgument->setText("");
myGeomGUI->getApp()->selectionMgr()->clearSelected();
void TransformationGUI_TranslationDlg::SelectionIntoArgument()
{
erasePreview();
- myEditCurrentArgument->setText("");
- if (myEditCurrentArgument == GroupPoints->LineEdit1)
- myObjects.length(0);
- else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1)
- myPoint1 = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2)
- myVector = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPoints->LineEdit3)
- myPoint2 = GEOM::GEOM_Object::_nil();
-
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
-
- QString aName;
-
- if (myEditCurrentArgument == GroupPoints->LineEdit1) {
- int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
- if (aNbSel < 1)
- return;
-
- GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
- if (!myObjects.length())
- return;
+ if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
+ myObjects = getSelected( TopAbs_SHAPE, -1 );
+ if ( !myObjects.isEmpty() ) {
+ QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
+ myEditCurrentArgument->setText( aName );
+ }
else {
- myEditCurrentArgument->setText(aName);
-
- // here we do not switch to the next field, because multiple objects can be selected
- /*
- if (getConstructorId() == 1) {
- if (myPoint1->_is_nil())
- GroupPoints->PushButton2->click();
- }
- else if (getConstructorId() == 2) {
- if (myVector->_is_nil())
- GroupPoints->PushButton2->click();
- }
- */
+ myEditCurrentArgument->setText("");
}
}
else {
- if (aSelList.Extent() != 1)
- return;
-
- // nbSel == 1
- GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
-
- if ( CORBA::is_nil(aSelectedObject) )
- return;
-
- aName = GEOMBase::GetName(aSelectedObject);
-
- // Get Selected object if selected subshape
+ TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2 ) ?
+ 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 && getConstructorId() == 2)
- aNeedType = TopAbs_EDGE;
-
- TColStd_IndexedMapOfInteger aMap;
- aSelMgr->GetIndexes(aSelList.First(), 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 = 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;
- }
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+ myEditCurrentArgument->setText( aName );
+ if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
+ if ( getConstructorId() == 1 ) {
+ myPoint1 = aSelectedObject;
+ if ( !myPoint2 )
+ GroupPoints->PushButton3->click();
+ else if ( myObjects.isEmpty() )
+ GroupPoints->PushButton1->click();
+ }
+ else if ( getConstructorId() == 2 ) {
+ myVector = aSelectedObject;
+ if ( myObjects.isEmpty() )
+ GroupPoints->PushButton1->click();
+ }
}
- else // Global Selection
- {
- if (aShape.ShapeType() != aNeedType) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- }
+ else if ( myEditCurrentArgument == GroupPoints->LineEdit3 ) {
+ myPoint2 = aSelectedObject;
+ if ( myObjects.isEmpty() )
+ GroupPoints->PushButton1->click();
+ else if ( !myPoint1 )
+ GroupPoints->PushButton2->click();
}
}
-
- myEditCurrentArgument->setText(aName);
-
- if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) {
- myPoint1 = aSelectedObject;
- if (!myPoint1->_is_nil() && myPoint2->_is_nil())
- GroupPoints->PushButton3->click();
- }
- else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2) {
- myVector = aSelectedObject;
- if (!myVector->_is_nil() && !myObjects.length())
- GroupPoints->PushButton1->click();
- }
- else if (myEditCurrentArgument == GroupPoints->LineEdit3) {
- myPoint2 = aSelectedObject;
- if (!myPoint2->_is_nil() && !myObjects.length())
- GroupPoints->PushButton1->click();
+ else {
+ if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
+ if ( getConstructorId() == 1 ) myPoint1.nullify();
+ else myVector.nullify();
+ }
+ else if ( myEditCurrentArgument == GroupPoints->LineEdit3 ) {
+ myPoint2.nullify();
+ }
+ myEditCurrentArgument->setText("");
}
}
- // clear selection
- /* disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- myGeomGUI->getApp()->selectionMgr()->clearSelected();
- connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
- this, SLOT(SelectionIntoArgument()));*/
- // here commented, because multiple objects can be selected IPAL 21437
-
displayPreview();
}
displayPreview();
}
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void TransformationGUI_TranslationDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if (send == GroupPoints->LineEdit1) {
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
-}
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
bool TransformationGUI_TranslationDlg::isValid (QString& msg)
{
- int aConstructorId = getConstructorId();
-
- switch (aConstructorId) {
+ bool ok = false;
+ switch (getConstructorId()) {
case 0:
- {
- bool ok = true;
- ok = GroupPoints->SpinBox1->isValid( msg, !IsPreview() ) && ok;
- ok = GroupPoints->SpinBox2->isValid( msg, !IsPreview() ) && ok;
- ok = GroupPoints->SpinBox3->isValid( msg, !IsPreview() ) && ok;
- return myObjects.length() > 0 && ok;
- }
+ ok = GroupPoints->SpinBox1->isValid( msg, !IsPreview() ) &&
+ GroupPoints->SpinBox2->isValid( msg, !IsPreview() ) &&
+ GroupPoints->SpinBox3->isValid( msg, !IsPreview() ) &&
+ !myObjects.isEmpty();
+ break;
case 1:
- return myObjects.length() > 0 && !(myPoint1->_is_nil() || myPoint2->_is_nil());
+ ok = myPoint1 && myPoint2 && !myObjects.isEmpty();
+ break;
case 2:
- {
- bool ok = GroupPoints->SpinBox3->isValid( msg, !IsPreview() );
- return myObjects.length() > 0 && !(myVector->_is_nil()) && ok;
- }
+ ok = GroupPoints->SpinBox3->isValid( msg, !IsPreview() ) &&
+ myVector && !myObjects.isEmpty();
+ break;
default:
break;
}
- return false;
+ return ok;
}
//=================================================================================
aParameters<<GroupPoints->SpinBox3->text();
if (toCreateCopy) {
- for (int i = 0; i < myObjects.length(); i++) {
+ for (int i = 0; i < myObjects.count(); i++) {
myCurrObject = myObjects[i];
- anObj = anOper->TranslateDXDYDZCopy(myObjects[i], dx, dy, dz);
+ anObj = anOper->TranslateDXDYDZCopy(myObjects[i].get(), dx, dy, dz);
if (!anObj->_is_nil()) {
if(!IsPreview())
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
}
}
else {
- for (int i = 0; i < myObjects.length(); i++) {
+ for (int i = 0; i < myObjects.count(); i++) {
myCurrObject = myObjects[i];
- anObj = anOper->TranslateDXDYDZ(myObjects[i], dx, dy, dz);
+ anObj = anOper->TranslateDXDYDZ(myObjects[i].get(), dx, dy, dz);
if (!anObj->_is_nil()) {
if(!IsPreview()) {
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
case 1:
{
if (toCreateCopy) {
- for (int i = 0; i < myObjects.length(); i++) {
+ for (int i = 0; i < myObjects.count(); i++) {
myCurrObject = myObjects[i];
- anObj = anOper->TranslateTwoPointsCopy(myObjects[i], myPoint1, myPoint2);
+ anObj = anOper->TranslateTwoPointsCopy(myObjects[i].get(), myPoint1.get(), myPoint2.get());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
}
else {
- for (int i = 0; i < myObjects.length(); i++) {
+ for (int i = 0; i < myObjects.count(); i++) {
myCurrObject = myObjects[i];
- anObj = anOper->TranslateTwoPoints(myObjects[i], myPoint1, myPoint2);
+ anObj = anOper->TranslateTwoPoints(myObjects[i].get(), myPoint1.get(), myPoint2.get());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
QStringList aParameters;
aParameters<<GroupPoints->SpinBox3->text();
bool byDistance = GroupPoints->CheckBox1->isChecked();
- createPathPreview( myVector );
+ createPathPreview( myVector.get() );
if (byDistance) {
double aDistance = GroupPoints->SpinBox3->value();
- for (int i = 0; i < myObjects.length(); i++) {
+ for (int i = 0; i < myObjects.count(); i++) {
myCurrObject = myObjects[i];
- anObj = anOper->TranslateVectorDistance(myObjects[i], myVector, aDistance, toCreateCopy);
+ anObj = anOper->TranslateVectorDistance(myObjects[i].get(), myVector.get(), aDistance, toCreateCopy);
if (!anObj->_is_nil()) {
if(!IsPreview()) {
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
}
else {
if (toCreateCopy) {
- for (int i = 0; i < myObjects.length(); i++) {
+ for (int i = 0; i < myObjects.count(); i++) {
myCurrObject = myObjects[i];
- anObj = anOper->TranslateVectorCopy(myObjects[i], myVector);
+ anObj = anOper->TranslateVectorCopy(myObjects[i].get(), myVector.get());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
}
else {
- for (int i = 0; i < myObjects.length(); i++) {
+ for (int i = 0; i < myObjects.count(); i++) {
myCurrObject = myObjects[i];
- anObj = anOper->TranslateVector(myObjects[i], myVector);
+ anObj = anOper->TranslateVector(myObjects[i].get(), myVector.get());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
// and we need to point the first argument directly
GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
anArgs->length(1);
- anArgs[0] = myCurrObject;
+ anArgs[0] = myCurrObject.copy();
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
/*theFindMethod=*/GEOM::FSM_Transformed,
/*theInheritFirstArg=*/true,
// function : CreateCopyModeChanged()
// purpose :
//=================================================================================
-void TransformationGUI_TranslationDlg::CreateCopyModeChanged (bool isCreateCopy)
+void TransformationGUI_TranslationDlg::CreateCopyModeChanged()
{
- mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
+ mainFrame()->GroupBoxName->setEnabled(GroupPoints->CheckBox2->isChecked());
}
//=================================================================================
// function : ActivateDistanceChanged()
// purpose :
//=================================================================================
-void TransformationGUI_TranslationDlg::ActivateDistanceChanged (bool theEnable)
+void TransformationGUI_TranslationDlg::ActivateDistanceChanged()
{
- GroupPoints->SpinBox3->setEnabled(theEnable);
+ GroupPoints->SpinBox3->setEnabled( GroupPoints->CheckBox1->isChecked() );
displayPreview();
}
{
bool toCreateCopy = IsPreview() || GroupPoints->CheckBox2->isChecked();
if (toCreateCopy) {
- QMap<QString, GEOM::GEOM_Object_var> objMap;
-
switch (getConstructorId()) {
- case 0:
- return;
case 1:
- objMap[GroupPoints->LineEdit2->text()] = myPoint1;
- objMap[GroupPoints->LineEdit3->text()] = myPoint2;
+ GEOMBase::PublishSubObject( myPoint1.get() );
+ GEOMBase::PublishSubObject( myPoint2.get() );
break;
case 2:
- objMap[GroupPoints->LineEdit2->text()] = myVector;
+ GEOMBase::PublishSubObject( myVector.get() );
+ break;
+ default:
break;
}
- addSubshapesToFather(objMap);
}
}
// function : createPathPreview
// purpose :
//=================================================================================
-void TransformationGUI_TranslationDlg::createPathPreview ( GEOM::GEOM_Object_var thePath )
+void TransformationGUI_TranslationDlg::createPathPreview ( GEOM::GEOM_Object_ptr thePath )
{
if ( IsPreview() ) {
TopoDS_Shape aShape;
#ifndef TRANSFORMATIONGUI_TRANSLATIONDLG_H
#define TRANSFORMATIONGUI_TRANSLATIONDLG_H
-#include <GEOMBase_Skeleton.h>
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
class DlgRef_3Sel3Spin2Check;
private:
void Init();
void enterEvent( QEvent* );
- void createPathPreview( GEOM::GEOM_Object_var );
+ void createPathPreview( GEOM::GEOM_Object_ptr );
private:
- GEOM::ListOfGO myObjects;
- GEOM::GEOM_Object_var myCurrObject;
- GEOM::GEOM_Object_var myVector, myPoint1, myPoint2;
+ QList<GEOM::GeomObjPtr> myObjects;
+ GEOM::GeomObjPtr myCurrObject;
+ GEOM::GeomObjPtr myVector, myPoint1, myPoint2;
// 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 );
void ValueChangedInSpinBox();
- void CreateCopyModeChanged( bool );
+ void CreateCopyModeChanged();
void SetDoubleSpinBoxStep( double );
- void ActivateDistanceChanged( bool );
+ void ActivateDistanceChanged();
};
#endif // TRANSFORMATIONGUI_TRANSLATIONDLG_H