ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
ModuleBase_ModelWidget* aCurrentWidget = aPanel->preselectionWidget();
if (!aCurrentWidget)
- aCurrentWidget = aPanel->activeWidget();
+ aCurrentWidget = myWorkshop->module()->activeWidget();
ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
(aCurrentWidget);
ModuleBase_ViewerPrs aPrs;
return 0;\r
}\r
\r
+ /// Returns the active widget, by default it is the property panel active widget\r
+ virtual ModuleBase_ModelWidget* activeWidget() const = 0;\r
+\r
/// Returns current workshop\r
ModuleBase_IWorkshop* workshop() const { return myWorkshop; }\r
\r
//********************************************************************
void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
{
- activateSelection(true);
- activateFilters(true);
+ activateSelectionAndFilters(true);
QList<ModuleBase_ViewerPrs> anEmptyList;
// This method will call Selection changed event which will call onSelectionChanged
// To clear mySelection, myListControl and storeValue()
aShapeTypeName = myTypeCombo->itemText(idx);
TopAbs_ShapeEnum aRefType = ModuleBase_Tools::shapeType(aShapeTypeName);
if(aRefType == theShapeType && idx != myTypeCombo->currentIndex()) {
- activateSelection(false);
- activateFilters(false);
+ activateSelectionAndFilters(false);
bool isBlocked = myTypeCombo->blockSignals(true);
myTypeCombo->setCurrentIndex(idx);
myTypeCombo->blockSignals(isBlocked);
- activateSelection(true);
- activateFilters(true);
+ activateSelectionAndFilters(true);
break;
}
}
}
//********************************************************************
-void ModuleBase_WidgetSelector::activateSelection(bool toActivate)
+void ModuleBase_WidgetSelector::activateSelectionAndFilters(bool toActivate)
{
updateSelectionName();
} else {
myWorkshop->deactivateSubShapesSelection();
}
+ activateFilters(toActivate);
}
//********************************************************************
connect(myWorkshop, SIGNAL(selectionChanged()), this,
SLOT(onSelectionChanged()), Qt::UniqueConnection);
- activateSelection(true);
+ activateSelectionAndFilters(true);
// Restore selection in the viewer by the attribute selection list
myWorkshop->setSelected(getAttributeSelection());
-
- activateFilters(true);
}
//********************************************************************
void ModuleBase_WidgetSelector::deactivate()
{
disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
- activateSelection(false);
- activateFilters(false);
+ activateSelectionAndFilters(false);
+ ModuleBase_ModelWidget::deactivate();
}
/// Defines if it is supposed that the widget should interact with the viewer.
virtual bool isViewerSelector() { return true; }
+ /// Activate or deactivate selection and selection filters
+ void activateSelectionAndFilters(bool toActivate);
+
/// Checks the widget validity. By default, it returns true.
/// \param thePrs a selected presentation in the view
/// \return a boolean value
/// The methiod called when widget is deactivated
virtual void deactivate();
-protected:
- /// Activate or deactivate selection
- void activateSelection(bool toActivate);
-
private slots:
/// Slot which is called on selection event
void onSelectionChanged();
//! Returns data object by AIS
ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
- /// It obtains selection filters from the workshop and activates them in the active viewer
- /// \param toActivate a flag about activation or deactivation the filters
- void activateFilters(const bool toActivate);
-
protected:
/// Creates a backup of the current values of the attribute
/// It should be realized in the specific widget because of different
/// \param theValues a list of presentations.
void filterPresentations(QList<ModuleBase_ViewerPrs>& theValues);
+ /// It obtains selection filters from the workshop and activates them in the active viewer
+ /// \param toActivate a flag about activation or deactivation the filters
+ void activateFilters(const bool toActivate);
+
protected:
/// Reference to workshop
ModuleBase_IWorkshop* myWorkshop;
PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
: ModuleBase_IModule(theWshop),
- myRestartingMode(RM_None), myVisualLayerId(0), myHasConstraintShown(true)
+ myRestartingMode(RM_None), myVisualLayerId(0), myHasConstraintShown(true),
+ myIsInternalEditOperation(false)
{
new PartSet_IconFactory();
FeaturePtr anOperationFeature = aFOperation->feature();
if (anOperationFeature.get() != NULL) {
editFeature(anOperationFeature);
- // 4. activate the first obligatory widget
+ myIsInternalEditOperation = true;
+ onInternalActivateFirstWidgetSelection();
+
+ // activate the last active widget in the Property Panel
if (!myPreviousAttributeID.empty()) {
ModuleBase_Operation* anEditOperation = currentOperation();
if (anEditOperation) {
if (aWidgets[i]->attributeID() == myPreviousAttributeID)
aPreviousAttributeWidget = aWidgets[i];
}
- if (aPreviousAttributeWidget)
+ // If the current widget is a selector, do nothing, it processes the mouse press
+ if (aPreviousAttributeWidget && !aPreviousAttributeWidget->isViewerSelector())
aPreviousAttributeWidget->focusTo();
}
}
}
}
else {
+ // the flag should be reset before start to do not react to the widget deactivate
+ myIsInternalEditOperation = false;
launchOperation(myLastOperationId);
breakOperationSequence();
}
void PartSet_Module::onOperationAborted(ModuleBase_Operation* theOperation)
{
+ myIsInternalEditOperation = false;
breakOperationSequence();
}
{
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(currentOperation());
- if (!aFOperation->isEditOperation())
+ if (/*!aFOperation->isEditOperation() || */myIsInternalEditOperation)
myRestartingMode = RM_EmptyFeatureUsed;
}
}
}
+void PartSet_Module::onInternalActivateFirstWidgetSelection()
+{
+ if (!myIsInternalEditOperation)
+ return;
+
+ ModuleBase_ModelWidget* aFirstWidget = activeWidget();
+ ModuleBase_IPropertyPanel* aPanel = currentOperation()->propertyPanel();
+ if (aFirstWidget != aPanel->activeWidget()) {
+ ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(aFirstWidget);
+ if (aWSelector)
+ aWSelector->activateSelectionAndFilters(true);
+ }
+}
+
void PartSet_Module::onVertexSelected()
{
ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
return aWgt;
}
+ModuleBase_ModelWidget* PartSet_Module::activeWidget() const
+{
+ ModuleBase_ModelWidget* anActiveWidget = 0;
+ ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+ if (aOperation) {
+ ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+ anActiveWidget = aPanel->activeWidget();
+ if (myIsInternalEditOperation && (!anActiveWidget || !anActiveWidget->isViewerSelector())) {
+ // finds the first widget which can accept a value
+ QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+ ModuleBase_ModelWidget* aFirstWidget = 0;
+ ModuleBase_ModelWidget* aWgt;
+ QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
+ for (aWIt = aWidgets.begin(); aWIt != aWidgets.end() && !aFirstWidget; ++aWIt) {
+ aWgt = (*aWIt);
+ if (aWgt->canSetValue())
+ aFirstWidget = aWgt;
+ }
+ if (aFirstWidget)
+ anActiveWidget = aFirstWidget;
+ }
+ }
+
+ return anActiveWidget;
+}
bool PartSet_Module::deleteObjects()
{
// the filters of this widget should be activated in the created view
ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
if (aOperation) {
- ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
- ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
+ ModuleBase_ModelWidget* anActiveWidget = activeWidget();
if (anActiveWidget) {
- ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
- (anActiveWidget);
- if (aWidgetValidated)
- aWidgetValidated->activateFilters(true);
+ ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(anActiveWidget);
+ if (aWSelector)
+ aWSelector->activateSelectionAndFilters(true);
}
}
}
virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
Config_WidgetAPI* theWidgetApi, std::string theParentId);
+ /// Returns the active widget, by default it is the property panel active widget
+ /// If the internal edit operation is started, this is the first widget of the operation
+ virtual ModuleBase_ModelWidget* activeWidget() const;
+
/// Call back forlast tuning of property panel before operation performance
virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
/// Returns list of granted operation indices
virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const;
+ bool isInternalEditOperation() { return myIsInternalEditOperation; }
+
public slots:
/// SLOT, that is called by no more widget signal emitted by property panel
/// Set a specific flag to restart the sketcher operation
void onNoMoreWidgets(const std::string& thePreviousAttributeID);
+ void onInternalActivateFirstWidgetSelection();
+
/// Redefines the parent method in order to customize the next case:
/// If the sketch nested operation is active and the presentation is not visualized in the viewer,
/// the operation should be always aborted.
virtual bool deleteObjects();
private:
- QString myLastOperationId;
- FeaturePtr myLastFeature;
+ QString myLastOperationId;
+ FeaturePtr myLastFeature;
+
+ std::string myPreviousAttributeID;
- std::string myPreviousAttributeID;
+ // Automatical restarting mode flag
+ RestartingMode myRestartingMode;
- // Automatical restarting mode flag
- RestartingMode myRestartingMode;
+ bool myIsInternalEditOperation;
SelectMgr_ListOfFilter mySelectionFilters;
bool PartSet_WidgetEditor::focusTo()
{
PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
- if (aModule->isMouseOverWindow())
+ if (aModule->isMouseOverWindow() && !isEditingMode())
return ModuleBase_WidgetEditor::focusTo();
else {
return ModuleBase_WidgetDoubleValue::focusTo();
myOperationMgr, SLOT(onKeyReleased(QKeyEvent*)));
//connect(myOperationMgr, SIGNAL(validationStateChanged(bool)),
// this, SLOT(onValidationStateChanged(bool)));
+ connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)),
+ myModule, SLOT(onInternalActivateFirstWidgetSelection()));
}
//******************************************************