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"
14 #include <AppElements_Workbench.h>
15 #include <AppElements_Command.h>
16 #include <AppElements_MainMenu.h>
17 #include <AppElements_MainWindow.h>
18 #include <AppElements_MenuGroupPanel.h>
19 #include <AppElements_Button.h>
21 #include <ModuleBase_IModule.h>
23 #include <ModelAPI_Object.h>
24 #include <ModelAPI_Events.h>
25 #include <ModelAPI_Session.h>
26 #include <ModelAPI_Result.h>
27 #include <ModelAPI_Feature.h>
28 #include <ModelAPI_Data.h>
29 #include <ModelAPI_ResultBody.h>
30 #include <ModelAPI_ResultCompSolid.h>
31 #include <ModelAPI_Tools.h>
33 #include <Events_Loop.h>
34 #include <Events_Error.h>
35 #include <Events_LongOp.h>
37 #include <ModuleBase_IWorkshop.h>
39 #include <ModuleBase_Operation.h>
40 #include <ModuleBase_OperationDescription.h>
41 #include <ModuleBase_OperationFeature.h>
42 #include <ModuleBase_Tools.h>
43 #include <ModuleBase_IViewer.h>
44 #include <ModuleBase_FilterFactory.h>
46 #include <Config_FeatureMessage.h>
47 #include <Config_PointerMessage.h>
48 #include <Config_SelectionFilterMessage.h>
49 #include <Config_Keywords.h>
51 #include <QApplication>
52 #include <QMainWindow>
61 //#define DEBUG_FEATURE_CREATED
62 //#define DEBUG_FEATURE_REDISPLAY
63 //#define DEBUG_FEATURE_UPDATED
64 //#define DEBUG_RESULT_COMPSOLID
66 XGUI_WorkshopListener::XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop)
67 : myWorkshop(theWorkshop),
70 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
71 //connect(anOperationMgr, SIGNAL(nestedStateChanged(const std::string&, const bool)),
72 // this, SLOT(onNestedStateChanged(const std::string&, const bool)));
75 //******************************************************
76 XGUI_WorkshopListener::~XGUI_WorkshopListener(void)
80 //******************************************************
81 void XGUI_WorkshopListener::initializeEventListening()
83 //Initialize event listening
84 Events_Loop* aLoop = Events_Loop::loop();
85 aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
86 aLoop->registerListener(this, Events_Loop::eventByName(Config_FeatureMessage::GUI_EVENT()));
87 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED));
88 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
89 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
90 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
91 aLoop->registerListener(this, Events_LongOp::eventID());
92 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED));
93 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SELFILTER_LOADED));
94 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED));
96 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED));
97 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED));
100 //******************************************************
101 void XGUI_WorkshopListener::processEvent(const std::shared_ptr<Events_Message>& theMessage)
103 if (QApplication::instance()->thread() != QThread::currentThread()) {
105 std::cout << "XGUI_Workshop::processEvent: " << "Working in another thread." << std::endl;
107 SessionPtr aMgr = ModelAPI_Session::get();
108 PostponeMessageQtEvent* aPostponeEvent = new PostponeMessageQtEvent(theMessage);
109 QApplication::postEvent(this, aPostponeEvent);
113 //A message to start feature creation received.
114 if (theMessage->eventID() == Events_Loop::loop()->eventByName(Config_FeatureMessage::GUI_EVENT())) {
115 std::shared_ptr<Config_FeatureMessage> aFeatureMsg =
116 std::dynamic_pointer_cast<Config_FeatureMessage>(theMessage);
117 if (!aFeatureMsg->isInternal()) {
118 addFeature(aFeatureMsg);
121 // Process creation of Part
122 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
123 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
124 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
125 onFeatureCreatedMsg(aUpdMsg);
127 XGUI_SalomeConnector* aSalomeConnector = workshop()->salomeConnector();
128 if (aSalomeConnector)
129 aSalomeConnector->createPreferences();
130 myUpdatePrefs = false;
133 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED)) {
134 myUpdatePrefs = true;
137 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
138 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
139 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
140 onFeatureRedisplayMsg(aUpdMsg);
142 //Update property panel on corresponding message. If there is no current operation (no
143 //property panel), or received message has different feature to the current - do nothing.
144 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
145 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
146 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
147 onFeatureUpdatedMsg(anUpdateMsg);
148 } else if (theMessage->eventID() == Events_LongOp::eventID()) {
149 if (Events_LongOp::isPerformed()) {
150 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
152 QApplication::restoreOverrideCursor();
155 //An operation passed by message. Start it, process and commit.
156 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) {
157 std::shared_ptr<Config_PointerMessage> aPartSetMsg =
158 std::dynamic_pointer_cast<Config_PointerMessage>(theMessage);
159 //myPropertyPanel->cleanContent();
160 ModuleBase_Operation* anOperation = (ModuleBase_Operation*) aPartSetMsg->pointer();
161 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
163 if (anOperationMgr->startOperation(anOperation)) {
164 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(anOperation);
166 workshop()->propertyPanel()->updateContentWidget(aFOperation->feature());
167 if (!anOperation->getDescription()->hasXmlRepresentation()) {
168 if (anOperation->commit())
169 workshop()->updateCommandStatus();
173 else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_SELFILTER_LOADED)) {
174 std::shared_ptr<Config_SelectionFilterMessage> aMsg =
175 std::dynamic_pointer_cast<Config_SelectionFilterMessage>(theMessage);
177 ModuleBase_FilterFactory* aFactory = myWorkshop->selectionFilters();
178 if (!aMsg->attributeId().empty()) {
179 aFactory->assignFilter(aMsg->selectionFilterId(), aMsg->featureId(), aMsg->attributeId(),
183 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)) {
184 // the viewer's update context will not happens until viewer updated is emitted
185 workshop()->displayer()->enableUpdateViewer(false);
186 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)) {
187 // the viewer's update context is unblocked, the viewer's update works
188 XGUI_Displayer* aDisplayer = workshop()->displayer();
189 aDisplayer->enableUpdateViewer(true);
190 aDisplayer->updateViewer();
191 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED)) {
192 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
193 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
194 std::set<ObjectPtr> aObjects = aUpdMsg->objects();
195 std::set<ObjectPtr>::const_iterator aIt;
196 for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
197 workshop()->errorMgr()->updateActions(ModelAPI_Feature::feature(*aIt));
200 //Show error dialog if error message received.
201 std::shared_ptr<Events_Error> anAppError = std::dynamic_pointer_cast<Events_Error>(theMessage);
203 emit errorOccurred(QString::fromLatin1(anAppError->description()));
207 if (!workshop()->isSalomeMode()) {
208 SessionPtr aMgr = ModelAPI_Session::get();
209 AppElements_MainWindow* aMainWindow = workshop()->mainWindow();
210 if (aMgr->isModified() != aMainWindow->isModifiedState())
211 aMainWindow->setModifiedState(aMgr->isModified());
215 //******************************************************
216 void XGUI_WorkshopListener::onFeatureUpdatedMsg(
217 const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
219 #ifdef DEBUG_FEATURE_UPDATED
220 std::set<ObjectPtr> aObjects = theMsg->objects();
221 std::set<ObjectPtr>::const_iterator aIt;
223 for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
224 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
226 QString anInfoStr = anInfo.join(";\t");
227 qDebug(QString("onFeatureUpdatedMsg: %1, %2").arg(aObjects.size()).arg(anInfoStr).toStdString().c_str());
229 std::set<ObjectPtr> aFeatures = theMsg->objects();
230 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
231 if (anOperationMgr->hasOperation()) {
232 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
233 (anOperationMgr->currentOperation());
235 FeaturePtr aCurrentFeature = aFOperation->feature();
236 std::set<ObjectPtr>::const_iterator aIt;
237 for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
238 ObjectPtr aNewFeature = (*aIt);
239 if (aNewFeature == aCurrentFeature) {
240 workshop()->propertyPanel()->updateContentWidget(aCurrentFeature);
246 //anOperationMgr->onValidateOperation();
248 //if (myObjectBrowser)
249 // myObjectBrowser->processEvent(theMsg);
252 //******************************************************
253 void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
255 std::set<ObjectPtr> aObjects = theMsg->objects();
256 std::set<ObjectPtr>::const_iterator aIt;
258 #ifdef DEBUG_FEATURE_REDISPLAY
260 for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
261 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
263 QString anInfoStr = anInfo.join(";\t");
264 qDebug(QString("onFeatureRedisplayMsg: %1, %2").arg(aObjects.size()).arg(anInfoStr).toStdString().c_str());
267 XGUI_Workshop* aWorkshop = workshop();
268 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
269 bool aRedisplayed = false;
270 for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
271 ObjectPtr aObj = (*aIt);
273 // Hide the object if it is invalid or concealed one
274 bool aHide = !aObj->data() || !aObj->data()->isValid() ||
275 aObj->isDisabled() || (!aObj->isDisplayed());
276 if (!aHide) { // check that this is not hidden result
277 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
278 aHide = aRes && aRes->isConcealed();
280 #ifdef DEBUG_RESULT_COMPSOLID
281 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
283 ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
284 if (aCompSolidRes.get()) {
285 qDebug(QString("COMPSOLID, numberOfSubs = %1").arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
287 if (ModelAPI_Tools::compSolidOwner(aRes))
288 qDebug("COMPSOLID sub-object");
292 aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
293 #ifdef DEBUG_FEATURE_REDISPLAY
294 // Redisplay the visible object or the object of the current operation
295 bool isVisibleObject = aDisplayer->isVisible(aObj);
297 QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
298 //qDebug(QString("visible=%1 : erase = %2").arg(isVisibleObject).arg(anObjInfo).toStdString().c_str());
302 // Redisplay the visible object or the object of the current operation
303 bool isVisibleObject = aDisplayer->isVisible(aObj);
304 #ifdef DEBUG_FEATURE_REDISPLAY
305 QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
306 //qDebug(QString("visible=%1 : display= %2").arg(isVisibleObject).arg(anObjInfo).toStdString().c_str());
307 /*FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
308 if (aFeature.get()) {
309 std::string aKind = aFeature->getKind();
310 if (aKind == "SketchMultiRotation")
315 if (isVisibleObject) { // redisplay visible object
316 //displayObject(aObj); // In order to update presentation
317 // in order to avoid the check whether the object can be redisplayed, the exact method
318 // of redisplay is called. This modification is made in order to have the line is updated
319 // by creation of a horizontal constraint on the line by preselection
320 if (ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(aObj))) {
321 aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
324 aRedisplayed = aDisplayer->redisplay(aObj, false) || aRedisplayed;
325 // Deactivate object of current operation from selection
326 aWorkshop->deactivateActiveObject(aObj, false);
328 } else { // display object if the current operation has it
329 if (displayObject(aObj)) {
331 // Deactivate object of current operation from selection
332 aWorkshop->deactivateActiveObject(aObj, false);
338 customizeCurrentObject();
339 aDisplayer->updateViewer();
342 //******************************************************
343 void XGUI_WorkshopListener::onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
345 std::set<ObjectPtr> aObjects = theMsg->objects();
346 std::set<ObjectPtr>::const_iterator aIt;
347 #ifdef DEBUG_FEATURE_CREATED
349 for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
350 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
352 QString anInfoStr = anInfo.join(";\t");
353 qDebug(QString("onFeatureCreatedMsg: %1, %2").arg(aObjects.size()).arg(anInfoStr).toStdString().c_str());
356 //bool aHasPart = false;
357 bool aDisplayed = false;
358 for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
359 ObjectPtr anObject = *aIt;
361 #ifdef DEBUG_RESULT_COMPSOLID
362 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
364 ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
365 if (aCompSolidRes.get()) {
366 qDebug(QString("COMPSOLID, numberOfSubs = %1").arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
368 if (ModelAPI_Tools::compSolidOwner(aRes))
369 qDebug("COMPSOLID sub-object");
372 // the validity of the data should be checked here in order to avoid display of the objects,
373 // which were created, then deleted, but flush for the creation event happens after that
374 // we should not display disabled objects
375 bool aHide = !anObject->data()->isValid() ||
376 anObject->isDisabled() ||
377 !anObject->isDisplayed();
379 // setDisplayed has to be called in order to synchronize internal state of the object
380 // with list of displayed objects
381 if (myWorkshop->module()->canDisplayObject(anObject)) {
382 anObject->setDisplayed(true);
383 aDisplayed = displayObject(*aIt);
385 anObject->setDisplayed(false);
389 //if (myObjectBrowser)
390 // myObjectBrowser->processEvent(theMsg);
392 customizeCurrentObject();
393 workshop()->displayer()->updateViewer();
395 //if (aHasPart) { // TODO: Avoid activate last part on loading of document
396 // activateLastPart();
400 /*void XGUI_WorkshopListener::onNestedStateChanged(const std::string& theFeatureId, const bool theState)
402 XGUI_Workshop* aWorkshop = workshop();
404 //one button is used for all features, which can have nested actions, so it is obtained from
405 // the action manager
406 //bool aActionToBeUpdated = aWorkshop->isFeatureOfNested(theFeatureId);
407 if (aWorkshop->isSalomeMode()) {
408 XGUI_SalomeConnector* aSalomeConnector = aWorkshop->salomeConnector();
409 XGUI_ActionsMgr* anActionsMgr = aWorkshop->actionsMgr();
410 if (aSalomeConnector->isFeatureOfNested(anActionsMgr->action(theFeatureId.c_str())))
411 aActionToBeUpdated = true;
413 AppElements_MainMenu* aMenuBar = aWorkshop->mainWindow()->menuObject();
414 AppElements_Command* aCommand = aMenuBar->feature(theFeatureId.c_str());
415 if (aCommand && aCommand->button()->additionalButtonWidget())
416 aActionToBeUpdated = true;
418 if (aActionToBeUpdated) {
419 QAction* anAcceptAllAction = aWorkshop->actionsMgr()->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL);
420 anAcceptAllAction->setEnabled(theState);
424 bool XGUI_WorkshopListener::event(QEvent * theEvent)
426 PostponeMessageQtEvent* aPostponedEv = dynamic_cast<PostponeMessageQtEvent*>(theEvent);
428 std::shared_ptr<Events_Message> aEventPtr = aPostponedEv->postponedMessage();
429 processEvent(aEventPtr);
435 void XGUI_WorkshopListener::addFeature(const std::shared_ptr<Config_FeatureMessage>& theMessage)
439 qDebug() << "XGUI_WorkshopListener::addFeature: NULL message.";
443 ActionInfo aFeatureInfo;
444 aFeatureInfo.initFrom(theMessage);
446 XGUI_Workshop* aWorkshop = workshop();
448 QString aWchName = QString::fromStdString(theMessage->workbenchId());
449 QStringList aNestedFeatures =
450 QString::fromStdString(theMessage->nestedFeatures()).split(" ", QString::SkipEmptyParts);
451 QString aDocKind = QString::fromStdString(theMessage->documentKind());
452 QList<QAction*> aNestedActList;
453 bool isColumnButton = !aNestedFeatures.isEmpty();
454 if (isColumnButton) {
455 QString aNestedActions = QString::fromStdString(theMessage->actionsWhenNested());
456 XGUI_OperationMgr* anOperationMgr = aWorkshop->operationMgr();
457 XGUI_ActionsMgr* anActionsMgr = aWorkshop->actionsMgr();
458 if (aNestedActions.contains(FEATURE_WHEN_NESTED_ACCEPT)) {
459 QAction* anAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL);
460 connect(anAction, SIGNAL(triggered()), anOperationMgr, SLOT(commitAllOperations()));
461 aNestedActList << anAction;
463 if (aNestedActions.contains(FEATURE_WHEN_NESTED_ABORT)) {
464 QAction* anAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AbortAll, NULL);
465 connect(anAction, SIGNAL(triggered()), anOperationMgr, SLOT(abortAllOperations()));
466 aNestedActList << anAction;
470 if (aWorkshop->isSalomeMode()) {
471 XGUI_SalomeConnector* aSalomeConnector = aWorkshop->salomeConnector();
473 if (isColumnButton) {
474 aAction = aSalomeConnector->addFeatureOfNested(aWchName, aFeatureInfo, aNestedActList);
476 //Issue #650: in the SALOME mode the tooltip should be same as text
477 aFeatureInfo.toolTip = aFeatureInfo.text;
478 aAction = aSalomeConnector->addFeature(aWchName, aFeatureInfo);
480 aSalomeConnector->setNestedActions(aFeatureInfo.id, aNestedFeatures);
481 aSalomeConnector->setDocumentKind(aFeatureInfo.id, aDocKind);
483 aWorkshop->actionsMgr()->addCommand(aAction);
484 aWorkshop->module()->actionCreated(aAction);
486 //Find or create Workbench
487 AppElements_MainMenu* aMenuBar = aWorkshop->mainWindow()->menuObject();
488 AppElements_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
490 aPage = aWorkshop->addWorkbench(aWchName);
492 //Find or create Group
493 QString aGroupName = QString::fromStdString(theMessage->groupId());
494 AppElements_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
496 aGroup = aPage->addGroup(aGroupName);
498 // Check if hotkey sequence is already defined:
499 XGUI_ActionsMgr* anActionsMgr = aWorkshop->actionsMgr();
500 QKeySequence aHotKey = anActionsMgr->registerShortcut(aFeatureInfo.shortcut);
501 if(aHotKey != aFeatureInfo.shortcut) {
502 aFeatureInfo.shortcut = aHotKey;
505 AppElements_Command* aCommand = aGroup->addFeature(aFeatureInfo,
508 // Enrich created button with accept/abort buttons if necessary
509 AppElements_Button* aButton = aCommand->button();
510 if (aButton->isColumnButton()) {
511 aButton->setAdditionalButtons(aNestedActList);
513 aWorkshop->actionsMgr()->addCommand(aCommand);
514 aWorkshop->module()->actionCreated(aCommand);
519 //**************************************************************
520 bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj)
522 #ifdef DEBUG_RESULT_COMPSOLID
523 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
524 if (aRes.get() && (ModelAPI_Tools::hasSubResults(aRes) || ModelAPI_Tools::compSolidOwner(aRes))) {
525 ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
526 if (aCompSolidRes.get()) {
527 qDebug("COMPSOLID: displayObject");
532 bool aDisplayed = false;
533 XGUI_Workshop* aWorkshop = workshop();
534 // do not display the object if it has sub objects. They should be displayed separately.
535 if (!aWorkshop->module()->canDisplayObject(theObj) ||
536 ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(theObj)))
539 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
540 ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theObj);
541 if (aBody.get() != NULL) {
542 int aNb = aDisplayer->objectsCount();
543 aDisplayed = aDisplayer->display(theObj, false);
545 myWorkshop->viewer()->fitAll();
547 aDisplayed = aDisplayer->display(theObj, false);
552 bool XGUI_WorkshopListener::customizeCurrentObject()
554 bool aCustomized = false;
555 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
556 if (anOperationMgr->hasOperation()) {
557 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
558 (anOperationMgr->currentOperation());
560 FeaturePtr aCurrentFeature = aFOperation->feature();
561 if (aCurrentFeature.get())
562 aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature, false);
568 XGUI_Workshop* XGUI_WorkshopListener::workshop() const
570 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
571 return aConnector->workshop();