## Exports all bodies
def exportBodies(self):
+ global ShapeIndex
kResultBodyType = "Bodies"
aPartSize = self.Part.size(kResultBodyType)
if aPartSize == 0:
aDump = aShape.getShapeStream()
# Load shape to SALOME Geom
aBrep = self.geompy.RestoreShape(aDump)
- self.geompy.addToStudy(aBrep, "NewGeomShape_{0}".format(idx + 1))
+ self.geompy.addToStudy(aBrep, aBodyResult.data().name())
self.geomObjects.append([aShape, aBrep])
## Exports all groups
if (!aDimAIS.IsNull()) {
aDimAIS->DimensionAspect()->SetCommonColor(aColor);
}
+ Handle(AIS_InteractiveContext) aContext = anAIS->GetContext();
+ aContext->SetColor(anAIS, aColor, false);
}
void GeomAPI_AISObject::setWidth(const double& theWidth)
if (!aDimAIS.IsNull()) {
aDimAIS->DimensionAspect()->SetCommonColor(aColor);
}
+ Handle(AIS_InteractiveContext) aContext = anAIS->GetContext();
+ aContext->SetColor(anAIS, aColor, false);
}
bool GeomAPI_AISObject::empty() const
return;
}
}
+ //BRepTools::Write(aNewShape, "Selection0.brep");
aSel.Select(aNewShape, aContext);
}
TopoDS_Shape aSubShape = aSubSh->impl<TopoDS_Shape>();
TopoDS_Shape aContext = aCont->shape()->impl<TopoDS_Shape>();
#ifdef DEB_NAMING
+ if(aSubShape.ShapeType() == TopAbs_COMPOUND) {
BRepTools::Write(aSubShape, "Selection.brep");
BRepTools::Write(aContext, "Context.brep");
+ }
#endif
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(aCont->document());
case TopAbs_EDGE:
{
// name structure: F1 | F2 [| F3 | F4], where F1 & F2 the faces which gives the Edge in trivial case
- // if it is not atrivial case we use localization by neighbours. F3 & F4 - neighbour faces
+ // if it is not atrivial case we use localization by neighbours. F3 & F4 - neighbour faces
+ if (BRep_Tool::Degenerated(TopoDS::Edge(aSubShape))) {
+ aName = "Degenerated_Edge";
+ break;
+ }
TopTools_IndexedDataMapOfShapeListOfShape aMap;
TopExp::MapShapesAndAncestors(aContext, TopAbs_EDGE, TopAbs_FACE, aMap);
TopTools_IndexedMapOfShape aSMap; // map for ancestors of the sub-shape
//n = aList.Extent();
#endif
int n = aList.Extent();
- if(n < 3) { // open topology case => via edges
+ if(n < 3) { // open topology case or Compound case => via edges
TopTools_IndexedDataMapOfShapeListOfShape aMap;
TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_EDGE, aMap);
- const TopTools_ListOfShape& aList2 = aMap.FindFromKey(aSubShape);
- if(aList2.Extent() >= 2) { // regular solution
- TopTools_ListIteratorOfListOfShape itl(aList2);
+ const TopTools_ListOfShape& aList22 = aMap.FindFromKey(aSubShape);
+ if(aList22.Extent() >= 2) { // regular solution
+#ifdef FIX_BUG1
+
+ // bug! duplication; fix is below
+ aFMap.Clear();
+ TopTools_ListOfShape aListE;
+ TopTools_ListIteratorOfListOfShape itl2(aList22);
+ for (int i = 1;itl2.More();itl2.Next(),i++) {
+ if(aFMap.Add(itl2.Value()))
+ aListE.Append(itl2.Value());
+ }
+ n = aListE.Extent();
+#endif
+ TopTools_ListIteratorOfListOfShape itl(aListE);
for (int i = 1;itl.More();itl.Next(),i++) {
const TopoDS_Shape& anEdge = itl.Value();
std::string anEdgeName = GetShapeName(aDoc, anEdge, selectionLabel());
else
aName += "|" + anEdgeName;
}
+ }//reg
+ else { // dangle vertex: if(aList22.Extent() == 1)
+ //it should be already in DF
}
}
else {
// DEB
//#include <TCollection_AsciiString.hxx>
//#include <TDF_Tool.hxx>
-#define DEB_IMPORT 1
+//#define DEB_IMPORT 1
Model_ResultBody::Model_ResultBody()
{
}
}
}
+
+//=======================================================================
+int findAmbiguities(const TopoDS_Shape& theShapeIn,
+ TopTools_ListOfShape& theList)
+{
+ int aNumEdges(0);
+ theList.Clear();
+ TopTools_IndexedDataMapOfShapeListOfShape subShapeAndAncestors;
+ TopAbs_ShapeEnum aTS(TopAbs_EDGE);
+ TopAbs_ShapeEnum aTA(TopAbs_FACE);
+ TopTools_MapOfShape aMap1, aMap2; // map1 - for edge ancestors; map2 - for keys => edges
+ TopTools_ListOfShape aKeyList;
+ TopExp::MapShapesAndAncestors(theShapeIn, aTS, aTA, subShapeAndAncestors);
+ for (Standard_Integer i = 1; i <= subShapeAndAncestors.Extent(); i++) {
+ const TopoDS_Shape& aKeyEdge1 = subShapeAndAncestors.FindKey(i);
+ const TopTools_ListOfShape& ancestors1 = subShapeAndAncestors.FindFromIndex(i);
+ aMap1.Clear();
+ TopTools_ListIteratorOfListOfShape it(ancestors1);
+ for(;it.More();it.Next()) aMap1.Add(it.Value()); // fill map with key ancestors => aKey1
+ for (Standard_Integer j = 1; j <= subShapeAndAncestors.Extent(); j++) {
+ if (i == j) continue;
+ const TopoDS_Shape& aKeyEdge2 = subShapeAndAncestors.FindKey(j);
+ const TopTools_ListOfShape& ancestors2 = subShapeAndAncestors.FindFromIndex(j);
+ if(ancestors1.Extent() == ancestors2.Extent() && ancestors1.Extent() > 1) {
+ int aNum (ancestors2.Extent());
+ TopTools_ListIteratorOfListOfShape it(ancestors2);
+ for(;it.More();it.Next())
+ if(aMap1.Contains(it.Value())) aNum--;
+ if(aNum == 0) {
+ if(aMap2.Add(aKeyEdge1))
+ aKeyList.Append(aKeyEdge1);
+ if(aMap2.Add(aKeyEdge2))
+ aKeyList.Append(aKeyEdge2);
+ }
+ }
+ } // at the end ==> List of edges to be named in addition
+ }
+ aNumEdges = aKeyList.Extent();
+ if(aNumEdges)
+ theList.Assign(aKeyList);
+ return aNumEdges;
+}
+
//=======================================================================
void Model_ResultBody::loadFirstLevel(
std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag)
itrShape->setImpl(new TopoDS_Shape(aShape));
loadNextLevels(itrShape, theName, theTag);
}
+ TopTools_ListOfShape aList;
+ if(findAmbiguities(aShape, aList)) {
+ TopTools_ListIteratorOfListOfShape it(aList);
+ for (; it.More(); it.Next(),theTag++) {
+ builder(theTag)->Generated(it.Value());
+ TCollection_AsciiString aStr(theTag);
+ aName = theName + aStr.ToCString();
+ buildName(theTag, aName);
+ }
+ }
}
//=======================================================================
{
registerValidators();
registerFilters();
+ registerProperties();
Config_ModuleReader aXMLReader = Config_ModuleReader();
aXMLReader.readAll();
/// Register selection filters for this module\r
virtual void registerFilters() {}\r
\r
+ /// Register properties of this module\r
+ virtual void registerProperties() {}\r
+\r
/// Returns new instance of operation object (used in createOperation for customization)\r
virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);\r
\r
/// Update current viewer
virtual void update() = 0;
+ /// Method returns True if the viewer can process editing objects
+ /// by mouse drugging. If this is impossible thet it has to return False.
+ virtual bool canDragByMouse() const { return true; }
+
signals:
/// Signal emited when last view window is closed
void lastViewClosed();
{
OCCViewer_ViewWindow* aViewWnd = dynamic_cast<OCCViewer_ViewWindow*>(theView);
Handle(AIS_InteractiveContext) aContext = AISContext();
- if (aContext->HasDetected())
+ if (aContext->HasDetected()) // Set focus to provide key events in the view
aViewWnd->getViewPort()->setFocus(Qt::MouseFocusReason);
emit mouseMove(myView, theEvent);
}
+//**********************************************
+bool NewGeom_SalomeViewer::canDragByMouse() const
+{
+ OCCViewer_Viewer* aViewer = mySelector->viewer();
+ return (aViewer->interactionStyle() != 0);
+}
+
+
//**********************************************
void NewGeom_SalomeViewer::onKeyPress(SUIT_ViewWindow* theView, QKeyEvent* theEvent)
{
/// Update current viewer
virtual void update();
+ /// Method returns True if the viewer can process editing objects
+ /// by mouse drugging. If this is impossible thet it has to return False.
+ virtual bool canDragByMouse() const;
private slots:
void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
//#include <SketchPlugin_ConstraintRigid.h>
#include <Events_Loop.h>
+#include <Config_PropManager.h>
#include <StdSelect_TypeOfFace.hxx>
#include <TopoDS_Vertex.hxx>
new ModuleBase_FilterCustom(aSelectFilter));
}
+void PartSet_Module::registerProperties()
+{
+ Config_PropManager::registerProp("Sketch planes", "planes_size", "Size", Config_Prop::Double,
+ PLANE_SIZE);
+ Config_PropManager::registerProp("Sketch planes", "planes_thickness", "Thickness",
+ Config_Prop::Integer, SKETCH_WIDTH);
+}
+
void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation)
{
if (theOperation->isEditOperation())
/// Register selection filters for this module
virtual void registerFilters();
+ /// Register properties of this module
+ virtual void registerProperties();
+
private slots:
/// Processing of vertex selected
void onVertexSelected();
if (!(theEvent->buttons() & Qt::LeftButton))
return;
+ // Clear dragging mode
+ myIsDragging = false;
+
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ ModuleBase_IViewer* aViewer = aWorkshop->viewer();
+ if (!aViewer->canDragByMouse())
+ return;
+
ModuleBase_Operation* aOperation = aWorkshop->currentOperation();
if (aOperation && aOperation->isEditOperation()) {
ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
}
}
- // Clear dragging mode
- myIsDragging = false;
-
// Use only for sketch operations
if (aOperation && myCurrentSketch) {
if (!PartSet_Tools::sketchPlane(myCurrentSketch))
return;
// MoveTo in order to highlight current object
- ModuleBase_IViewer* aViewer = aWorkshop->viewer();
aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
// Remember highlighted objects for editing
void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ ModuleBase_IViewer* aViewer = aWorkshop->viewer();
+ if (!aViewer->canDragByMouse())
+ return;
ModuleBase_Operation* aOp = aWorkshop->currentOperation();
if (aOp) {
if (sketchOperationIdList().contains(aOp->id())) {
get2dPoint(theWnd, theEvent, myClickedPoint);
// Only for sketcher operations
- ModuleBase_IViewer* aViewer = aWorkshop->viewer();
if (myIsDragging) {
if (myDragDone) {
//aOp->commit();
#include <QTimer>
#include <QApplication>
-#define PLANE_SIZE "200"
-#define SKETCH_WIDTH "4"
PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
std::shared_ptr<GeomAPI_Dir> theNorm,
const int theRGB[3])
{
- double aSize = Config_PropManager::integer("Sketch planes", "Size of planes", PLANE_SIZE);
+ double aSize = Config_PropManager::integer("Sketch planes", "planes_size", PLANE_SIZE);
std::shared_ptr<GeomAPI_Shape> aFace = GeomAlgoAPI_FaceBuilder::square(theOrigin, theNorm, aSize);
AISObjectPtr aAIS = AISObjectPtr(new GeomAPI_AISObject());
aAIS->createShape(aFace);
class XGUI_OperationMgr;
class XGUI_Workshop;
+/// the plane edge width
+#define SKETCH_WIDTH "4"
+
+/// face of the square-face displayed for selection of general plane
+#define PLANE_SIZE "200"
+
/**
* \ingroup Modules
* A model widget implementation for a label which provides specific behaviour
if (!aConst)
return thePrevious;
+
+ std::shared_ptr<SketchPlugin_Feature> aSketchFea =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(ModelAPI_Feature::feature(aConst));
+ if (aSketchFea.get() != NULL) {
+ if (aSketchFea->isExternal())
+ return thePrevious;
+ }
aShape = aConst->shape();
}
else {
{
AttributeSelectionPtr aAttr = data()->selection(EXTERNAL_ID());
if (aAttr)
- return aAttr->context().get() == NULL;
+ return aAttr->context().get() != NULL;
return false;
}
virtual void customisePresentation(AISObjectPtr thePrs)
{
// if this is an edge
- if (thePrs->getShapeType() == 6)
+ if (thePrs->getShapeType() == 6) {
thePrs->setWidth(3);
+ if (isExternal())
+ thePrs->setColor(0,255,0);
+ }
// if this is a vertex
//else if (thePrs->getShapeType() == 7)
// thePrs->setPointMarker(6, 2.);
ModelAPI_Session::get()->registerPlugin(this);
// register sketcher properties
- Config_PropManager::registerProp("Sketch planes", "planes_color", "Color", Config_Prop::Color,
- SKETCH_PLANE_COLOR);
- Config_PropManager::registerProp("Sketch planes", "planes_size", "Size", Config_Prop::Double,
- PLANE_SIZE);
- Config_PropManager::registerProp("Sketch planes", "planes_thickness", "Thickness",
- Config_Prop::Integer, SKETCH_WIDTH);
Config_PropManager::registerProp("Visualization", "parallel_color", "Parallel constraint color",
Config_Prop::Color, PARALLEL_COLOR);
#include <GeomAPI_IPresentable.h>
#include <list>
-/// the plane edge color
-#define SKETCH_PLANE_COLOR "#700000"
-
-/// the plane edge width
-#define SKETCH_WIDTH "4"
-
-/// face of the square-face displayed for selection of general plane
-#define PLANE_SIZE "200"
-
/**\class SketchPlugin_Sketch
* \ingroup Plugins
* \brief Feature for creation of the new part in PartSet.
void connectViewer() const;
/// Add menu atems for viewer into the given menu (used in SALOME mode)
- /// \param a popup menu to be shown in the viewer
+ /// \param theMenu a popup menu to be shown in the viewer
void addViewerItems(QMenu* theMenu) const;
signals:
{
myWorkshop->displayer()->updateViewer();
}
+
+//***************************************
+bool XGUI_ViewerProxy::canDragByMouse() const
+{
+ if (myWorkshop->isSalomeMode()) {
+ ModuleBase_IViewer* aViewer = myWorkshop->salomeConnector()->viewer();
+ return aViewer->canDragByMouse();
+ } else {
+ return true;
+ }
+}
\ No newline at end of file
/// Update current viewer
virtual void update();
+ /// Method returns True if the viewer can process editing objects
+ /// by mouse drugging. If this is impossible thet it has to return False.
+ virtual bool canDragByMouse() const;
+
private slots:
void onTryCloseView(AppElements_ViewWindow*);
void onDeleteView(AppElements_ViewWindow*);