// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
//
#include "SalomeApp_Application.h"
#include "LightApp_SelectionMgr.h"
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS.hxx>
+#include <TopExp.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
#include <qlabel.h>
#include "GEOMImpl_Types.hxx"
Layout1->addWidget(GroupDimensions, 2, 0);
/***************************************************************/
- setHelpFileName( "cone.htm" );
+ setHelpFileName( "create_cone_page.html" );
Init();
}
double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
/* min, max, step and decimals for spin boxes & initial values */
- GroupPoints->SpinBox_DX->RangeStepAndValidator(0.000, 999.999, step, 3);
- GroupPoints->SpinBox_DY->RangeStepAndValidator(0.000, 999.999, step, 3);
- GroupPoints->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3);
- GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.000, 999.999, step, 3);
- GroupDimensions->SpinBox_DY->RangeStepAndValidator(0.000, 999.999, step, 3);
- GroupDimensions->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3);
+ GroupPoints->SpinBox_DX->RangeStepAndValidator(0.000, COORD_MAX, step, DBL_DIGITS_DISPLAY);
+ GroupPoints->SpinBox_DY->RangeStepAndValidator(0.000, COORD_MAX, step, DBL_DIGITS_DISPLAY);
+ GroupPoints->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
+ GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.000, COORD_MAX, step, DBL_DIGITS_DISPLAY);
+ GroupDimensions->SpinBox_DY->RangeStepAndValidator(0.000, COORD_MAX, step, DBL_DIGITS_DISPLAY);
+ GroupDimensions->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
double aRadius1(100.0), aRadius2(0.0), aHeight(300.0);
GroupPoints->SpinBox_DX->SetValue(aRadius1);
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY, SLOT(SetStep(double)));
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DZ, SLOT(SetStep(double)));
- connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+ connect(myGeomGUI->getApp()->selectionMgr(),
SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
initName( tr( "GEOM_CONE" ) );
//=================================================================================
void PrimitiveGUI_ConeDlg::ConstructorsClicked(int constructorId)
{
- disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
switch(constructorId)
{
case 0 :
{
- globalSelection( GEOM_POINT );
+ // globalSelection( GEOM_POINT );
+ globalSelection(); // to break prvious local selection
+ localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
GroupDimensions->hide();
resize(0, 0);
GroupPoints->show();
GroupPoints->LineEdit2->setText(tr(""));
myPoint = myDir = GEOM::GEOM_Object::_nil();
- connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+ connect(myGeomGUI->getApp()->selectionMgr(),
SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
break;
}
case 1 :
{
GroupPoints->hide();
+ globalSelection(); // close local contexts, if any
resize( 0, 0 );
GroupDimensions->show();
//=================================================================================
void PrimitiveGUI_ConeDlg::SelectionIntoArgument()
{
- if ( getConstructorId() != 0 )
+ if (getConstructorId() != 0)
return;
- if(IObjectCount() != 1)
- {
- if(myEditCurrentArgument == GroupPoints->LineEdit1)
- myPoint = GEOM::GEOM_Object::_nil();
- else if (myEditCurrentArgument == GroupPoints->LineEdit2)
- myDir = GEOM::GEOM_Object::_nil();
- return;
- }
+ if (IObjectCount() != 1)
+ {
+ if (myEditCurrentArgument == GroupPoints->LineEdit1)
+ myPoint = GEOM::GEOM_Object::_nil();
+ else if (myEditCurrentArgument == GroupPoints->LineEdit2)
+ myDir = GEOM::GEOM_Object::_nil();
+ return;
+ }
/* nbSel == 1 */
Standard_Boolean testResult = Standard_False;
if(!testResult || CORBA::is_nil( aSelectedObject ))
return;
+ TopoDS_Shape aShape;
+ QString aName = GEOMBase::GetName( aSelectedObject );
+
+ if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
+ {
+ TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
+ if (myEditCurrentArgument == GroupPoints->LineEdit2)
+ aNeedType = TopAbs_EDGE;
+
+ LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+ TColStd_IndexedMapOfInteger aMap;
+ aSelMgr->GetIndexes( firstIObject(), aMap );
+ if (aMap.Extent() == 1)
+ {
+ 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 == GEOM::GEOM_Object::_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
+ {
+ if (aShape.ShapeType() != aNeedType) {
+ aSelectedObject = GEOM::GEOM_Object::_nil();
+ aName = "";
+ }
+ }
+ }
+
+ myEditCurrentArgument->setText(aName);
+
if (myEditCurrentArgument == GroupPoints->LineEdit1)
myPoint = aSelectedObject;
else if (myEditCurrentArgument == GroupPoints->LineEdit2)
myDir = aSelectedObject;
-
-
- myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
+
displayPreview();
}
-
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
if(send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1;
- globalSelection( GEOM_POINT );
+ globalSelection( GEOM_POINT ); // to break prvious local selection
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
}
else if(send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2;
- globalSelection( GEOM_LINE );
+ globalSelection( GEOM_LINE );// to break prvious local selection
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
}
myEditCurrentArgument->setFocus();
}
}
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
void PrimitiveGUI_ConeDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
- connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
- SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
-
- ConstructorsClicked( getConstructorId() );
-}
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
+ ConstructorsClicked(getConstructorId());
+}
//=================================================================================
// function : DeactivateActiveDialog()
return GroupDimensions->SpinBox_DZ->GetValue();
return 0;
}
+
+//=================================================================================
+// function : addSubshapeToStudy
+// purpose : virtual method to add new SubObjects if local selection
+//=================================================================================
+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;
+ }
+ addSubshapesToFather( objMap );
+}