-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
#include "RepairGUI_DivideEdgeDlg.h"
-#include <DlgRef.h>
-#include <GeometryGUI.h>
-#include <GEOMBase.h>
-#include <SalomeApp_DoubleSpinBox.h>
+#include "DlgRef.h"
+#include "GeometryGUI.h"
+#include "GEOMBase.h"
+#include "RepairGUI.h"
+#include <SalomeApp_DoubleSpinBox.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SUIT_Session.h>
#include <TopoDS_Edge.hxx>
#include <gp_Pnt.hxx>
+#include <QButtonGroup>
+
enum { BY_PARAM, BY_POINT_PROJ };
//=================================================================================
//=======================================================================
void RepairGUI_DivideEdgeDlg::ConstructorsClicked( int constructorId )
{
- myIsParameterGr->button( 0 )->setShown( constructorId == BY_PARAM );
- myIsParameterGr->button( 1 )->setShown( constructorId == BY_PARAM );
- myValEdt ->setShown( constructorId == BY_PARAM );
- myValLbl ->setShown( constructorId == BY_PARAM );
- GroupPoints->TextLabel2 ->setShown( constructorId == BY_POINT_PROJ );
- GroupPoints->PushButton2 ->setShown( constructorId == BY_POINT_PROJ );
- GroupPoints->LineEdit2 ->setShown( constructorId == BY_POINT_PROJ );
+ myIsParameterGr->button( 0 )->setVisible( constructorId == BY_PARAM );
+ myIsParameterGr->button( 1 )->setVisible( constructorId == BY_PARAM );
+ myValEdt ->setVisible( constructorId == BY_PARAM );
+ myValLbl ->setVisible( constructorId == BY_PARAM );
+ GroupPoints->TextLabel2 ->setVisible( constructorId == BY_POINT_PROJ );
+ GroupPoints->PushButton2 ->setVisible( constructorId == BY_POINT_PROJ );
+ GroupPoints->LineEdit2 ->setVisible( constructorId == BY_POINT_PROJ );
initSelection();
myEditCurrentArgument = GroupPoints->LineEdit1;
myObject = GEOM::GEOM_Object::_nil();
- myPoint.nullify();
+ myPoints.clear();
myIndex = -1;
myProjectionOK = false;
BRepBuilderAPI_MakeVertex mkVertex (aPnt);
aShape = mkVertex.Shape();
}
- else if ( getConstructorId() == BY_POINT_PROJ && myPoint )
+ else if ( getConstructorId() == BY_POINT_PROJ && !myPoints.empty() )
{
- TopoDS_Shape aPoints;
- GEOMBase::GetShape( myPoint.get(), aPoints, TopAbs_SHAPE );
-
BRep_Builder builder;
TopoDS_Compound compoundOfVV;
builder.MakeCompound(compoundOfVV);
aProjector.Init( aCurve, aFP, aLP );
TopTools_MapOfShape vMap;
- TopExp_Explorer vertex( aPoints, TopAbs_VERTEX );
- for ( ; vertex.More(); vertex.Next() )
+ for ( int i = 0; i < myPoints.count(); ++i )
{
- if ( !vMap.Add( vertex.Current() )) continue;
- gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( vertex.Current() ));
+ TopoDS_Shape aPoint;
+ GEOMBase::GetShape( myPoints[i].get(), aPoint, TopAbs_VERTEX );
+ if ( !vMap.Add( aPoint )) continue;
+
+ gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( aPoint ));
aProjector.Perform( p );
if ( aProjector.NbPoints() > 0 )
{
initName();
- myEditCurrentArgument->setText( "" );
+ GroupPoints->LineEdit1->setText( "" );
+ GroupPoints->LineEdit2->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
- myPoint.nullify();
+ myPoints.clear();
myIndex = -1;
myProjectionOK = false;
- ConstructorsClicked(getConstructorId());
+ GroupPoints->PushButton1->click();
return true;
}
{
myObject = GEOM::GEOM_Object::_nil();
myIndex = -1;
+ myProjectionOK = false;
}
else //if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
{
- myPoint.nullify();
+ myPoints.clear();
myProjectionOK = false;
}
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
- if ( aSelList.Extent() == 1 ) {
+ if ( toSelectObject && aSelList.Extent() == 1 ) {
Handle(SALOME_InteractiveObject) anIO = aSelList.First();
GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO );
if ( !CORBA::is_nil( aSelectedObj ) )
if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) )
{
const int aType = aShape.ShapeType();
- if ( aType <= TopAbs_EDGE || !toSelectObject ) // edge, wire, face, shell, solid, compound
+ if ( aType <= TopAbs_EDGE ) // edge, wire, face, shell, solid, compound
{
GEOM::short_array anIndexes;
if ( !aMap.IsEmpty() ) // sub-shape selection
{
- if ( toSelectObject ) {
- myIndex = aMap( 1 );
- myObject = aSelectedObj;
- myEditCurrentArgument->setText( aName += QString( ":edge_%1" ).arg( myIndex ) );
- }
- else if (( myPoint = getSelected( TopAbs_VERTEX )))
- {
- myEditCurrentArgument->setText( aName += QString( ":vertex_%1" ).arg( aMap( 1 )));
- }
+ myIndex = aMap( 1 );
+ myObject = aSelectedObj;
+ myEditCurrentArgument->setText( aName += QString( ":edge_%1" ).arg( myIndex ) );
}
- else if ( aType == TopAbs_EDGE && toSelectObject ) // single shape selection
+ else if ( aType == TopAbs_EDGE ) // single shape selection
{
myIndex = -1;
myObject = aSelectedObj;
- myEditCurrentArgument->setText( aName );
- }
- else if ( aType == TopAbs_VERTEX && !toSelectObject ) // single shape selection
- {
- myPoint = aSelectedObj;
- myEditCurrentArgument->setText( aName );
+ myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) );
}
else // face, shell, solid or compound was selected, and NOT its sub-shape.
{
+ myIndex = -1;
+ myObject = GEOM::GEOM_Object::_nil();
}
}
}
}
}
+ if ( !toSelectObject )
+ {
+ myPoints = getSelected( TopAbs_VERTEX, -1, /*strict=*/true );
+ if ( myPoints.empty() )
+ myEditCurrentArgument->setText( "" );
+ else if ( myPoints.count() == 1 )
+ myEditCurrentArgument->setText( GEOMBase::GetName( myPoints[0].get() ));
+ else
+ myEditCurrentArgument->setText( QObject::tr( "%1_vertices" ).arg( myPoints.count() ));
+ }
displayPreview();
}
//=================================================================================
GEOM::GEOM_IOperations_ptr RepairGUI_DivideEdgeDlg::createOperation()
{
- return getGeomEngine()->GetIHealingOperations( getStudyId() );
+ return getGeomEngine()->GetIHealingOperations();
}
//=================================================================================
}
else if ( getConstructorId() == BY_POINT_PROJ )
{
- if (( ok = myPoint ) && !( ok = myProjectionOK ))
+ if (( ok = myPoints.count() ) && !( ok = myProjectionOK ))
msg = tr("DEVIDE_EDGE_BAD_PROJ_MSG");
}
return !myObject->_is_nil() && ok;
GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow( getOperation() );
GEOM::GEOM_Object_var anObj;
if ( getConstructorId() == BY_PARAM )
+ {
anObj = anOper->DivideEdge( myObject, myIndex, myValEdt->value(), getIsByParameter() );
+ }
else
- anObj = anOper->DivideEdgeByPoint( myObject, myIndex, myPoint.get() );
-
+ {
+ GEOM::ListOfGO_var objList = new GEOM::ListOfGO;
+ objList->length( myPoints.count() );
+ for ( int i = 0; i < myPoints.count(); ++i )
+ objList[i] = myPoints[i].copy();
+ anObj = anOper->DivideEdgeByPoint( myObject, myIndex, objList );
+ }
bool aResult = !anObj->_is_nil();
if ( aResult )
{
aParameters << "";
aParameters << myValEdt->text();
aParameters << "";
- anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+ anObj->SetParameters(aParameters.join(":").toUtf8().constData());
}
+ if ( !IsPreview() )
+ RepairGUI::ShowStatistics( anOper, this );
objects.push_back( anObj._retn() );
}
//=================================================================================
void RepairGUI_DivideEdgeDlg::initSelection()
{
- TopAbs_ShapeEnum type = TopAbs_EDGE;
- if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
- type = TopAbs_VERTEX;
-
- globalSelection(); // close local contexts, if any
- localSelection( GEOM::GEOM_Object::_nil(), type ); // load local selection on ALL objects
+ // close local contexts
+ globalSelection();
+ // load local selection on ALL objects
+ localSelection( myEditCurrentArgument == GroupPoints->LineEdit2 ? TopAbs_VERTEX : TopAbs_EDGE );
}
//=================================================================================
//=================================================================================
void RepairGUI_DivideEdgeDlg::addSubshapesToStudy()
{
- GEOMBase::PublishSubObject( myPoint.get() );
+ for ( int i = 0; i < myPoints.count(); ++i )
+ GEOMBase::PublishSubObject( myPoints[i].get() );
+}
+
+//=================================================================================
+// function : getSourceObjects
+// purpose : virtual method to get source objects
+//=================================================================================
+QList<GEOM::GeomObjPtr> RepairGUI_DivideEdgeDlg::getSourceObjects()
+{
+ QList<GEOM::GeomObjPtr> res(myPoints);
+ GEOM::GeomObjPtr aGeomObjPtr(myObject);
+ res << aGeomObjPtr;
+ return res;
}