1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 #include "XGUI_WorkshopListener.h"
4 #include "XGUI_Workshop.h"
5 #include "XGUI_Displayer.h"
6 #include "XGUI_ErrorMgr.h"
7 #include "XGUI_OperationMgr.h"
8 #include "XGUI_SalomeConnector.h"
9 #include "XGUI_ActionsMgr.h"
10 #include "XGUI_PropertyPanel.h"
11 #include "XGUI_ModuleConnector.h"
12 #include "XGUI_QtEvents.h"
15 #include <AppElements_Workbench.h>
16 #include <AppElements_Command.h>
17 #include <AppElements_MainMenu.h>
18 #include <AppElements_MainWindow.h>
19 #include <AppElements_MenuGroupPanel.h>
20 #include <AppElements_Button.h>
23 #include <ModuleBase_IModule.h>
25 #include <ModelAPI_Object.h>
26 #include <ModelAPI_Events.h>
27 #include <ModelAPI_Session.h>
28 #include <ModelAPI_Result.h>
29 #include <ModelAPI_Feature.h>
30 #include <ModelAPI_Data.h>
31 #include <ModelAPI_ResultBody.h>
32 #include <ModelAPI_ResultGroup.h>
33 #include <ModelAPI_ResultCompSolid.h>
34 #include <ModelAPI_Tools.h>
36 #include <Events_Loop.h>
37 #include <Events_Error.h>
38 #include <Events_LongOp.h>
40 #include <ModuleBase_IWorkshop.h>
42 #include <ModuleBase_Operation.h>
43 #include <ModuleBase_OperationDescription.h>
44 #include <ModuleBase_OperationFeature.h>
45 #include <ModuleBase_Tools.h>
46 #include <ModuleBase_IViewer.h>
47 #include <ModuleBase_FilterFactory.h>
49 #include <Config_FeatureMessage.h>
50 #include <Config_PointerMessage.h>
51 #include <Config_SelectionFilterMessage.h>
52 #include <Config_Keywords.h>
54 #include <QApplication>
55 #include <QMainWindow>
64 //#define DEBUG_FEATURE_CREATED
65 //#define DEBUG_FEATURE_REDISPLAY
66 //#define DEBUG_FEATURE_UPDATED
67 //#define DEBUG_RESULT_COMPSOLID
69 #ifdef DEBUG_FEATURE_REDISPLAY
70 const std::string DebugFeatureKind = "Extrusion";
73 XGUI_WorkshopListener::XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop)
74 : myWorkshop(theWorkshop),
77 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
80 //******************************************************
81 XGUI_WorkshopListener::~XGUI_WorkshopListener(void)
85 //******************************************************
86 void XGUI_WorkshopListener::initializeEventListening()
88 //Initialize event listening
89 Events_Loop* aLoop = Events_Loop::loop();
90 aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
91 aLoop->registerListener(this, Events_Loop::eventByName(Config_FeatureMessage::GUI_EVENT()));
92 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED));
93 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
94 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
95 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
96 aLoop->registerListener(this, Events_LongOp::eventID());
97 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED));
98 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SELFILTER_LOADED));
99 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED));
101 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED));
102 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED));
105 //******************************************************
106 void XGUI_WorkshopListener::processEvent(const std::shared_ptr<Events_Message>& theMessage)
108 if (QApplication::instance()->thread() != QThread::currentThread()) {
110 std::cout << "XGUI_Workshop::processEvent: " << "Working in another thread." << std::endl;
112 SessionPtr aMgr = ModelAPI_Session::get();
113 PostponeMessageQtEvent* aPostponeEvent = new PostponeMessageQtEvent(theMessage);
114 QApplication::postEvent(this, aPostponeEvent);
118 //A message to start feature creation received.
119 if (theMessage->eventID() == Events_Loop::loop()->eventByName(Config_FeatureMessage::GUI_EVENT())) {
120 std::shared_ptr<Config_FeatureMessage> aFeatureMsg =
121 std::dynamic_pointer_cast<Config_FeatureMessage>(theMessage);
122 if (!aFeatureMsg->isInternal()) {
123 addFeature(aFeatureMsg);
126 // Process creation of Part
127 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
128 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
129 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
130 onFeatureCreatedMsg(aUpdMsg);
132 XGUI_SalomeConnector* aSalomeConnector = workshop()->salomeConnector();
133 if (aSalomeConnector)
134 aSalomeConnector->createPreferences();
135 myUpdatePrefs = false;
138 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED)) {
139 myUpdatePrefs = true;
142 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
143 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
144 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
145 onFeatureRedisplayMsg(aUpdMsg);
147 //Update property panel on corresponding message. If there is no current operation (no
148 //property panel), or received message has different feature to the current - do nothing.
149 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
150 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
151 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
152 onFeatureUpdatedMsg(anUpdateMsg);
153 } else if (theMessage->eventID() == Events_LongOp::eventID()) {
154 if (Events_LongOp::isPerformed()) {
155 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
157 QApplication::restoreOverrideCursor();
160 //An operation passed by message. Start it, process and commit.
161 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) {
162 std::shared_ptr<Config_PointerMessage> aPartSetMsg =
163 std::dynamic_pointer_cast<Config_PointerMessage>(theMessage);
164 //myPropertyPanel->cleanContent();
165 ModuleBase_Operation* anOperation = (ModuleBase_Operation*) aPartSetMsg->pointer();
166 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
168 if (anOperationMgr->startOperation(anOperation)) {
169 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(anOperation);
171 workshop()->propertyPanel()->updateContentWidget(aFOperation->feature());
172 if (!anOperation->getDescription()->hasXmlRepresentation()) {
173 if (anOperation->commit())
174 workshop()->updateCommandStatus();
178 else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_SELFILTER_LOADED)) {
179 std::shared_ptr<Config_SelectionFilterMessage> aMsg =
180 std::dynamic_pointer_cast<Config_SelectionFilterMessage>(theMessage);
182 ModuleBase_FilterFactory* aFactory = myWorkshop->selectionFilters();
183 if (!aMsg->attributeId().empty()) {
184 aFactory->assignFilter(aMsg->selectionFilterId(), aMsg->featureId(), aMsg->attributeId(),
188 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)) {
189 // the viewer's update context will not happens until viewer updated is emitted
190 workshop()->displayer()->enableUpdateViewer(false);
191 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)) {
192 // the viewer's update context is unblocked, the viewer's update works
193 XGUI_Displayer* aDisplayer = workshop()->displayer();
194 aDisplayer->enableUpdateViewer(true);
195 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED)) {
196 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
197 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
198 std::set<ObjectPtr> anObjects = aUpdMsg->objects();
200 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
201 (workshop()->operationMgr()->currentOperation());
202 bool aFeatureChanged = false;
204 FeaturePtr aFeature = aFOperation->feature();
205 if (aFeature.get()) {
206 std::set<ObjectPtr>::const_iterator aIt;
207 for (aIt = anObjects.begin(); aIt != anObjects.end() && !aFeatureChanged; ++aIt) {
208 aFeatureChanged = ModelAPI_Feature::feature(*aIt) == aFeature;
212 workshop()->operationMgr()->onValidateOperation();
215 //Show error dialog if error message received.
216 std::shared_ptr<Events_Error> anAppError = std::dynamic_pointer_cast<Events_Error>(theMessage);
218 emit errorOccurred(QString::fromLatin1(anAppError->description()));
223 SessionPtr aMgr = ModelAPI_Session::get();
224 AppElements_MainWindow* aMainWindow = workshop()->mainWindow();
225 if (aMgr->isModified() != aMainWindow->isModifiedState())
226 aMainWindow->setModifiedState(aMgr->isModified());
230 //******************************************************
231 void XGUI_WorkshopListener::onFeatureUpdatedMsg(
232 const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
234 #ifdef DEBUG_FEATURE_UPDATED
235 std::set<ObjectPtr> anObjects = theMsg->objects();
236 std::set<ObjectPtr>::const_iterator aIt;
238 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
239 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
241 QString anInfoStr = anInfo.join(";\t");
242 qDebug(QString("onFeatureUpdatedMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
244 std::set<ObjectPtr> aFeatures = theMsg->objects();
245 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
246 if (anOperationMgr->hasOperation()) {
247 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
248 (anOperationMgr->currentOperation());
250 FeaturePtr aCurrentFeature = aFOperation->feature();
251 std::set<ObjectPtr>::const_iterator aIt;
252 for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
253 ObjectPtr aNewFeature = (*aIt);
254 if (aNewFeature == aCurrentFeature) {
255 workshop()->propertyPanel()->updateContentWidget(aCurrentFeature);
261 //anOperationMgr->onValidateOperation();
263 //if (myObjectBrowser)
264 // myObjectBrowser->processEvent(theMsg);
267 //******************************************************
268 void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
270 std::set<ObjectPtr> anObjects = theMsg->objects();
271 std::set<ObjectPtr>::const_iterator aIt;
273 #ifdef DEBUG_FEATURE_REDISPLAY
275 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
276 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
278 QString anInfoStr = anInfo.join(";\t");
279 qDebug(QString("onFeatureRedisplayMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
282 XGUI_Workshop* aWorkshop = workshop();
283 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
284 bool aFirstVisualizedBody = false;
286 bool aRedisplayed = false;
287 //std::list<ObjectPtr> aHiddenObjects;
288 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
289 ObjectPtr aObj = (*aIt);
291 // Hide the object if it is invalid or concealed one
292 bool aHide = !aObj->data() || !aObj->data()->isValid() ||
293 aObj->isDisabled() || (!aObj->isDisplayed());
294 if (!aHide) { // check that this is not hidden result
295 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
296 aHide = aRes && aRes->isConcealed();
298 // Hide the presentation with an empty shape. But isDisplayed state of the object should not
299 // be changed to the object becomes visible when the shape becomes not empty
300 if (!aHide && aRes.get())
301 aHide = !aRes->shape().get() || aRes->shape()->isNull();
304 #ifdef DEBUG_RESULT_COMPSOLID
305 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
307 ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
308 if (aCompSolidRes.get()) {
309 qDebug(QString("COMPSOLID, numberOfSubs = %1").arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
311 if (ModelAPI_Tools::compSolidOwner(aRes))
312 qDebug("COMPSOLID sub-object");
315 #ifdef DEBUG_FEATURE_REDISPLAY
316 QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
317 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
318 if (aFeature.get()) {
319 std::string aKind = aFeature->getKind();
320 if (aKind == DebugFeatureKind) {
321 qDebug(QString("visible=%1, hide=%2 : display= %2").arg(aDisplayer->isVisible(aObj))
322 .arg(aHide).arg(anObjInfo).toStdString().c_str());
327 //we should provide objects which are hidden in the viewer, e.g. sketch always should visualizes
328 // all sub-features, if some features are to be hidden, sould be proposed may be to removed #1223
329 //aHiddenObjects.push_back(aObj);
330 aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
331 #ifdef DEBUG_FEATURE_REDISPLAY
332 // Redisplay the visible object or the object of the current operation
333 bool isVisibleObject = aDisplayer->isVisible(aObj);
335 QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
336 //qDebug(QString("visible=%1 : erase = %2").arg(isVisibleObject).arg(anObjInfo).toStdString().c_str());
340 // Redisplay the visible object or the object of the current operation
341 bool isVisibleObject = aDisplayer->isVisible(aObj);
342 #ifdef DEBUG_FEATURE_REDISPLAY
343 QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
344 //qDebug(QString("visible=%1 : display= %2").arg(isVisibleObject).arg(anObjInfo).toStdString().c_str());
347 if (isVisibleObject) { // redisplay visible object
348 //displayObject(aObj); // In order to update presentation
349 // in order to avoid the check whether the object can be redisplayed, the exact method
350 // of redisplay is called. This modification is made in order to have the line is updated
351 // by creation of a horizontal constraint on the line by preselection
352 if (ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(aObj))) {
353 aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
356 aRedisplayed = aDisplayer->redisplay(aObj, false) || aRedisplayed;
357 // Deactivate object of current operation from selection
358 aWorkshop->deactivateActiveObject(aObj, false);
360 } else { // display object if the current operation has it
361 if (displayObject(aObj, aFirstVisualizedBody)) {
363 // Deactivate object of current operation from selection
364 aWorkshop->deactivateActiveObject(aObj, false);
369 // this processing should be moved in another place in order to do not cause problems in
370 // flush messages chain
371 //if (aHiddenObjects.size() > 0)
372 // myWorkshop->module()->processHiddenObject(aHiddenObjects);
374 bool isCustomized = customizeCurrentObject(anObjects, aRedisplayed);
375 if (aRedisplayed || isCustomized) {
376 //VSV FitAll updated viewer by it self
377 if (aFirstVisualizedBody)
378 myWorkshop->viewer()->fitAll();
380 aDisplayer->updateViewer();
383 //******************************************************
384 void XGUI_WorkshopListener::onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
386 std::set<ObjectPtr> anObjects = theMsg->objects();
387 std::set<ObjectPtr>::const_iterator aIt;
388 #ifdef DEBUG_FEATURE_CREATED
390 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
391 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
393 QString anInfoStr = anInfo.join(";\t");
394 qDebug(QString("onFeatureCreatedMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
397 bool aFirstVisualizedBody = false;
399 //bool aHasPart = false;
400 bool aDisplayed = false;
401 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
402 ObjectPtr anObject = *aIt;
404 #ifdef DEBUG_RESULT_COMPSOLID
405 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
407 ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
408 if (aCompSolidRes.get()) {
409 qDebug(QString("COMPSOLID, numberOfSubs = %1").arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
411 if (ModelAPI_Tools::compSolidOwner(aRes))
412 qDebug("COMPSOLID sub-object");
415 // the validity of the data should be checked here in order to avoid display of the objects,
416 // which were created, then deleted, but flush for the creation event happens after that
417 // we should not display disabled objects
418 bool aHide = !anObject->data()->isValid() ||
419 anObject->isDisabled() ||
420 !anObject->isDisplayed();
421 if (!aHide) { // check that this is not hidden result
422 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
423 bool isConcealed = aRes && aRes->isConcealed();
424 aHide = aRes && aRes->isConcealed();
425 // Hide the presentation with an empty shape. But isDisplayed state of the object should not
426 // be changed to the object becomes visible when the shape becomes not empty
427 if (!aHide && aRes.get())
428 aHide = !aRes->shape().get() || aRes->shape()->isNull();
431 // setDisplayed has to be called in order to synchronize internal state of the object
432 // with list of displayed objects
433 if (myWorkshop->module()->canDisplayObject(anObject)) {
434 anObject->setDisplayed(true);
435 aDisplayed = displayObject(*aIt, aFirstVisualizedBody);
437 anObject->setDisplayed(false);
441 bool isCustomized = customizeCurrentObject(anObjects, aDisplayed);
443 //if (myObjectBrowser)
444 // myObjectBrowser->processEvent(theMsg);
446 //VSV FitAll updated viewer by it self
447 if (aFirstVisualizedBody)
448 myWorkshop->viewer()->fitAll();
450 workshop()->displayer()->updateViewer();
452 //if (aHasPart) { // TODO: Avoid activate last part on loading of document
453 // activateLastPart();
457 bool XGUI_WorkshopListener::event(QEvent * theEvent)
459 PostponeMessageQtEvent* aPostponedEv = dynamic_cast<PostponeMessageQtEvent*>(theEvent);
461 std::shared_ptr<Events_Message> aEventPtr = aPostponedEv->postponedMessage();
462 processEvent(aEventPtr);
468 void XGUI_WorkshopListener::addFeature(const std::shared_ptr<Config_FeatureMessage>& theMessage)
472 qDebug() << "XGUI_WorkshopListener::addFeature: NULL message.";
476 ActionInfo aFeatureInfo;
477 aFeatureInfo.initFrom(theMessage);
479 XGUI_Workshop* aWorkshop = workshop();
481 QString aWchName = QString::fromStdString(theMessage->workbenchId());
482 QStringList aNestedFeatures =
483 QString::fromStdString(theMessage->nestedFeatures()).split(" ", QString::SkipEmptyParts);
484 QString aDocKind = QString::fromStdString(theMessage->documentKind());
485 QList<QAction*> aNestedActList;
486 bool isColumnButton = !aNestedFeatures.isEmpty();
487 if (isColumnButton) {
488 QString aNestedActions = QString::fromStdString(theMessage->actionsWhenNested());
489 XGUI_OperationMgr* anOperationMgr = aWorkshop->operationMgr();
490 XGUI_ActionsMgr* anActionsMgr = aWorkshop->actionsMgr();
491 if (aNestedActions.contains(FEATURE_WHEN_NESTED_ACCEPT)) {
492 QAction* anAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL);
493 connect(anAction, SIGNAL(triggered()), anOperationMgr, SLOT(commitAllOperations()));
494 aNestedActList << anAction;
496 if (aNestedActions.contains(FEATURE_WHEN_NESTED_ABORT)) {
497 QAction* anAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AbortAll, NULL);
498 connect(anAction, SIGNAL(triggered()), anOperationMgr, SLOT(abortAllOperations()));
499 aNestedActList << anAction;
504 XGUI_SalomeConnector* aSalomeConnector = aWorkshop->salomeConnector();
506 if (isColumnButton) {
507 aAction = aSalomeConnector->addFeatureOfNested(aWchName, aFeatureInfo, aNestedActList);
509 //Issue #650: in the SALOME mode the tooltip should be same as text
510 aFeatureInfo.toolTip = aFeatureInfo.text;
511 aAction = aSalomeConnector->addFeature(aWchName, aFeatureInfo);
513 aSalomeConnector->setNestedActions(aFeatureInfo.id, aNestedFeatures);
514 aSalomeConnector->setDocumentKind(aFeatureInfo.id, aDocKind);
516 aWorkshop->actionsMgr()->addCommand(aAction);
517 aWorkshop->module()->actionCreated(aAction);
519 //Find or create Workbench
520 AppElements_MainMenu* aMenuBar = aWorkshop->mainWindow()->menuObject();
521 AppElements_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
523 aPage = aWorkshop->addWorkbench(aWchName);
525 //Find or create Group
526 QString aGroupName = QString::fromStdString(theMessage->groupId());
527 AppElements_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
529 aGroup = aPage->addGroup(aGroupName);
531 // Check if hotkey sequence is already defined:
532 XGUI_ActionsMgr* anActionsMgr = aWorkshop->actionsMgr();
533 QKeySequence aHotKey = anActionsMgr->registerShortcut(aFeatureInfo.shortcut);
534 if(aHotKey != aFeatureInfo.shortcut) {
535 aFeatureInfo.shortcut = aHotKey;
538 AppElements_Command* aCommand = aGroup->addFeature(aFeatureInfo,
541 // Enrich created button with accept/abort buttons if necessary
542 AppElements_Button* aButton = aCommand->button();
543 if (aButton->isColumnButton()) {
544 aButton->setAdditionalButtons(aNestedActList);
546 aWorkshop->actionsMgr()->addCommand(aCommand);
547 aWorkshop->module()->actionCreated(aCommand);
552 //**************************************************************
553 bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj, bool& theFirstVisualizedBody)
555 #ifdef DEBUG_RESULT_COMPSOLID
556 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
557 if (aRes.get() && (ModelAPI_Tools::hasSubResults(aRes) || ModelAPI_Tools::compSolidOwner(aRes))) {
558 ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
559 if (aCompSolidRes.get()) {
560 qDebug("COMPSOLID: displayObject");
565 bool aDisplayed = false;
566 XGUI_Workshop* aWorkshop = workshop();
567 // do not display the object if it has sub objects. They should be displayed separately.
568 if (!aWorkshop->module()->canDisplayObject(theObj) ||
569 ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(theObj)))
572 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
573 ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theObj);
574 if (aBody.get() != NULL) {
575 int aNb = aDisplayer->objectsCount();
576 aDisplayed = aDisplayer->display(theObj, false);
578 theFirstVisualizedBody = true;
580 aDisplayed = aDisplayer->display(theObj, false);
582 ResultPtr aGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(theObj);
583 if (aGroup.get() != NULL) {
584 std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aGroup);
585 theFirstVisualizedBody = aShapePtr.get() != NULL;
592 bool XGUI_WorkshopListener::customizeCurrentObject(const std::set<ObjectPtr>& theObjects,
593 bool theForceRedisplay)
595 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
596 FeaturePtr aCurrentFeature;
597 if (anOperationMgr->hasOperation()) {
598 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
599 (anOperationMgr->currentOperation());
601 aCurrentFeature = aFOperation->feature();
605 bool aCustomized = false;
606 if (aCurrentFeature.get()) {
607 // the customize presentation should be redisplayed if force redislayed is true or
608 // if a list of message objects contains the operation feature for case when
609 // the feature is hidden, but arguments of the feature are modified
610 // e.g. extrusion is hidden(h=0) but sketch is chosen
611 if (theForceRedisplay || theObjects.find(aCurrentFeature) != theObjects.end()) {
612 aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
613 ModuleBase_IModule::CustomizeArguments, false);
614 aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
615 ModuleBase_IModule::CustomizeResults, false);
616 aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
617 ModuleBase_IModule::CustomizeHighlightedObjects, false);
623 XGUI_Workshop* XGUI_WorkshopListener::workshop() const
625 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
626 return aConnector->workshop();