Salome HOME
Fix too long line (>100 characters)
[modules/shaper.git] / src / XGUI / XGUI_PropertyPanel.cpp
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include <XGUI_ActionsMgr.h>
21 #include <XGUI_ActiveControlMgr.h>
22 #include <XGUI_SelectionActivate.h>
23 #include <XGUI_ActiveControlSelector.h>
24 #include <XGUI_PropertyPanel.h>
25 #include <XGUI_PropertyPanelSelector.h>
26 #include <XGUI_OperationMgr.h>
27 #include <XGUI_Tools.h>
28 #include <XGUI_Workshop.h>
29
30 //#include <AppElements_Constants.h>
31 #include <ModuleBase_WidgetMultiSelector.h>
32 #include <ModuleBase_Tools.h>
33 #include <ModuleBase_PageBase.h>
34 #include <ModuleBase_PageWidget.h>
35 #include <ModuleBase_WidgetFactory.h>
36 #include <ModuleBase_OperationDescription.h>
37 #include <ModuleBase_Events.h>
38 #include <ModuleBase_IModule.h>
39 #include <ModuleBase_IWorkshop.h>
40
41 #include <Events_Loop.h>
42
43 #include <ModelAPI_Session.h>
44 #include <ModelAPI_Validator.h>
45
46 #include <QEvent>
47 #include <QFrame>
48 #include <QIcon>
49 #include <QKeyEvent>
50 #include <QLayoutItem>
51 #include <QToolButton>
52 #include <QVBoxLayout>
53 #include <QGridLayout>
54 #include <QWidget>
55 #include <QAction>
56
57 #ifdef _DEBUG
58 #include <iostream>
59 #endif
60
61 //#define DEBUG_TAB_WIDGETS
62
63 //#define DEBUG_ACTIVE_WIDGET
64
65 XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr)
66     : ModuleBase_IPropertyPanel(theParent),
67     myActiveWidget(NULL),
68     myPreselectionWidget(NULL),
69     myInternalActiveWidget(NULL),
70     myPanelPage(NULL),
71     myOperationMgr(theMgr)
72 {
73   setWindowTitle(tr("Property Panel"));
74   QAction* aViewAct = toggleViewAction();
75   setObjectName(PROP_PANEL);
76   setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
77
78   QWidget* aContent = new QWidget(this);
79   QGridLayout* aMainLayout = new QGridLayout(aContent);
80   const int kPanelColumn = 0;
81   int aPanelRow = 0;
82   aMainLayout->setContentsMargins(3, 3, 3, 3);
83   setWidget(aContent);
84
85   QFrame* aFrm = new QFrame(aContent);
86   aFrm->setFrameStyle(QFrame::Raised);
87   aFrm->setFrameShape(QFrame::Panel);
88   QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
89   ModuleBase_Tools::zeroMargins(aBtnLay);
90   aMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
91
92   myHeaderWidget = aFrm;
93
94   QStringList aBtnNames;
95   aBtnNames << QString(PROP_PANEL_HELP)
96             << QString(PROP_PANEL_OK)
97             << QString(PROP_PANEL_OK_PLUS)
98             << QString(PROP_PANEL_CANCEL);
99   foreach(QString eachBtnName, aBtnNames) {
100     QToolButton* aBtn = new QToolButton(aFrm);
101     aBtn->setObjectName(eachBtnName);
102     aBtn->setAutoRaise(true);
103     aBtnLay->addWidget(aBtn);
104   }
105   aBtnLay->insertStretch(1, 1);
106
107   myPanelPage = new ModuleBase_PageWidget(aContent);
108   myPanelPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
109   aMainLayout->addWidget(myPanelPage, aPanelRow, kPanelColumn);
110
111   // spit to make the preview button on the bottom of the panel
112   aMainLayout->setRowStretch(aPanelRow++, 1);
113
114   // preview button on the bottom of panel
115   aFrm = new QFrame(aContent);
116   aBtnLay = new QHBoxLayout(aFrm);
117   aBtnLay->addStretch(1);
118   ModuleBase_Tools::zeroMargins(aBtnLay);
119   aMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
120
121   QToolButton* aBtn = new QToolButton(aFrm);
122   aBtn->setObjectName(PROP_PANEL_PREVIEW);
123   aBtnLay->addWidget(aBtn);
124 }
125
126 XGUI_PropertyPanel::~XGUI_PropertyPanel()
127 {
128 }
129
130 void XGUI_PropertyPanel::cleanContent()
131 {
132   if (myActiveWidget)
133     myActiveWidget->deactivate();
134
135   XGUI_ActiveControlSelector* aPPSelector = XGUI_Tools::workshop(myOperationMgr->workshop())->
136     activeControlMgr()->getSelector(XGUI_PropertyPanelSelector::Type());
137   aPPSelector->reset(); // it removes need to be updated widget link
138
139   /// as the widgets are deleted later, it is important that the signals
140   /// of these widgets are not processed. An example of the error is issue 986.
141   /// In the given case, the property panel is firstly filled by new widgets
142   /// of restarted operation and after that the mouse release signal come from
143   /// the widget of the previous operation (Point2d widget about mouse is released
144   /// and focus is out of this widget)
145   QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(),
146                                                  aLast = myWidgets.end();
147   for (; anIt != aLast; anIt++) {
148     QWidget* aWidget = *anIt;
149     if (aWidget) {
150       aWidget->blockSignals(true);
151     }
152   }
153
154   myWidgets.clear();
155   myPanelPage->clearPage();
156   myActiveWidget = NULL;
157   emit propertyPanelDeactivated();
158   myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
159   myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
160 #ifdef DEBUG_ACTIVE_WIDGET
161   std::cout << "myActiveWidget = NULL" << std::endl;
162 #endif
163
164   findButton(PROP_PANEL_PREVIEW)->setVisible(false); /// by default it is hidden
165   setWindowTitle(tr("Property Panel"));
166 }
167
168 void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets)
169 {
170   myWidgets = theWidgets;
171   if (theWidgets.empty())
172     return;
173   foreach (ModuleBase_ModelWidget* aWidget, theWidgets) {
174     connect(aWidget, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
175             this,    SLOT(onFocusInWidget(ModuleBase_ModelWidget*)));
176     connect(aWidget, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
177             this,    SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
178     connect(aWidget, SIGNAL(keyReleased(QObject*, QKeyEvent*)),
179             this,    SIGNAL(keyReleased(QObject*, QKeyEvent*)));
180     connect(aWidget, SIGNAL(enterClicked(QObject*)),
181             this,    SIGNAL(enterClicked(QObject*)));
182   }
183 }
184
185 const QList<ModuleBase_ModelWidget*>& XGUI_PropertyPanel::modelWidgets() const
186 {
187   return myWidgets;
188 }
189
190 ModuleBase_PageBase* XGUI_PropertyPanel::contentWidget()
191 {
192   return static_cast<ModuleBase_PageBase*>(myPanelPage);
193 }
194
195 void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
196 {
197   // Invalid feature case on abort of the operation
198   if (theFeature.get() == NULL)
199     return;
200   if (theFeature->isAction() || !theFeature->data())
201     return;
202   foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
203     if (!eachWidget->feature().get())
204       eachWidget->setFeature(theFeature);
205     eachWidget->restoreValue();
206   }
207   // the repaint is used here to immediately react in GUI to the values change.
208   repaint();
209 }
210
211 void XGUI_PropertyPanel::createContentPanel(FeaturePtr theFeature)
212 {
213   // Invalid feature case on abort of the operation
214   if (theFeature.get() == NULL)
215     return;
216   if (theFeature->isAction() || !theFeature->data())
217     return;
218
219   if (myWidgets.empty()) {
220     ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
221     QString aXmlRepr = anOperation->getDescription()->xmlRepresentation();
222
223     ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myOperationMgr->workshop());
224     aFactory.createPanel(contentWidget(), theFeature);
225     /// Apply button should be update if the feature was modified by the panel
226     myOperationMgr->onValidateOperation();
227   }
228   std::shared_ptr<Config_FeatureMessage> aFeatureInfo =
229     myOperationMgr->workshop()->featureInfo(theFeature->getKind().c_str());
230   if (aFeatureInfo.get())
231     findButton(PROP_PANEL_OK_PLUS)->setVisible(aFeatureInfo->isApplyContinue());
232 }
233
234 ModuleBase_ModelWidget* XGUI_PropertyPanel::activeWidget(const bool isUseCustomWidget) const
235 {
236   if (isUseCustomWidget && myInternalActiveWidget)
237     return myInternalActiveWidget;
238
239   return myActiveWidget;
240 }
241
242 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
243 {
244   // it is possible that the property panel widgets have not been visualized
245   // (e.g. on start operation), so it is strictly important to do not check visualized state
246   activateNextWidget(theWidget, false);
247 }
248
249 void XGUI_PropertyPanel::onFocusInWidget(ModuleBase_ModelWidget* theWidget)
250 {
251 #ifdef DEBUG_ACTIVE_WIDGET
252   std::cout << "onFocusInWidget" << std::endl;
253 #endif
254   if (theWidget->canAcceptFocus())
255     activateWidget(theWidget);
256 }
257
258 void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget)
259 {
260   // this slot happens when some widget lost focus, the next widget which accepts the focus
261   // should be shown, so the second parameter is true
262   // it is important for features where in cases the same attributes are used, isCase for this
263   // attribute returns true, however it can be placed in hidden stack widget(extrusion: elements,
264   // sketch multi rotation -> single/full point)
265   // it is important to check the widget visibility to do not check of the next widget visible
266   // state if the current is not shown. (example: sketch circle re-entrant operation after mouse
267   // release in the viewer, next, radius,
268   // widget should be activated but the first is not visualized)
269   bool isVisible = theWidget->isVisible();
270   activateNextWidget(theWidget, isVisible);
271 }
272
273
274 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget,
275                                             const bool isCheckVisibility)
276 {
277   // TO CHECK: Editing operation does not have automatical activation of widgets
278   if (isEditingMode()) {
279     activateWidget(NULL);
280     return;
281   }
282   ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
283
284   QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end();
285   bool isFoundWidget = false;
286   ModuleBase_Tools::activateWindow(this, "XGUI_PropertyPanel::activateNextWidget()");
287   for (; anIt != aLast; anIt++) {
288     ModuleBase_ModelWidget* aCurrentWidget = *anIt;
289     if (isFoundWidget || !theWidget) {
290
291       if (!aValidators->isCase(aCurrentWidget->feature(), aCurrentWidget->attributeID()))
292         continue; // this attribute does not participate in the current case
293       if (isCheckVisibility && !aCurrentWidget->isInternal()) {
294         if (!aCurrentWidget->isVisible())
295           continue;
296       }
297       if (!aCurrentWidget->isObligatory())
298         continue; // not obligatory widgets are not activated automatically
299
300       if (!aCurrentWidget->canAcceptFocus())
301         continue; // do not set focus if it can not be accepted, case: optional choice
302
303       if (aCurrentWidget->focusTo()) {
304         aCurrentWidget->emitFocusInWidget();
305         return;
306       }
307     }
308     isFoundWidget = isFoundWidget || (*anIt) == theWidget;
309   }
310   // set focus to Ok/Cancel button in Property panel if there are no more active widgets
311   // it should be performed before activateWidget(NULL) because it emits some signals which
312   // can be processed by moudule for example as to activate another widget with setting focus
313   QWidget* aNewFocusWidget = 0;
314   QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
315   if (anOkBtn->isEnabled())
316     aNewFocusWidget = anOkBtn;
317   else {
318     QToolButton* aCancelBtn = findButton(PROP_PANEL_CANCEL);
319     if (aCancelBtn->isEnabled())
320       aNewFocusWidget = aCancelBtn;
321   }
322   if (aNewFocusWidget)
323     ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::activateNextWidget");
324
325   activateWidget(NULL);
326 }
327
328 void findDirectChildren(QWidget* theParent, QList<QWidget*>& theWidgets, const bool theDebug)
329 {
330   QList<QWidget*> aWidgets;
331
332   if (theParent) {
333     QLayout* aLayout = theParent->layout();
334     if (aLayout) {
335       for (int i = 0, aCount = aLayout->count(); i < aCount; i++) {
336         QLayoutItem* anItem = aLayout->itemAt(i);
337         QWidget* aWidget = anItem ? anItem->widget() : 0;
338         if (aWidget) {
339           if (aWidget->isVisible()) {
340             if (aWidget->focusPolicy() != Qt::NoFocus)
341               theWidgets.append(aWidget);
342             findDirectChildren(aWidget, theWidgets, false);
343           }
344         }
345         else if (anItem->layout()) {
346           QLayout* aLayout = anItem->layout();
347           for (int i = 0, aCount = aLayout->count(); i < aCount; i++) {
348             QLayoutItem* anItem = aLayout->itemAt(i);
349             QWidget* aWidget = anItem ? anItem->widget() : 0;
350             if (aWidget) {
351               if (aWidget->isVisible()) {
352                 if (aWidget->focusPolicy() != Qt::NoFocus)
353                   theWidgets.append(aWidget);
354                 findDirectChildren(aWidget, theWidgets, false);
355               }
356             }
357             else {
358               // TODO: improve recursive search for the case when here QLayout is used
359               // currently, the switch widget uses only 1 level of qlayout in qlayout using for
360               // example for construction plane feature. If there are more levels,
361               // it should be implemented here
362             }
363           }
364         }
365       }
366     }
367   }
368 #ifdef DEBUG_TAB_WIDGETS
369   if (theDebug) {
370     QStringList aWidgetTypes;
371     QList<QWidget*>::const_iterator anIt =  theWidgets.begin(), aLast = theWidgets.end();
372     for (; anIt != aLast; anIt++) {
373       QWidget* aWidget = *anIt;
374       if (aWidget)
375         aWidgetTypes.append(aWidget->objectName());
376     }
377     QString anInfo = QString("theWidgets[%1]: %2")
378       .arg(theWidgets.count()).arg(aWidgetTypes.join(","));
379     qDebug(anInfo.toStdString().c_str());
380   }
381 #endif
382 }
383
384 bool XGUI_PropertyPanel::setFocusNextPrevChild(bool theIsNext)
385 {
386   return focusNextPrevChild(theIsNext);
387 }
388
389 bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext)
390 {
391   // it wraps the Tabs clicking to follow in the chain:
392   // controls, last control, Apply, Cancel, first control, controls
393   bool isChangedFocus = false;
394
395   QWidget* aFocusWidget = focusWidget();
396 #ifdef DEBUG_TAB_WIDGETS
397   if (aFocusWidget) {
398     QString anInfo = QString("focus Widget: %1").arg(aFocusWidget->objectName());
399     qDebug(anInfo.toStdString().c_str());
400   }
401 #endif
402   ModuleBase_ModelWidget* aFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this,
403                                                                          aFocusWidget);
404   //if (aFocusMWidget)
405   //  aFocusMWidget->setHighlighted(false);
406
407   QWidget* aNewFocusWidget = 0;
408   if (aFocusWidget) {
409     QList<QWidget*> aChildren;
410     findDirectChildren(this, aChildren, true);
411     int aChildrenCount = aChildren.count();
412     int aFocusWidgetIndex = aChildren.indexOf(aFocusWidget);
413     QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
414     if (aFocusWidgetIndex >= 0) {
415       if (theIsNext) {
416         if (aFocusWidgetIndex == aChildrenCount-1) {
417           // after the last widget focus should be set to "Apply"
418           if (anOkBtn->isEnabled())
419             aNewFocusWidget = anOkBtn;
420           else {
421             QToolButton* aCancelBtn = findButton(PROP_PANEL_CANCEL);
422             if (aCancelBtn->isEnabled())
423               aNewFocusWidget = aCancelBtn;
424           }
425         }
426         else {
427           aNewFocusWidget = aChildren[aFocusWidgetIndex+1];
428         }
429       }
430       else {
431         if (aFocusWidgetIndex == 0) {
432           // before the first widget, the last should accept focus
433           aNewFocusWidget = aChildren[aChildrenCount - 1];
434         }
435         else {
436           // before the "Apply" button, the last should accept focus for consistency with "Next"
437           if (aFocusWidget == anOkBtn) {
438             aNewFocusWidget = aChildren[aChildrenCount - 1];
439           }
440           else {
441             aNewFocusWidget = aChildren[aFocusWidgetIndex-1];
442           }
443         }
444       }
445     }
446   }
447   if (aNewFocusWidget) {
448     if (myActiveWidget) {
449       bool isFirstControl = !theIsNext;
450       QWidget* aLastFocusControl = myActiveWidget->getControlAcceptingFocus(isFirstControl);
451       if (aFocusWidget == aLastFocusControl) {
452         setActiveWidget(NULL, false);
453       }
454     }
455
456     // we want to have property panel as an active window to enter values in double control
457     ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::focusNextPrevChild()");
458
459     ModuleBase_ModelWidget* aNewFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this,
460                                                                               aNewFocusWidget);
461     if (aNewFocusMWidget) {
462       if (aFocusMWidget) {
463         aFocusMWidget->setHighlighted(false);
464       }
465       aNewFocusMWidget->emitFocusInWidget();
466       isChangedFocus = true;
467     }
468   }
469   return isChangedFocus;
470 }
471
472 void XGUI_PropertyPanel::activateNextWidget()
473 {
474   activateNextWidget(myActiveWidget);
475 }
476
477 void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget, const bool theEmitSignal)
478 {
479   std::string aPreviosAttributeID;
480   if(myActiveWidget)
481     aPreviosAttributeID = myActiveWidget->attributeID();
482
483   // Avoid activation of already actve widget. It could happen on focusIn event many times
484   setActiveWidget(theWidget, theEmitSignal);
485 }
486
487 bool XGUI_PropertyPanel::setActiveWidget(ModuleBase_ModelWidget* theWidget, const bool isEmitSignal)
488 {
489   // Avoid activation of already actve widget. It could happen on focusIn event many times
490   if (theWidget == myActiveWidget) {
491     return false;
492   }
493   std::string aPreviosAttributeID;
494   ModuleBase_ModelWidget* aDeactivatedWidget = NULL, *anActivatedWidget = NULL;
495   if(myActiveWidget) {
496     aPreviosAttributeID = myActiveWidget->attributeID();
497     myActiveWidget->processValueState();
498     myActiveWidget->deactivate();
499     myActiveWidget->setHighlighted(false);
500     aDeactivatedWidget = myActiveWidget;
501   }
502   if(theWidget) {
503     emit beforeWidgetActivated(theWidget);
504     theWidget->setHighlighted(true);
505     theWidget->activate();
506     anActivatedWidget = theWidget;
507   }
508   myActiveWidget = theWidget;
509
510 #ifdef DEBUG_ACTIVE_WIDGET
511   std::cout << "myActiveWidget = " << (theWidget ? theWidget->context().c_str() : "") << std::endl;
512 #endif
513   bool aHasMoreWidgets = true;
514   if (isEmitSignal) {
515     //emit widgetActivated(myActiveWidget);
516     if (!myActiveWidget && !isEditingMode()) {
517       aHasMoreWidgets = false;
518       emit noMoreWidgets(aPreviosAttributeID);
519     }
520   }
521   if (myActiveWidget)
522     emit propertyPanelActivated();
523   else
524     emit propertyPanelDeactivated();
525   myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
526   myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
527
528   if (aHasMoreWidgets && aDeactivatedWidget)
529     aDeactivatedWidget->updateAfterDeactivation();
530   if (aHasMoreWidgets && anActivatedWidget)
531     anActivatedWidget->updateAfterActivation();
532
533   if (aHasMoreWidgets && myActiveWidget)
534   {
535     // restore widget selection should be done after selection modes of widget activating
536     static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
537     Events_Loop::loop()->flush(anEvent);
538   }
539   return true;
540 }
541
542 void XGUI_PropertyPanel::setFocusOnOkButton()
543 {
544   QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
545   ModuleBase_Tools::setFocus(anOkBtn, "XGUI_PropertyPanel::setFocusOnOkButton()");
546 }
547
548 void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)
549 {
550   QToolButton* anCancelBtn = findButton(PROP_PANEL_CANCEL);
551   anCancelBtn->setEnabled(theEnabled);
552 }
553
554 bool XGUI_PropertyPanel::isCancelEnabled() const
555 {
556   QToolButton* anCancelBtn = findButton(PROP_PANEL_CANCEL);
557   return anCancelBtn->isEnabled();
558 }
559
560 void XGUI_PropertyPanel::setEditingMode(bool isEditing)
561 {
562   ModuleBase_IPropertyPanel::setEditingMode(isEditing);
563   foreach(ModuleBase_ModelWidget* aWgt, myWidgets) {
564     aWgt->setEditingMode(isEditing);
565   }
566 }
567
568 void XGUI_PropertyPanel::setupActions(XGUI_ActionsMgr* theMgr)
569 {
570   QStringList aButtonNames;
571   aButtonNames << PROP_PANEL_OK<< PROP_PANEL_OK_PLUS << PROP_PANEL_CANCEL
572                << PROP_PANEL_HELP << PROP_PANEL_PREVIEW;
573   QList<XGUI_ActionsMgr::OperationStateActionId> aActionIds;
574   aActionIds << XGUI_ActionsMgr::Accept << XGUI_ActionsMgr::AcceptPlus << XGUI_ActionsMgr::Abort
575              << XGUI_ActionsMgr::Help << XGUI_ActionsMgr::Preview;
576   for (int i = 0; i < aButtonNames.size(); ++i) {
577     QToolButton* aBtn = findButton(aButtonNames.at(i).toStdString().c_str());
578     QAction* anAct = theMgr->operationStateAction(aActionIds.at(i));
579     aBtn->setDefaultAction(anAct);
580   }
581 }
582
583 void XGUI_PropertyPanel::onAcceptData()
584 {
585   foreach (ModuleBase_ModelWidget* aWidget, myWidgets) {
586     aWidget->onFeatureAccepted();
587   }
588 }
589
590 void XGUI_PropertyPanel::setInternalActiveWidget(ModuleBase_ModelWidget* theWidget)
591 {
592   if (theWidget)
593   {
594     myInternalActiveWidget = theWidget;
595     emit propertyPanelActivated();
596   }
597   else
598   {
599     if (myInternalActiveWidget)
600     {
601       delete myInternalActiveWidget;
602       myInternalActiveWidget = 0;
603     }
604     emit propertyPanelDeactivated();
605   }
606   myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
607   myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
608 }
609
610 ModuleBase_ModelWidget* XGUI_PropertyPanel::preselectionWidget() const
611 {
612   return myPreselectionWidget;
613 }
614
615 void XGUI_PropertyPanel::setPreselectionWidget(ModuleBase_ModelWidget* theWidget)
616 {
617   myPreselectionWidget = theWidget;
618 }
619
620
621 void XGUI_PropertyPanel::closeEvent(QCloseEvent* theEvent)
622 {
623   ModuleBase_Operation* aOp = myOperationMgr->currentOperation();
624   if (aOp) {
625     if (myOperationMgr->canStopOperation(aOp)) {
626       myOperationMgr->abortOperation(aOp);
627       if (myOperationMgr->hasOperation())
628         theEvent->ignore();
629       else
630         theEvent->accept();
631     } else
632       theEvent->ignore();
633   } else
634     ModuleBase_IPropertyPanel::closeEvent(theEvent);
635 }
636
637 QToolButton* XGUI_PropertyPanel::findButton(const char* theInternalName) const
638 {
639   return findChild<QToolButton*>(theInternalName);
640 }