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_ResultCompSolid.h>
33 #include <ModelAPI_Tools.h>
35 #include <Events_Loop.h>
36 #include <Events_Error.h>
37 #include <Events_LongOp.h>
39 #include <ModuleBase_IWorkshop.h>
41 #include <ModuleBase_Operation.h>
42 #include <ModuleBase_OperationDescription.h>
43 #include <ModuleBase_OperationFeature.h>
44 #include <ModuleBase_Tools.h>
45 #include <ModuleBase_IViewer.h>
46 #include <ModuleBase_FilterFactory.h>
48 #include <Config_FeatureMessage.h>
49 #include <Config_PointerMessage.h>
50 #include <Config_SelectionFilterMessage.h>
51 #include <Config_Keywords.h>
53 #include <QApplication>
54 #include <QMainWindow>
63 //#define DEBUG_FEATURE_CREATED
64 //#define DEBUG_FEATURE_REDISPLAY
65 //#define DEBUG_FEATURE_UPDATED
66 //#define DEBUG_RESULT_COMPSOLID
68 #ifdef DEBUG_FEATURE_REDISPLAY
69 const std::string DebugFeatureKind = "Extrusion";
72 XGUI_WorkshopListener::XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop)
73 : myWorkshop(theWorkshop),
76 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
79 //******************************************************
80 XGUI_WorkshopListener::~XGUI_WorkshopListener(void)
84 //******************************************************
85 void XGUI_WorkshopListener::initializeEventListening()
87 //Initialize event listening
88 Events_Loop* aLoop = Events_Loop::loop();
89 aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
90 aLoop->registerListener(this, Events_Loop::eventByName(Config_FeatureMessage::GUI_EVENT()));
91 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED));
92 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
93 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
94 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
95 aLoop->registerListener(this, Events_LongOp::eventID());
96 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED));
97 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SELFILTER_LOADED));
98 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED));
100 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED));
101 aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED));
104 //******************************************************
105 void XGUI_WorkshopListener::processEvent(const std::shared_ptr<Events_Message>& theMessage)
107 if (QApplication::instance()->thread() != QThread::currentThread()) {
109 std::cout << "XGUI_Workshop::processEvent: " << "Working in another thread." << std::endl;
111 SessionPtr aMgr = ModelAPI_Session::get();
112 PostponeMessageQtEvent* aPostponeEvent = new PostponeMessageQtEvent(theMessage);
113 QApplication::postEvent(this, aPostponeEvent);
117 //A message to start feature creation received.
118 if (theMessage->eventID() == Events_Loop::loop()->eventByName(Config_FeatureMessage::GUI_EVENT())) {
119 std::shared_ptr<Config_FeatureMessage> aFeatureMsg =
120 std::dynamic_pointer_cast<Config_FeatureMessage>(theMessage);
121 if (!aFeatureMsg->isInternal()) {
122 addFeature(aFeatureMsg);
125 // Process creation of Part
126 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
127 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
128 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
129 onFeatureCreatedMsg(aUpdMsg);
131 XGUI_SalomeConnector* aSalomeConnector = workshop()->salomeConnector();
132 if (aSalomeConnector)
133 aSalomeConnector->createPreferences();
134 myUpdatePrefs = false;
137 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED)) {
138 myUpdatePrefs = true;
141 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
142 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
143 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
144 onFeatureRedisplayMsg(aUpdMsg);
146 //Update property panel on corresponding message. If there is no current operation (no
147 //property panel), or received message has different feature to the current - do nothing.
148 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
149 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
150 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
151 onFeatureUpdatedMsg(anUpdateMsg);
152 } else if (theMessage->eventID() == Events_LongOp::eventID()) {
153 if (Events_LongOp::isPerformed()) {
154 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
156 QApplication::restoreOverrideCursor();
159 //An operation passed by message. Start it, process and commit.
160 else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) {
161 std::shared_ptr<Config_PointerMessage> aPartSetMsg =
162 std::dynamic_pointer_cast<Config_PointerMessage>(theMessage);
163 //myPropertyPanel->cleanContent();
164 ModuleBase_Operation* anOperation = (ModuleBase_Operation*) aPartSetMsg->pointer();
165 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
167 if (anOperationMgr->startOperation(anOperation)) {
168 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(anOperation);
170 workshop()->propertyPanel()->updateContentWidget(aFOperation->feature());
171 if (!anOperation->getDescription()->hasXmlRepresentation()) {
172 if (anOperation->commit())
173 workshop()->updateCommandStatus();
177 else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_SELFILTER_LOADED)) {
178 std::shared_ptr<Config_SelectionFilterMessage> aMsg =
179 std::dynamic_pointer_cast<Config_SelectionFilterMessage>(theMessage);
181 ModuleBase_FilterFactory* aFactory = myWorkshop->selectionFilters();
182 if (!aMsg->attributeId().empty()) {
183 aFactory->assignFilter(aMsg->selectionFilterId(), aMsg->featureId(), aMsg->attributeId(),
187 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)) {
188 // the viewer's update context will not happens until viewer updated is emitted
189 workshop()->displayer()->enableUpdateViewer(false);
190 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)) {
191 // the viewer's update context is unblocked, the viewer's update works
192 XGUI_Displayer* aDisplayer = workshop()->displayer();
193 aDisplayer->enableUpdateViewer(true);
194 } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED)) {
195 std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
196 std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
197 std::set<ObjectPtr> anObjects = aUpdMsg->objects();
199 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
200 (workshop()->operationMgr()->currentOperation());
201 bool aFeatureChanged = false;
203 FeaturePtr aFeature = aFOperation->feature();
204 if (aFeature.get()) {
205 std::set<ObjectPtr>::const_iterator aIt;
206 for (aIt = anObjects.begin(); aIt != anObjects.end() && !aFeatureChanged; ++aIt) {
207 aFeatureChanged = ModelAPI_Feature::feature(*aIt) == aFeature;
211 workshop()->operationMgr()->onValidateOperation();
214 //Show error dialog if error message received.
215 std::shared_ptr<Events_Error> anAppError = std::dynamic_pointer_cast<Events_Error>(theMessage);
217 emit errorOccurred(QString::fromLatin1(anAppError->description()));
222 SessionPtr aMgr = ModelAPI_Session::get();
223 AppElements_MainWindow* aMainWindow = workshop()->mainWindow();
224 if (aMgr->isModified() != aMainWindow->isModifiedState())
225 aMainWindow->setModifiedState(aMgr->isModified());
229 //******************************************************
230 void XGUI_WorkshopListener::onFeatureUpdatedMsg(
231 const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
233 #ifdef DEBUG_FEATURE_UPDATED
234 std::set<ObjectPtr> anObjects = theMsg->objects();
235 std::set<ObjectPtr>::const_iterator aIt;
237 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
238 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
240 QString anInfoStr = anInfo.join(";\t");
241 qDebug(QString("onFeatureUpdatedMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
243 std::set<ObjectPtr> aFeatures = theMsg->objects();
244 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
245 if (anOperationMgr->hasOperation()) {
246 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
247 (anOperationMgr->currentOperation());
249 FeaturePtr aCurrentFeature = aFOperation->feature();
250 std::set<ObjectPtr>::const_iterator aIt;
251 for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
252 ObjectPtr aNewFeature = (*aIt);
253 if (aNewFeature == aCurrentFeature) {
254 workshop()->propertyPanel()->updateContentWidget(aCurrentFeature);
260 //anOperationMgr->onValidateOperation();
262 //if (myObjectBrowser)
263 // myObjectBrowser->processEvent(theMsg);
266 //******************************************************
267 void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
269 std::set<ObjectPtr> anObjects = theMsg->objects();
270 std::set<ObjectPtr>::const_iterator aIt;
272 #ifdef DEBUG_FEATURE_REDISPLAY
274 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
275 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
277 QString anInfoStr = anInfo.join(";\t");
278 qDebug(QString("onFeatureRedisplayMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
281 XGUI_Workshop* aWorkshop = workshop();
282 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
283 bool aFirstVisualizedBody = false;
285 bool aRedisplayed = false;
286 //std::list<ObjectPtr> aHiddenObjects;
287 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
288 ObjectPtr aObj = (*aIt);
290 // Hide the object if it is invalid or concealed one
291 bool aHide = !aObj->data() || !aObj->data()->isValid() ||
292 aObj->isDisabled() || (!aObj->isDisplayed());
293 if (!aHide) { // check that this is not hidden result
294 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
295 aHide = aRes && aRes->isConcealed();
298 #ifdef DEBUG_RESULT_COMPSOLID
299 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
301 ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
302 if (aCompSolidRes.get()) {
303 qDebug(QString("COMPSOLID, numberOfSubs = %1").arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
305 if (ModelAPI_Tools::compSolidOwner(aRes))
306 qDebug("COMPSOLID sub-object");
309 #ifdef DEBUG_FEATURE_REDISPLAY
310 QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
311 FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
312 if (aFeature.get()) {
313 std::string aKind = aFeature->getKind();
314 if (aKind == DebugFeatureKind) {
315 qDebug(QString("visible=%1, hide=%2 : display= %2").arg(aDisplayer->isVisible(aObj))
316 .arg(aHide).arg(anObjInfo).toStdString().c_str());
321 //we should provide objects which are hidden in the viewer, e.g. sketch always should visualizes
322 // all sub-features, if some features are to be hidden, sould be proposed may be to removed #1223
323 //aHiddenObjects.push_back(aObj);
324 aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
325 #ifdef DEBUG_FEATURE_REDISPLAY
326 // Redisplay the visible object or the object of the current operation
327 bool isVisibleObject = aDisplayer->isVisible(aObj);
329 QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
330 //qDebug(QString("visible=%1 : erase = %2").arg(isVisibleObject).arg(anObjInfo).toStdString().c_str());
334 // Redisplay the visible object or the object of the current operation
335 bool isVisibleObject = aDisplayer->isVisible(aObj);
336 #ifdef DEBUG_FEATURE_REDISPLAY
337 QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
338 //qDebug(QString("visible=%1 : display= %2").arg(isVisibleObject).arg(anObjInfo).toStdString().c_str());
341 if (isVisibleObject) { // redisplay visible object
342 //displayObject(aObj); // In order to update presentation
343 // in order to avoid the check whether the object can be redisplayed, the exact method
344 // of redisplay is called. This modification is made in order to have the line is updated
345 // by creation of a horizontal constraint on the line by preselection
346 if (ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(aObj))) {
347 aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
350 aRedisplayed = aDisplayer->redisplay(aObj, false) || aRedisplayed;
351 // Deactivate object of current operation from selection
352 aWorkshop->deactivateActiveObject(aObj, false);
354 } else { // display object if the current operation has it
355 if (displayObject(aObj, aFirstVisualizedBody)) {
357 // Deactivate object of current operation from selection
358 aWorkshop->deactivateActiveObject(aObj, false);
363 // this processing should be moved in another place in order to do not cause problems in
364 // flush messages chain
365 //if (aHiddenObjects.size() > 0)
366 // myWorkshop->module()->processHiddenObject(aHiddenObjects);
368 bool isCustomized = customizeCurrentObject(anObjects, aRedisplayed);
369 if (aRedisplayed || isCustomized) {
370 //VSV FitAll updated viewer by it self
371 if (aFirstVisualizedBody)
372 myWorkshop->viewer()->fitAll();
374 aDisplayer->updateViewer();
377 //******************************************************
378 void XGUI_WorkshopListener::onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
380 std::set<ObjectPtr> anObjects = theMsg->objects();
381 std::set<ObjectPtr>::const_iterator aIt;
382 #ifdef DEBUG_FEATURE_CREATED
384 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
385 anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
387 QString anInfoStr = anInfo.join(";\t");
388 qDebug(QString("onFeatureCreatedMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
391 bool aFirstVisualizedBody = false;
393 //bool aHasPart = false;
394 bool aDisplayed = false;
395 for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
396 ObjectPtr anObject = *aIt;
398 #ifdef DEBUG_RESULT_COMPSOLID
399 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
401 ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
402 if (aCompSolidRes.get()) {
403 qDebug(QString("COMPSOLID, numberOfSubs = %1").arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
405 if (ModelAPI_Tools::compSolidOwner(aRes))
406 qDebug("COMPSOLID sub-object");
409 // the validity of the data should be checked here in order to avoid display of the objects,
410 // which were created, then deleted, but flush for the creation event happens after that
411 // we should not display disabled objects
412 bool aHide = !anObject->data()->isValid() ||
413 anObject->isDisabled() ||
414 !anObject->isDisplayed();
415 if (!aHide) { // check that this is not hidden result
416 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
417 bool isConcealed = aRes && aRes->isConcealed();
418 aHide = aRes && aRes->isConcealed();
421 // setDisplayed has to be called in order to synchronize internal state of the object
422 // with list of displayed objects
423 if (myWorkshop->module()->canDisplayObject(anObject)) {
424 anObject->setDisplayed(true);
425 aDisplayed = displayObject(*aIt, aFirstVisualizedBody);
427 anObject->setDisplayed(false);
431 bool isCustomized = customizeCurrentObject(anObjects, aDisplayed);
433 //if (myObjectBrowser)
434 // myObjectBrowser->processEvent(theMsg);
436 //VSV FitAll updated viewer by it self
437 if (aFirstVisualizedBody)
438 myWorkshop->viewer()->fitAll();
440 workshop()->displayer()->updateViewer();
442 //if (aHasPart) { // TODO: Avoid activate last part on loading of document
443 // activateLastPart();
447 bool XGUI_WorkshopListener::event(QEvent * theEvent)
449 PostponeMessageQtEvent* aPostponedEv = dynamic_cast<PostponeMessageQtEvent*>(theEvent);
451 std::shared_ptr<Events_Message> aEventPtr = aPostponedEv->postponedMessage();
452 processEvent(aEventPtr);
458 void XGUI_WorkshopListener::addFeature(const std::shared_ptr<Config_FeatureMessage>& theMessage)
462 qDebug() << "XGUI_WorkshopListener::addFeature: NULL message.";
466 ActionInfo aFeatureInfo;
467 aFeatureInfo.initFrom(theMessage);
469 XGUI_Workshop* aWorkshop = workshop();
471 QString aWchName = QString::fromStdString(theMessage->workbenchId());
472 QStringList aNestedFeatures =
473 QString::fromStdString(theMessage->nestedFeatures()).split(" ", QString::SkipEmptyParts);
474 QString aDocKind = QString::fromStdString(theMessage->documentKind());
475 QList<QAction*> aNestedActList;
476 bool isColumnButton = !aNestedFeatures.isEmpty();
477 if (isColumnButton) {
478 QString aNestedActions = QString::fromStdString(theMessage->actionsWhenNested());
479 XGUI_OperationMgr* anOperationMgr = aWorkshop->operationMgr();
480 XGUI_ActionsMgr* anActionsMgr = aWorkshop->actionsMgr();
481 if (aNestedActions.contains(FEATURE_WHEN_NESTED_ACCEPT)) {
482 QAction* anAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL);
483 connect(anAction, SIGNAL(triggered()), anOperationMgr, SLOT(commitAllOperations()));
484 aNestedActList << anAction;
486 if (aNestedActions.contains(FEATURE_WHEN_NESTED_ABORT)) {
487 QAction* anAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AbortAll, NULL);
488 connect(anAction, SIGNAL(triggered()), anOperationMgr, SLOT(abortAllOperations()));
489 aNestedActList << anAction;
494 XGUI_SalomeConnector* aSalomeConnector = aWorkshop->salomeConnector();
496 if (isColumnButton) {
497 aAction = aSalomeConnector->addFeatureOfNested(aWchName, aFeatureInfo, aNestedActList);
499 //Issue #650: in the SALOME mode the tooltip should be same as text
500 aFeatureInfo.toolTip = aFeatureInfo.text;
501 aAction = aSalomeConnector->addFeature(aWchName, aFeatureInfo);
503 aSalomeConnector->setNestedActions(aFeatureInfo.id, aNestedFeatures);
504 aSalomeConnector->setDocumentKind(aFeatureInfo.id, aDocKind);
506 aWorkshop->actionsMgr()->addCommand(aAction);
507 aWorkshop->module()->actionCreated(aAction);
509 //Find or create Workbench
510 AppElements_MainMenu* aMenuBar = aWorkshop->mainWindow()->menuObject();
511 AppElements_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
513 aPage = aWorkshop->addWorkbench(aWchName);
515 //Find or create Group
516 QString aGroupName = QString::fromStdString(theMessage->groupId());
517 AppElements_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
519 aGroup = aPage->addGroup(aGroupName);
521 // Check if hotkey sequence is already defined:
522 XGUI_ActionsMgr* anActionsMgr = aWorkshop->actionsMgr();
523 QKeySequence aHotKey = anActionsMgr->registerShortcut(aFeatureInfo.shortcut);
524 if(aHotKey != aFeatureInfo.shortcut) {
525 aFeatureInfo.shortcut = aHotKey;
528 AppElements_Command* aCommand = aGroup->addFeature(aFeatureInfo,
531 // Enrich created button with accept/abort buttons if necessary
532 AppElements_Button* aButton = aCommand->button();
533 if (aButton->isColumnButton()) {
534 aButton->setAdditionalButtons(aNestedActList);
536 aWorkshop->actionsMgr()->addCommand(aCommand);
537 aWorkshop->module()->actionCreated(aCommand);
542 //**************************************************************
543 bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj, bool& theFirstVisualizedBody)
545 #ifdef DEBUG_RESULT_COMPSOLID
546 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
547 if (aRes.get() && (ModelAPI_Tools::hasSubResults(aRes) || ModelAPI_Tools::compSolidOwner(aRes))) {
548 ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
549 if (aCompSolidRes.get()) {
550 qDebug("COMPSOLID: displayObject");
555 bool aDisplayed = false;
556 XGUI_Workshop* aWorkshop = workshop();
557 // do not display the object if it has sub objects. They should be displayed separately.
558 if (!aWorkshop->module()->canDisplayObject(theObj) ||
559 ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast<ModelAPI_Result>(theObj)))
562 XGUI_Displayer* aDisplayer = aWorkshop->displayer();
563 ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theObj);
564 if (aBody.get() != NULL) {
565 int aNb = aDisplayer->objectsCount();
566 aDisplayed = aDisplayer->display(theObj, false);
568 theFirstVisualizedBody = true;
570 aDisplayed = aDisplayer->display(theObj, false);
575 bool XGUI_WorkshopListener::customizeCurrentObject(const std::set<ObjectPtr>& theObjects,
576 bool theForceRedisplay)
578 XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
579 FeaturePtr aCurrentFeature;
580 if (anOperationMgr->hasOperation()) {
581 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
582 (anOperationMgr->currentOperation());
584 aCurrentFeature = aFOperation->feature();
588 bool aCustomized = false;
589 if (aCurrentFeature.get()) {
590 // the customize presentation should be redisplayed if force redislayed is true or
591 // if a list of message objects contains the operation feature for case when
592 // the feature is hidden, but arguments of the feature are modified
593 // e.g. extrusion is hidden(h=0) but sketch is chosen
594 if (theForceRedisplay || theObjects.find(aCurrentFeature) != theObjects.end()) {
595 aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
596 ModuleBase_IModule::CustomizeArguments, false);
597 aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
598 ModuleBase_IModule::CustomizeResults, false);
599 aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
600 ModuleBase_IModule::CustomizeHighlightedObjects, false);
606 XGUI_Workshop* XGUI_WorkshopListener::workshop() const
608 XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
609 return aConnector->workshop();