ModuleBase_IconFactory.h
ModuleBase_Dialog.h
ModuleBase_ModelDialogWidget.h
+ ModuleBase_ActionParameter.h
+ ModuleBase_ActionIntParameter.h
)
SET(PROJECT_MOC_HEADERS
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef ModuleBase_ActionIntParameter_H_
+#define ModuleBase_ActionIntParameter_H_
+
+#include "ModuleBase_ActionParameter.h"
+
+class ModuleBase_ActionIntParameter : public ModuleBase_ActionParameter
+{
+public:
+ ModuleBase_ActionIntParameter(int theVal):ModuleBase_ActionParameter(), myVal(theVal) {}
+
+ int value() const { return myVal; }
+
+private:
+ int myVal;
+};
+
+typedef std::shared_ptr<ModuleBase_ActionIntParameter> ActionIntParamPtr;
+
+#endif
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef ModuleBase_ActionParameter_H_
+#define ModuleBase_ActionParameter_H_
+
+#include <memory>
+
+class ModuleBase_ActionParameter
+{
+public:
+ /// Destuctor is added in order to virtualize the class
+ virtual ~ModuleBase_ActionParameter() {}
+};
+
+typedef std::shared_ptr<ModuleBase_ActionParameter> ActionParamPtr;
+
+#endif
\ No newline at end of file
#ifndef ModuleBase_ActionType_H_
#define ModuleBase_ActionType_H_
-#include <ModuleBase.h>
-
/*!
* Structure to describe widget processed types of actions.
*/
-enum MODULEBASE_EXPORT ModuleBase_ActionType
+enum ModuleBase_ActionType
{
ActionEnter,
ActionEscape,
}
}
-bool ModuleBase_ModelWidget::processAction(ModuleBase_ActionType theActionType)
+bool ModuleBase_ModelWidget::processAction(ModuleBase_ActionType theActionType,
+ const ActionParamPtr& theParam)
{
switch (theActionType) {
case ActionEnter:
#include <ModuleBase_ActionType.h>
#include <ModuleBase_OperationFeature.h>
#include <ModuleBase_ActionInfo.h>
+#include <ModuleBase_ActionParameter.h>
#include <ModelAPI_Feature.h>
#include <QWidget>
virtual bool canProcessAction(ModuleBase_ActionType theActionType, bool& isActionEnabled);
/// Returns true if the event is processed. The default implementation is empty, returns false.
- virtual bool processAction(ModuleBase_ActionType theActionType);
+ virtual bool processAction(ModuleBase_ActionType theActionType,
+ const ActionParamPtr& theParam = ActionParamPtr());
/// Returns list of accessible actions for Undo/Redo commands. By default it returns empty list.
/// \param theActionType type of action. It can be ActionUndo or ActionRedo.
afterCommitOperation();
#ifdef DEBUG_OPERATION_START
- qDebug("ModuleBase_OperationFeature::commit -- end : IMPOSSIBLE to commit");
+ qDebug("ModuleBase_OperationFeature::commit -- end");
#endif
return true;
}
#ifdef DEBUG_OPERATION_START
- qDebug("ModuleBase_OperationFeature::commit -- end");
+ qDebug("ModuleBase_OperationFeature::commit -- end : IMPOSSIBLE to commit");
#endif
return false;
}
}
//********************************************************************
-bool ModuleBase_WidgetFeatureSelector::processAction(ModuleBase_ActionType theActionType)
+bool ModuleBase_WidgetFeatureSelector::processAction(ModuleBase_ActionType theActionType,
+ const ActionParamPtr& theParam)
{
if (theActionType == ActionSelection)
onSelectionChanged();
else
- return ModuleBase_WidgetValidated::processAction(theActionType);
+ return ModuleBase_WidgetValidated::processAction(theActionType, theParam);
return true;
}
virtual void deactivate();
/// Processes Selection action.
- virtual bool processAction(ModuleBase_ActionType theActionType);
+ virtual bool processAction(ModuleBase_ActionType theActionType,
+ const ActionParamPtr& theParam = ActionParamPtr());
protected:
/// The method called when widget is activated
#include <ModuleBase_Tools.h>
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_WidgetShapeSelector.h>
+#include <ModuleBase_ActionIntParameter.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
}
//********************************************************************
-bool ModuleBase_WidgetMultiSelector::processAction(ModuleBase_ActionType theActionType)
+bool ModuleBase_WidgetMultiSelector::processAction(ModuleBase_ActionType theActionType,
+ const ActionParamPtr& theParam)
{
switch (theActionType) {
case ActionUndo:
case ActionRedo: {
+ ActionIntParamPtr aParam =
+ std::dynamic_pointer_cast<ModuleBase_ActionIntParameter>(theParam);
+ int aNb = aParam->value();
if (theActionType == ActionUndo)
- myCurrentHistoryIndex--;
+ myCurrentHistoryIndex -= aNb;
else
- myCurrentHistoryIndex++;
+ myCurrentHistoryIndex += aNb;
QList<ModuleBase_ViewerPrsPtr> aSelected = mySelectedHistoryValues[myCurrentHistoryIndex];
// equal vertices should not be used here
ModuleBase_ISelection::filterSelectionOnEqualPoints(aSelected);
return true;
}
default:
- return ModuleBase_ModelWidget::processAction(theActionType);
+ return ModuleBase_ModelWidget::processAction(theActionType, theParam);
}
}
if (myCurrentHistoryIndex > -1) {
int i = 0;
QString aTitle("Selection %1 items");
+ QString aTit("Selection %1 item");
QIcon aIcon(":pictures/selection.png");
+ int aNb;
switch (theActionType) {
case ActionUndo:
i = 1;
while (i <= myCurrentHistoryIndex) {
- ActionInfo aInfo(aIcon, aTitle.arg(mySelectedHistoryValues.at(i).count()));
- aList.append(aInfo);
+ aNb = mySelectedHistoryValues.at(i).count();
+ if (aNb == 1) {
+ ActionInfo aInfo(aIcon, aTit.arg(aNb));
+ aList.insert(0, aInfo);
+ } else {
+ ActionInfo aInfo(aIcon, aTitle.arg(aNb));
+ aList.insert(0, aInfo);
+ }
i++;
}
break;
case ActionRedo:
i = mySelectedHistoryValues.length() - 1;
while (i > myCurrentHistoryIndex) {
- ActionInfo aInfo(aIcon, aTitle.arg(mySelectedHistoryValues.at(i).count()));
- aList.append(aInfo);
+ aNb = mySelectedHistoryValues.at(i).count();
+ if (aNb == 1) {
+ ActionInfo aInfo(aIcon, aTit.arg(mySelectedHistoryValues.at(i).count()));
+ aList.insert(0, aInfo);
+ } else {
+ ActionInfo aInfo(aIcon, aTitle.arg(mySelectedHistoryValues.at(i).count()));
+ aList.insert(0, aInfo);
+ }
i--;
}
break;
virtual bool canProcessAction(ModuleBase_ActionType theActionType, bool& isActionEnabled);
/// Returns true if the event is processed. The default implementation is empty, returns false.
- virtual bool processAction(ModuleBase_ActionType theActionType);
+ virtual bool processAction(ModuleBase_ActionType theActionType,
+ const ActionParamPtr& theParam = ActionParamPtr());
/// Activate or deactivate selection and selection filters
/// \return true if the selection filter of the widget is activated in viewer context
}
//********************************************************************
-bool PartSet_WidgetSketchLabel::processAction(ModuleBase_ActionType theActionType)
+bool PartSet_WidgetSketchLabel::processAction(ModuleBase_ActionType theActionType,
+ const ActionParamPtr& theParam)
{
if (theActionType == ActionSelection)
onSelectionChanged();
else
- return ModuleBase_WidgetValidated::processAction(theActionType);
+ return ModuleBase_WidgetValidated::processAction(theActionType, theParam);
return true;
}
static bool canFillSketch(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
/// Processes Selection action.
- virtual bool processAction(ModuleBase_ActionType theActionType);
+ virtual bool processAction(ModuleBase_ActionType theActionType,
+ const ActionParamPtr& theParam);
signals:
/// Signal on plane selection
#include <ModuleBase_WidgetValidated.h>
#include <ModuleBase_ModelWidget.h>
#include <ModuleBase_ResultPrs.h>
+#include <ModuleBase_ActionIntParameter.h>
#include <Config_Common.h>
#include <Config_FeatureMessage.h>
void XGUI_Workshop::onUndo(int theTimes)
{
ModuleBase_ModelWidget* anActiveWidget = myOperationMgr->activeWidget();
- if (anActiveWidget && anActiveWidget->processAction(ActionUndo))
- return;
+ if (anActiveWidget) {
+ ActionIntParamPtr aParam(new ModuleBase_ActionIntParameter(theTimes));
+ if (anActiveWidget->processAction(ActionUndo, aParam))
+ return;
+ }
objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
SessionPtr aMgr = ModelAPI_Session::get();
void XGUI_Workshop::onRedo(int theTimes)
{
ModuleBase_ModelWidget* anActiveWidget = myOperationMgr->activeWidget();
- if (anActiveWidget && anActiveWidget->processAction(ActionRedo))
- return;
+ if (anActiveWidget) {
+ ActionIntParamPtr aParam(new ModuleBase_ActionIntParameter(theTimes));
+ if (anActiveWidget->processAction(ActionRedo, aParam))
+ return;
+ }
// the viewer update should be blocked in order to avoid the features blinking. For the created
// feature a results are created, the flush of the created signal caused the viewer redisplay for