# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
-FIND_PROGRAM(DOXYGEN_EXECUTABLE Doxygen)
+IF (WIN32)
+ FIND_PROGRAM(DOXYGEN_EXECUTABLE Doxygen)
+ELSE (WIN32)
+ FIND_PROGRAM(DOXYGEN_EXECUTABLE doxygen)
+ENDIF(WIN32)
CONFIGURE_FILE(doxyfile.in
"${CMAKE_CURRENT_BINARY_DIR}/doxyfile"
IMMEDIATE @ONLY)
-ADD_CUSTOM_TARGET(usr_docs ${DOXYGEN_EXECUTABLE})
-
-INSTALL(CODE "EXECUTE_PROCESS(COMMAND \"${CMAKE_COMMAND}\" --build ${PROJECT_BINARY_DIR} --target usr_docs)")
-INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tui DESTINATION doc)
+ADD_CUSTOM_TARGET(INSTALL_DOCS
+ COMMAND "${DOXYGEN_EXECUTABLE}"
+ COMMAND "${CMAKE_COMMAND}" --build "${PROJECT_BINARY_DIR}" --target install
+ WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/doc"
+)
+INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tui DESTINATION doc OPTIONAL)
// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-/*
- *
- */
#include "Config_AttributeMessage.h"
Config_AttributeMessage::Config_AttributeMessage(const Events_ID theId, const void* theParent)
#include <string>
-/*
- * Class to pass an attribute's (widget's) entry info extracted from xml file.
+/*!
+ * \class Config_AttributeMessage
+ * \brief Class to pass an attribute's (widget's) entry info extracted from xml file.
* <widget id="tool_object" concealment="true" obligatory="0"/>
*/
class Config_AttributeMessage : public Events_Message
struct _xmlDoc;
//<<
-/*
+/*!
* Returns true if theNode is XML ELEMENT node (not a "text" node ie).
*/
CONFIG_EXPORT bool isElementNode(xmlNodePtr theNode);
-/*
+/*!
* Returns true if theNode is XML node with a given name.
* Please note that this function should be called with NULL last argument.
*/
CONFIG_EXPORT bool isNode(xmlNodePtr theNode, const char* theNodeName, ...);
-/*
+/*!
* Checks is the given node is attribute (widget) node.
*/
CONFIG_EXPORT bool isWidgetNode(xmlNodePtr theNode);
-/*
+/*!
* Every xml node has child. Even if there is no explicit
* child nodes libxml gives the "Text node" as child.
*
*/
CONFIG_EXPORT bool hasChild(xmlNodePtr theNode);
-/*
+/*!
* Returns named property for an id node as std::string and the parameters of the node.
*/
CONFIG_EXPORT bool getParametersInfo(xmlNodePtr theNode, std::string& outPropertyId,
*/
CONFIG_EXPORT std::string library(const std::string& theLibName);
-/*
+/*!
* Returns named property for a given node as std::string.
*/
CONFIG_EXPORT std::string getProperty(xmlNodePtr theNode, const char* thePropName);
-/*
+/*!
* Checks if the given XML node has the given attribute,
* if yes - returns it's bool value, if no, or if the value can not
* be converted to bool - returns theDefault value.
const char* theAttributeName,
bool theDefault);
-/*
+/*!
* Returns normalized (lower case) version of string.
* Should be used for case insensitive string matching.
*/
// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-/*
- *
- */
#include "Config_FeatureMessage.h"
Config_FeatureMessage::Config_FeatureMessage(const Events_ID theId, const void* theParent)
\r
#include <string>\r
\r
-/*\r
- * Class to pass a feature entry extracted from xml file.\r
+/*!\r
+ * \class Config_FeatureMessage\r
+ * \brief Class to pass a feature entry extracted from xml file.\r
* Example of the feature entry:\r
* <feature id="Part" text="New part" tooltip="Creates a new part" icon=":pictures/part_ico.png"/>\r
*/\r
class Config_FeatureMessage;
+/*!
+ * \class Config_FeatureReader
+ * \brief Class to process feature's xml definition.
+ */
class Config_FeatureReader : public Config_XMLReader
{
public:
- Config_FeatureReader(const std::string& theXmlFile, const std::string& theLibraryName,
+ Config_FeatureReader(const std::string& theXmlFile,
+ const std::string& theLibraryName,
const char* theEventGenerated = 0);
virtual ~Config_FeatureReader();
-
+ /// Returns list of all features defined in reader's file
std::list<std::string> features() const;
protected:
- void processNode(xmlNodePtr aNode);
- bool processChildren(xmlNodePtr aNode);
+ /// Overloaded method. Defines how to process each node
+ virtual void processNode(xmlNodePtr aNode);
+ /// Overloaded method. Defines if the given node should be parsed recursively
+ virtual bool processChildren(xmlNodePtr aNode);
+ /// Fills feature message
void fillFeature(xmlNodePtr theRoot,
const std::shared_ptr<Config_FeatureMessage>& outFeatureMessage);
+ /// Stores an attribute in internal map for later use.
+ /// Key is "Node_Name:Node_Attribute" and value is getProperty(theNodeAttribute)
void storeAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+ /// Restores an attribute from internal map.
std::string restoreAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+ /// Restores an attribute from internal map.
std::string restoreAttribute(const char* theNodeName, const char* theNodeAttribute);
private:
return myFeaturesInFiles;
}
-/*
+/*!
* Get module name from plugins.xml
* (property "module")
*/
return getProperty(aRoot, PLUGINS_MODULE);
}
-/*
- *
- */
void Config_ModuleReader::processNode(xmlNodePtr theNode)
{
if (isNode(theNode, NODE_PLUGIN, NULL)) {
#include <set>
#include <string>
+/*!
+ * \class Config_ModuleReader
+ * \brief Class to process plugins.xml - definition of plugins (scripts, libraries).
+ */
class Config_ModuleReader : public Config_XMLReader
{
enum PluginType {
#include <Config_def.h>
#include <Events_Message.h>
-/*
- * A general class to pass pointers over the event loop.
+/*!
+ * \class Config_PointerMessage
+ * \brief A general class to pass pointers over the event loop.
*/
class CONFIG_EXPORT Config_PointerMessage : public Events_Message
{
#include <string>
#include <vector>
-//! Class wihich let to register properties
+//! Class which let to register properties
class Config_PropManager
{
public:
/// Event ID that Selection Filter is loaded (comes with Config_SelectionFilterMessage)
static const char * EVENT_SELFILTER_LOADED = "SelectionFilterLoaded";
+/*!
+ * \class Config_SelectionFilterMessage
+ * \brief Transmits info about selection filters on "SelectionFilterLoaded" event
+ */
class Config_SelectionFilterMessage : public Events_Message
{
std::string mySelectionFilterId;
/// Event ID that Validator is loaded (comes with Config_ValidatorMessage)
static const char * EVENT_VALIDATOR_LOADED = "ValidatorLoaded";
+/*!
+ * \class Config_ValidatorMessage
+ * \brief Transmits info about created validator on "ValidatorLoaded" event
+ */
class Config_ValidatorMessage : public Events_Message
{
std::string myValidatorId;
struct _xmlDoc;
//<<
+/*!
+ * \class Config_WidgetAPI
+ * \brief Provides low-level API for WidgetFactory for reading xml definitions of widgets
+ */
class CONFIG_EXPORT Config_WidgetAPI
{
public:
#include <map>
#include <string>
+/*!
+ * \class Config_WidgetReader
+ * \brief Class that dumps xml definitions of widgets for
+ * further processing in the WidgetFactory
+ */
class Config_WidgetReader : public Config_XMLReader
{
public:
- CONFIG_EXPORT Config_WidgetReader(const std::string& theXmlFile);CONFIG_EXPORT virtual ~Config_WidgetReader();
+ CONFIG_EXPORT Config_WidgetReader(const std::string& theXmlFile);
+ CONFIG_EXPORT virtual ~Config_WidgetReader();
- CONFIG_EXPORT std::string featureWidgetCfg(const std::string& theFeatureName);CONFIG_EXPORT std::string featureDescription(
- const std::string& theFeatureName);
+ CONFIG_EXPORT std::string featureWidgetCfg(const std::string& theFeatureName);
+ CONFIG_EXPORT std::string featureDescription(const std::string& theFeatureName);
protected:
void processNode(xmlNodePtr theNode);
xmlFreeDoc(myXmlDoc);
}
-/*
+/*!
* Read all nodes in associated xml file,
* recursively if processChildren(xmlNode) is true for the xmlNode.
* For each read node the processNode will be called.
readRecursively(aRoot);
}
-/*
+/*!
* Allows to customize reader's behavior for a node. Virtual.
* The default impl does nothing. (In debug mode prints
* some info)
}
}
-/*
+/*!
* Defines which nodes should be processed recursively. Virtual.
* The default impl is to read all nodes.
*/
return true;
}
-/*
- *
+/*!
+ * Returns xmlNodePtr to the root of reader's document
+ * or NULL if not found
*/
xmlNodePtr Config_XMLReader::findRoot()
{
return aRoot;
}
-/*
+/*!
* Calls processNode() for each child (for some - recursively)
* of the given node.
* \sa ReadAll()
}
}
-/*
+/*!
* void* -> xmlNodePtr
*/
xmlNodePtr Config_XMLReader::node(void* theNode)
return static_cast<xmlNodePtr>(theNode);
}
+/*!
+ * Gets xml node name
+ */
std::string Config_XMLReader::getNodeName(xmlNodePtr theNode)
{
std::string result = "";
return result;
}
+/*!
+ * Retrieves all the necessary info from the validator node.
+ * Sends ValidatorLoaded event
+ */
void Config_XMLReader::processValidator(xmlNodePtr theNode)
{
Events_ID aValidatoEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED);
aEvLoop->send(aMessage);
}
+/*!
+ * Retrieves all the necessary info from the SelectionFilter node.
+ * Sends SelectionFilterLoaded event
+ */
void Config_XMLReader::processSelectionFilter(xmlNodePtr theNode)
{
Events_ID aFilterEvent = Events_Loop::eventByName(EVENT_SELFILTER_LOADED);
struct _xmlDoc;
//<<
-/*
- * Base class for all libxml readers. Provides high-level API
+/*!
+ * \class Config_XMLReader
+ * \brief Base class for all libxml readers. Provides high-level API
* for all xml operations.
- *
- */
+*/
class Config_XMLReader
{
public:
- CONFIG_EXPORT Config_XMLReader(const std::string& theXmlFile);CONFIG_EXPORT virtual ~Config_XMLReader();
+ CONFIG_EXPORT Config_XMLReader(const std::string& theXmlFile);
+ CONFIG_EXPORT virtual ~Config_XMLReader();
CONFIG_EXPORT void readAll();
return False
def initAttributes(self):
- # This feature has no attributes, but should perfore some actions on initialization
+ # This feature has no attributes, but should perform some actions on initialization
aSession = ModelAPI.ModelAPI_Session.get()
- aPart = aSession.activeDocument()
+ self.Part = aSession.activeDocument()
+ self.geomObjects = []
+ self.geompy = geomBuilder.New(salome.myStudy)
+
+ # Export bodies and groups
+ self.exportBodies()
+ self.exportGroups()
+
+ def exportBodies(self):
# Get all bodies
kResultBodyType = "Bodies"
- aPartSize = aPart.size(kResultBodyType)
+ aPartSize = self.Part.size(kResultBodyType)
if aPartSize == 0:
EventsAPI.Events_Error_send("No results in the active document")
return
-
- anObjList = [aPart.object(kResultBodyType, idx) for idx in xrange(aPartSize)]
+
+ anObjList = [self.Part.object(kResultBodyType, idx) for idx in xrange(aPartSize)]
for idx, anObject in enumerate(anObjList):
aResult = ModelAPI.modelAPI_Result(anObject)
aBodyResult = ModelAPI.modelAPI_ResultBody(aResult)
aShape = aBodyResult.shape()
aDump = aShape.getShapeStream()
# Load shape to SALOME Geom
- geompy = geomBuilder.New(salome.myStudy)
- aBrep = geompy.RestoreShape(aDump)
- geompy.addToStudy(aBrep, "NewGeomShape_{0}".format(idx))
+ aBrep = self.geompy.RestoreShape(aDump)
+ self.geompy.addToStudy(aBrep, "NewGeomShape_{0}".format(idx + 1))
+ self.geomObjects.append([aShape, aBrep])
+
+ def exportGroups(self):
+ # iterate all features to find groups
+ aFeaturesNum = self.Part.size("Features")
+ groupIndex = 0
+ for anIndex in range(0, aFeaturesNum):
+ aFeature = self.Part.object("Features", anIndex)
+ aSelectionList = aFeature.data().selectionList("group_list")
+ # if a group has been found
+ if aSelectionList:
+ groupIndex = groupIndex + 1
+ self.createGroupFromList(aSelectionList, "NewGeomGroup_{0}".format(groupIndex))
+
+ def createGroupFromList(self, theSelectionList, theGroupName):
+ # iterate on all selected entities of the group
+ # and get the corresponding ID
+ aSelectionNum = theSelectionList.size()
+ Ids = []
+ for aSelIndex in range(0, aSelectionNum):
+ aSelection = theSelectionList.value(aSelIndex)
+ aSelectionContext = aSelection.context()
+ anID = aSelection.Id()
+ Ids.append(anID)
+ if aSelection.value().isVertex():
+ groupType = "VERTEX"
+ elif aSelection.value().isEdge():
+ groupType = "EDGE"
+ elif aSelection.value().isFace():
+ groupType = "FACE"
+ else:
+ groupType = "SOLID"
+ # iterate on exported objects and check if the current
+ # group refers to this object
+ for obj in self.geomObjects:
+ if aSelectionContext.shape().isEqual(obj[0]):
+ aGroup = self.geompy.CreateGroup(obj[1], self.geompy.ShapeType[groupType])
+ self.geompy.UnionIDs(aGroup,Ids)
+ self.geompy.addToStudyInFather(obj[1], aGroup, theGroupName)
+
def execute(self):
# Nothing to execute: all logic would be in the initAttributes
pass
<feature
id="ExportToGEOM"
title="Export to GEOM"
- tooltip="Export all bodies into GEOM module"
+ tooltip="Export all bodies and groups into GEOM module"
icon=":icons/geom_export.png"/>
</group>
</workbench>
}
}
+
+int Model_AttributeSelection::Id()
+{
+ std::shared_ptr<GeomAPI_Shape> aSelection = value();
+ std::shared_ptr<GeomAPI_Shape> aContext = context()->shape();
+ const TopoDS_Shape& aMainShape = aContext->impl<TopoDS_Shape>();
+ const TopoDS_Shape& aSubShape = aSelection->impl<TopoDS_Shape>();
+ int anID = 0;
+ if (aSelection && !aSelection->isNull() &&
+ aContext && !aContext->isNull())
+ {
+ TopTools_IndexedMapOfShape aSubShapesMap;
+ TopExp::MapShapes(aMainShape, aSubShapesMap);
+ anID = aSubShapesMap.FindIndex(aSubShape);
+ }
+ return anID;
+}
/// Returns a textual string of the selection
MODEL_EXPORT virtual std::string namingName();
+
+ /// Returns an Id of the selection
+ /// NOTE: This method has been added for temporary export of groups towards old GEOM
+ /// It should then be removed when a direct use of objects from NewGeom
+ /// will be possible from SMESH module of SALOME.
+ MODEL_EXPORT virtual int Id();
/// Selects (i.e. creates Naming data structure) of sub-shape specifed by textual name
MODEL_EXPORT virtual void selectSubShape(const std::string& theType, const std::string& theSubShapeName);
// returns all objects referenced to this
MODEL_EXPORT virtual const std::set<AttributePtr>& refsToMe() {return myRefsToMe;}
+ // returns all references by attributes of this data
+ // \param theRefs returned list of pairs: id of referenced attribute and list of referenced objects
+ MODEL_EXPORT virtual void referencesToObjects(
+ std::list<std::pair<std::string, std::list<ObjectPtr> > >& theRefs);
+
private:
// removes all information about back references
void eraseBackReferences();
// adds a back reference (with identifier which attribute references to this object
void addBackReference(FeaturePtr theFeature, std::string theAttrID);
- // returns all references by attributes of this data
- // \param the returned list of pairs: id of referenced attribute and list of referenced objects
- void referencesToObjects(std::list<std::pair<std::string, std::list<ObjectPtr> > >& theRefs);
};
#endif
{
if (!myNestedNum.empty() && !myDoc->HasOpenCommand()) { // abort all what was done in nested
compactNested();
- undo();
+ undoInternal(false);
myDoc->ClearRedos();
myRedos.clear();
} else { // abort the current
return false;
}
-void Model_Document::undo()
+void Model_Document::undoInternal(const bool theWithSubs)
{
int aNumTransactions = *myTransactions.rbegin();
myTransactions.pop_back();
for(int a = 0; a < aNumTransactions; a++)
myDoc->Undo();
- synchronizeFeatures(true, true);
- // undo for all subs
- const std::set<std::string> aSubs = subDocuments(true);
- std::set<std::string>::iterator aSubIter = aSubs.begin();
- for (; aSubIter != aSubs.end(); aSubIter++)
- subDoc(*aSubIter)->undo();
+ if (theWithSubs) {
+ synchronizeFeatures(true, true);
+ // undo for all subs
+ const std::set<std::string> aSubs = subDocuments(true);
+ std::set<std::string>::iterator aSubIter = aSubs.begin();
+ for (; aSubIter != aSubs.end(); aSubIter++)
+ subDoc(*aSubIter)->undo();
+ }
+}
+
+void Model_Document::undo()
+{
+ undoInternal(true);
}
bool Model_Document::canRedo()
//! Returns all sub documents
const std::set<std::string> subDocuments(const bool theActivatedOnly) const;
+ //! The implementation of undo: with or without recoursive calls in the sub-documents
+ void undoInternal(const bool theWithSubs);
+
friend class Model_Application;
friend class Model_Session;
friend class Model_Update;
/// Returns a textual string of the selection
virtual std::string namingName() = 0;
+
+ /// Returns an id of the selection
+ virtual int Id() = 0;
/// Selects sub-shape by the textual Name
class ModelAPI_Feature;
class ModelAPI_AttributeSelection;
class ModelAPI_AttributeSelectionList;
+class ModelAPI_Object;
class GeomAPI_Shape;
/// Enumeration that contains the execution status of the Object
// returns all objects referenced to this
virtual const std::set<std::shared_ptr<ModelAPI_Attribute> >& refsToMe() = 0;
+ // returns all references by attributes of this data
+ // \param theRefs returned list of pairs: id of referenced attribute and list of referenced objects
+ virtual void referencesToObjects(
+ std::list<std::pair<std::string, std::list<std::shared_ptr<ModelAPI_Object> > > >& theRefs) = 0;
protected:
/// Objects are created for features automatically
ModelAPI_Data()
if (aWirePtr->hasPlane() ) {
// If this is a wire with plane defined thin it is a sketch-like object
// It must have invisible faces
- GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
- aWirePtr->dirY(), aWirePtr->norm(), aWirePtr, myFacesList);
-
- myOriginalShape = aWirePtr->impl<TopoDS_Shape>();
- Set(myOriginalShape);
myIsSketchMode = true;
- } else {
- Set(aWirePtr->impl<TopoDS_Shape>());
}
- } else {
- Set(aShapePtr->impl<TopoDS_Shape>());
}
+ Set(aShapePtr->impl<TopoDS_Shape>());
}
std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
if (!aShapePtr)
return;
+ if (myIsSketchMode) {
+ std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr =
+ std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapePtr);
+ myFacesList.clear();
+ GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
+ aWirePtr->dirY(), aWirePtr->norm(), aWirePtr, myFacesList);
+ }
myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
if (!myOriginalShape.IsNull()) {
Set(aShapePtr->impl<TopoDS_Shape>());
// because the displayed objects should be removed from the viewer, but
// the AIS context is obtained from the selector.
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
- if (anOperation)
+ while (anOperation) {
anOperation->abort();
-
+ anOperation = myWorkshop->operationMgr()->currentOperation();
+ }
// Delete selector because it has to be redefined on next activation
if (mySelector) {
myProxyViewer->setSelector(0);
//**********************************************
void NewGeom_SalomeViewer::enableSelection(bool isEnabled)
{
- //mySelector->viewer()->enableSelection(isEnabled);
+ if (mySelector)
+ mySelector->viewer()->enableSelection(isEnabled);
// The enableSelection() in SALOME 7.5 cause of forced Viewer update(we have blinking)
// After this is corrected, the first row should be recommented, the last - removed
- if (mySelector)
- mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
- : SUIT_ViewModel::KEY_FREE);
+ //mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
+ // : SUIT_ViewModel::KEY_FREE);
}
//**********************************************
if (!(theEvent->buttons() & Qt::LeftButton))
return;
+ // Clear dragging mode
+ myIsDragging = false;
+
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
ModuleBase_Operation* aOperation = aWorkshop->currentOperation();
// Use only for sketch operations
if (isSketcher) {
myIsDragging = true;
-
get2dPoint(theWnd, theEvent, myCurX, myCurY);
myDragDone = false;
launchEditing();
{
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
ModuleBase_Operation* aOp = aWorkshop->currentOperation();
- if (!aOp)
- return;
- if (!sketchOperationIdList().contains(aOp->id()))
- return;
-
- // Only for sketcher operations
- ModuleBase_IViewer* aViewer = aWorkshop->viewer();
- if (myIsDragging) {
- aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
- myIsDragging = false;
- if (myDragDone) {
- //aOp->commit();
- myFeature2AttributeMap.clear();
-
- // Reselect edited object
- /*aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
- if (theEvent->modifiers() & Qt::ShiftModifier)
- aViewer->AISContext()->ShiftSelect();
- else
- aViewer->AISContext()->Select();
- */
- return;
+ if (aOp) {
+ if (sketchOperationIdList().contains(aOp->id())) {
+ // Only for sketcher operations
+ ModuleBase_IViewer* aViewer = aWorkshop->viewer();
+ if (myIsDragging) {
+ if (myDragDone) {
+ //aOp->commit();
+ myFeature2AttributeMap.clear();
+
+ // Reselect edited object
+ /*aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
+ if (theEvent->modifiers() & Qt::ShiftModifier)
+ aViewer->AISContext()->ShiftSelect();
+ else
+ aViewer->AISContext()->Select();
+ */
+ }
+ }
}
}
+ aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
+ myIsDragging = false;
}
void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
aViewer->enableSelection(false);
ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation();
+ if (!aOperation)
+ return;
if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID())
return; // No edit operation activated
#include <ModelAPI_AttributeRefAttr.h>
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_Object.h>
#include <SketchPlugin_Sketch.h>
const std::list<std::string>& theArguments,
const AttributePtr& theAttribute) const
{
- // not implemented
- return true;
+ return PartSet_DifferentObjectsValidator::isValid(theAttribute, theArguments);
}
bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments) const
{
- // not implemented
+ std::list<std::pair<std::string, std::list<ObjectPtr> > > allRefs;
+ if (theAttribute->owner().get() && theAttribute->owner()->data().get())
+ theAttribute->owner()->data()->referencesToObjects(allRefs);
+ // collect object referenced by theAttribute
+ std::list<ObjectPtr>* anAttrObjs = 0;
+ std::list<std::pair<std::string, std::list<ObjectPtr> > >::iterator aRefIter = allRefs.begin();
+ for(; aRefIter != allRefs.end(); aRefIter++) {
+ if (theAttribute->id() == aRefIter->first)
+ anAttrObjs = &(aRefIter->second);
+ }
+ if (!anAttrObjs || anAttrObjs->empty())
+ return true; // theAttribute does not references to anything
+ // check with all others
+ for(aRefIter = allRefs.begin(); aRefIter != allRefs.end(); aRefIter++) {
+ if (theAttribute->id() == aRefIter->first)
+ continue; // do not check with myself
+ std::list<ObjectPtr>::iterator aReferenced = aRefIter->second.begin();
+ for(; aReferenced != aRefIter->second.end(); aReferenced++) {
+ std::list<ObjectPtr>::iterator aReferencedByMe = anAttrObjs->begin();
+ for(; aReferencedByMe != anAttrObjs->end(); aReferencedByMe++) {
+ if (*aReferenced == *aReferencedByMe) // found same objects!
+ return false;
+ }
+ }
+ }
return true;
}
std::shared_ptr<GeomDataAPI_Point2D> aAttrPnt =
PartSet_Tools::findAttributePoint(mySketch, aX, anY, aTolerance, aIgnore);
if (aAttrPnt.get() != NULL) {
-
+ aFeaturePoint->setValue(aAttrPnt->pnt());
PartSet_Tools::createConstraint(mySketch, aAttrPnt, aFeaturePoint);
emit vertexSelected();
}
void PartSet_WidgetSketchLabel::setSketchingMode()
{
- qDebug("### Set sketching mode");
-
XGUI_Displayer* aDisp = myWorkshop->displayer();
// Clear standard selection modes if they are defined
//aDisp->activateObjects(aModes);
closeLocalContexts(false);
}
aContext->Display(anAISIO, false);
- qDebug("### Display %i", (long)anAISIO.Access());
aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, false);
// Customization of presentation
AISObjectPtr anObj = myResult2AISObjectMap[theObject];
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
aContext->Deactivate(anAIS);
- qDebug("### Deactivate obj %i", (long)anAIS.Access());
}
}
foreach(int aMode, theModes) {
//aContext->Load(anAIS, aMode, true);
aContext->Activate(anAIS, aMode);
- qDebug("### 1. Activate obj %i, %i", (long)anAIS.Access(), aMode);
}
} else {
//aContext->Load(anAIS, 0, true);
aContext->Activate(anAIS);
- qDebug("### 2. Activate obj %i", (long)anAIS.Access());
}
}
}
if (myActiveSelectionModes.size() == 0) {
//aContext->Load(anAISIO, 0, true);
aContext->Activate(anAISIO);
- qDebug("### 2. Activate all %i", (long)anAISIO.Access());
} else {
foreach(int aMode, myActiveSelectionModes) {
//aContext->Load(anAISIO, aMode, true);
aContext->Activate(anAISIO, aMode);
- qDebug("### 1. Activate all %i, %i", (long)anAISIO.Access(), aMode);
}
}
}
for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
anAISIO = aLIt.Value();
aContext->Deactivate(anAISIO);
- //aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
- //if (aTrihedron.IsNull()) {
- // qDebug("### Deactivate all %i", (long)anAISIO.Access());
- // //aContext->Activate(anAISIO);
- //}
}
}
//aContext->ClearCurrents();
aContext->OpenLocalContext();
- qDebug("### Open context");
//aContext->NotUseDisplayedObjects();
//myUseExternalObjects = false;
//aContext->ClearSelected();
aContext->CloseAllContexts(false);
- qDebug("### Close context");
// Redisplay all object if they were displayed in localContext
Handle(AIS_InteractiveObject) aAISIO;
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
if ((!aContext.IsNull()) && (!aContext->HasOpenedContext())) {
aContext->OpenLocalContext();
- qDebug("### Open context");
}
return aContext;
}
myObjectBrowser->activatePart(theFeature);
myPartActivating = false;
}
+ updateCommandStatus();
}
//**************************************************************
//**************************************************************
void XGUI_Workshop::closeDocument()
{
+ ModuleBase_Operation* anOperation = operationMgr()->currentOperation();
+ while (anOperation) {
+ anOperation->abort();
+ anOperation = operationMgr()->currentOperation();
+ }
myDisplayer->closeLocalContexts();
myDisplayer->eraseAll();
objectBrowser()->clearContent();