outFeatureMessage->setKeysequence(getProperty(theNode, FEATURE_KEYSEQUENCE));
outFeatureMessage->setGroupId(restoreAttribute(NODE_GROUP, _ID));
outFeatureMessage->setWorkbenchId(restoreAttribute(NODE_WORKBENCH, _ID));
- outFeatureMessage->setDocumentKind(restoreAttribute(NODE_WORKBENCH, WORKBENCH_DOC));
+ // Get document kind of a feature, if empty set workbench's kind (might be empty too)
+ std::string aDocKind = getProperty(theNode, WORKBENCH_DOC);
+ if(aDocKind.empty()) {
+ aDocKind = restoreAttribute(NODE_WORKBENCH, WORKBENCH_DOC);
+ }
+ outFeatureMessage->setDocumentKind(aDocKind);
}
void Config_FeatureReader::storeAttribute(xmlNodePtr theNode,
{
if (!myFlushActive)
return;
- std::map<char*, std::shared_ptr<Events_Message>>::iterator aMyGroup =
- myGroups.find(theID.eventText());
- if (aMyGroup != myGroups.end()) { // really sends
- myFlushed.insert(theID.myID);
+ std::map<char*, std::shared_ptr<Events_Message> >::iterator aMyGroup;
+ for(aMyGroup = myGroups.find(theID.eventText());
+ aMyGroup != myGroups.end(); aMyGroup = myGroups.find(theID.eventText()))
+ { // really sends
+ bool aWasFlushed = myFlushed.find(theID.myID) != myFlushed.end();
+ if (!aWasFlushed)
+ myFlushed.insert(theID.myID);
std::shared_ptr<Events_Message> aGroup = aMyGroup->second;
myGroups.erase(aMyGroup);
send(aGroup, false);
- myFlushed.erase(myFlushed.find(theID.myID));
+ if (!aWasFlushed)
+ myFlushed.erase(myFlushed.find(theID.myID));
}
}
else
myFlushed.erase(myFlushed.find(theID.myID));
}
+
+bool Events_Loop::isFlushed(const Events_ID& theID)
+{
+ return myFlushed.find(theID.myID) != myFlushed.end();
+}
+
+void Events_Loop::setFlushed(const Events_ID& theID, const bool theValue)
+{
+ if (theValue)
+ myFlushed.insert(theID.myID);
+ else
+ myFlushed.erase(myFlushed.find(theID.myID));
+}
//! Enables flush without grouping for the given message
EVENTS_EXPORT void autoFlush(const Events_ID& theID, const bool theAuto = true);
+
+ //! Returns true if the evement is flushed right now
+ EVENTS_EXPORT bool isFlushed(const Events_ID& theID);
+ //! Sets the flag that the event is flished right now
+ EVENTS_EXPORT void setFlushed(const Events_ID& theID, const bool theValue);
};
#endif
void Model_Update::redisplayWithResults(FeaturePtr theFeature, const ModelAPI_ExecState theState)
{
- // maske updated and redisplay all results
+ // make updated and redisplay all results
static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
if (isValid(aObject, aShape)) {
setObject(aObject, aShape);
emit focusOutWidget(this);
+ return true;
}
- return true;
+ return false;
}
//********************************************************************
#include <ModuleBase_IViewer.h>
#include <ModuleBase_IViewWindow.h>
#include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_WidgetEditor.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Events.h>
connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
+ connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
+
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
XGUI_Workshop* aWorkshop = aConnector->workshop();
}
}
+void PartSet_Module::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
+{
+ ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+ if (aOperation->isEditOperation()) {
+ std::string aId = aOperation->id().toStdString();
+ if ((aId == SketchPlugin_ConstraintLength::ID()) ||
+ (aId == SketchPlugin_ConstraintDistance::ID()) ||
+ (aId == SketchPlugin_ConstraintRadius::ID()))
+ {
+ // Activate dimension value editing on double click
+ ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+ QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+ // Find corresponded widget to activate value editing
+ foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
+ if (aWgt->attributeID() == "ConstraintValue") {
+ aWgt->focusTo();
+ return;
+ }
+ }
+ }
+ }
+}
+
void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
{
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
}else
return 0;
}
+
virtual void onSelectionChanged();
/// SLOT, that is called by mouse press in the viewer.
- /// The mouse released point is sent to the current operation to be processed.
+ /// \param theWnd - the window where the event happens
/// \param theEvent the mouse event
void onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
/// SLOT, that is called by mouse release in the viewer.
- /// The mouse released point is sent to the current operation to be processed.
+ /// \param theWnd - the window where the event happens
/// \param theEvent the mouse event
- virtual void onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+ void onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
/// SLOT, that is called by mouse move in the viewer.
- /// The mouse moved point is sent to the current operation to be processed.
+ /// \param theWnd - the window where the event happens
+ /// \param theEvent the mouse event
+ void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+
+ /// SLOT, that is called by mouse double click in the viewer.
+ /// \param theWnd - the window where the event happens
/// \param theEvent the mouse event
- virtual void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+ void onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
/// SLOT, that is called by key release in the viewer.
/// The mouse moved point is sent to the current operation to be processed.
PartSetPlugin_Remove.cpp
)
+SET(XML_RESOURCES
+ plugin-PartSet.xml
+)
+
ADD_DEFINITIONS(-DPARTSETPLUGIN_EXPORTS)
-ADD_LIBRARY(PartSetPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+ADD_LIBRARY(PartSetPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
TARGET_LINK_LIBRARIES(PartSetPlugin ${PROJECT_LIBRARIES} ModelAPI)
INCLUDE_DIRECTORIES(
../GeomAPI
)
-SET(XML_RESOURCES
- plugin-PartSet.xml
-)
-
INSTALL(TARGETS PartSetPlugin DESTINATION plugins)
INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
<workbench id="Part">
<group id="Operations">
<feature id="Part" title="New part" tooltip="Create a new part" icon=":pictures/part_ico.png"/>
- <feature id="Duplicate" title="Duplicate" tooltip="Duplicate selected part" icon=":icons/duplicate.png"/>
- <feature id="Remove" title="Remove part" tooltip="Remove active part" icon=":icons/remove.png"/>
+ <feature id="Duplicate" title="Duplicate"
+ tooltip="Duplicate selected part"
+ icon=":icons/duplicate.png"
+ document="Part"/>
+ <feature id="Remove"
+ title="Remove part"
+ tooltip="Remove active part"
+ icon=":icons/remove.png"
+ document="Part"/>
</group>
</workbench>
</plugin>
<sketch_constraint_shape_selector id="ConstraintEntityA"
label="First line" tooltip="Select an line in the viewer"
shape_types="edge" use_subshapes="true">
- <validator id="SketchPlugin_ResultLine"/>
</sketch_constraint_shape_selector>
<sketch_constraint_shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer"
shape_types="edge" use_subshapes="true">
- <validator id="SketchPlugin_ResultLine"/>
<validator id="SketchPlugin_DifferentObjects"/>
</sketch_constraint_shape_selector>
<sketch_constraint_shape_selector id="ConstraintEntityA"
label="First line" tooltip="Select an line in the viewer"
shape_types="edge" use_subshapes="true">
- <validator id="SketchPlugin_ResultLine"/>
</sketch_constraint_shape_selector>
<sketch_constraint_shape_selector id="ConstraintEntityB"
label="Last line" tooltip="Select an line in the viewer"
shape_types="edge" use_subshapes="true">
- <validator id="SketchPlugin_ResultLine"/>
<validator id="SketchPlugin_DifferentObjects"/>
</sketch_constraint_shape_selector>
<validator id="PartSet_PerpendicularValidator"/>
{
myIsComputed = true;
bool needToUpdate = false;
+ static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+ // to avoid redisplay of each segment on update by solver one by one in the viewer
+ bool isUpdateFlushed = Events_Loop::loop()->isFlushed(anUpdateEvent);
+ if (isUpdateFlushed) {
+ Events_Loop::loop()->setFlushed(anUpdateEvent, false);
+ }
+
std::vector<SketchSolver_ConstraintGroup*>::iterator aGroupIter;
for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++)
if ((*aGroupIter)->resolveConstraints())
needToUpdate = true;
- // Features may be updated => send events
+ // Features may be updated => now send events, btu for all changed at once
+ if (isUpdateFlushed) {
+ Events_Loop::loop()->setFlushed(anUpdateEvent, true);
+ }
if (needToUpdate)
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ Events_Loop::loop()->flush(anUpdateEvent);
myIsComputed = false;
}