bool isInternal);\r
};\r
\r
-#endif // CONFIG_MESSAGE_H\r
\ No newline at end of file
+#endif // CONFIG_MESSAGE_H\r
return true;
}
-bool ModuleBase_IOperation::isGranted(ModuleBase_IOperation* /*theOperation*/) const
-{
- return false;
-}
-
/*void ModuleBase_IOperation::setModelWidgets(const std::string& theXmlRepresentation,
QList<ModuleBase_ModelWidget*> theWidgets)
{
#include <QObject>
#include <QString>
#include <QList>
+#include <QStringList>
#include <boost/shared_ptr.hpp>
/// /returns the instance of the description class
ModuleBase_OperationDescription* getDescription() const;
- /// Verifies whether this operator can be always started above any already running one
- /// \return Returns TRUE if current operation must not be checked for ActiveOperation->IsValid( this )
- /// This method must be redefined in derived operation if operation of derived class
- /// must be always can start above any launched one. Default impl returns FALSE,
- /// so it is being checked for IsValid, but some operations may overload IsGranted()
- /// In this case they will always start, no matter what operation is running.
- /// \param theOperation the previous running operation
- virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
+ /**
+ * Must return true if this operation can be launched as nested for any current operation
+ * and it is not necessary to check this operation on validity. By default
+ * the operation is not granted.
+ * The method has to be redefined for granted operations.
+ */
+ virtual bool isGranted() const { return false; }
+
+ /**
+ * Must return True if the given opertation can be launched as nested to current one.
+ * By default it returns false and it has to be redefined for operations which expect
+ * launching of nested operations
+ */
+ virtual bool isValid(ModuleBase_IOperation* theOperation) const { return false; }
/// Sets a list of model widgets, according to the operation feature xml definition
/// \param theXmlRepresentation an xml feature definition
return myIsEditing;
}
+ /// Returns list of nested features
+ QStringList nestedFeatures() const { return myNestedFeatures; }
+
+ /// Sets list of nested features
+ void setNestedFeatures(const QStringList& theList) { myNestedFeatures = theList; }
+
signals:
void started(); /// the operation is started
void aborted(); /// the operation is aborted
private:
ModuleBase_OperationDescription* myDescription; /// the container to have the operation description
+
+ QStringList myNestedFeatures;
};
#endif
return false;
}
-bool PartSet_OperationFeatureCreate::isGranted(ModuleBase_IOperation* theOperation) const
-{
- return theOperation->getDescription()->operationId().toStdString()
- == PartSet_OperationSketch::Type();
-}
-
std::list<int> PartSet_OperationFeatureCreate::getSelectionModes(ObjectPtr theFeature) const
{
std::list<int> aModes;
/// Destructor
virtual ~PartSet_OperationFeatureCreate();
- /// Returns that this operator can be started above already running one.
- /// The runned operation should be the sketch feature modified operation
- /// \param theOperation the previous running operation
- virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
-
/// Returns the operation local selection mode
/// \param theFeature the feature object to get the selection mode
/// \return the selection mode
{
}
-bool PartSet_OperationFeatureEdit::isGranted(ModuleBase_IOperation* theOperation) const
-{
- return theOperation->getDescription()->operationId().toStdString()
- == PartSet_OperationSketch::Type();
-}
-
std::list<int> PartSet_OperationFeatureEdit::getSelectionModes(ObjectPtr theFeature) const
{
return PartSet_OperationSketchBase::getSelectionModes(theFeature);
/// Destructor
virtual ~PartSet_OperationFeatureEdit();
- /// Returns that this operator can be started above already running one.
- /// The runned operation should be the sketch feature modified operation
- /// \param theOperation the previous running operation
- virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
-
/// Returns the operation local selection mode
/// \param theFeature the feature object to get the selection mode
/// \return the selection mode
{
}
-bool PartSet_OperationFeatureEditMulti::isGranted(ModuleBase_IOperation* theOperation) const
-{
- return theOperation->getDescription()->operationId().toStdString()
- == PartSet_OperationSketch::Type();
-}
void PartSet_OperationFeatureEditMulti::initSelection(
const std::list<ModuleBase_ViewerPrs>& theSelected,
/// Destructor
virtual ~PartSet_OperationFeatureEditMulti();
- /// Returns that this operator can be started above already running one.
- /// The runned operation should be the sketch feature modified operation
- /// \param theOperation the previous running operation
- virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
-
/// Initializes the operation with previously created feature. It is used in sequental operations
virtual void initFeature(FeaturePtr theFeature);
/// It is empty and we have to use the process mouse release to start edition operation
/// for these objects
if (theSelected.size() == 1) {
- ObjectPtr aFeature = theSelected.front().object();
- if (aFeature)
- restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
+ ObjectPtr aObject = theSelected.front().object();
+ if (aObject) {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
+ if (aFeature) {
+ QStringList aNested = this->nestedFeatures();
+ if ((!aNested.isEmpty()) && aNested.contains(QString(aFeature->getKind().c_str()))) {
+ restartOperation(PartSet_OperationFeatureEdit::Type(), aObject);
+ }
+ }
+ }
}
}
}
emit closeLocalContext();
emit planeSelected(aDir->x(), aDir->y(), aDir->z());
}
+
+
+bool PartSet_OperationSketch::isValid(ModuleBase_IOperation* theOperation) const
+{
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
+ return aPreviewOp != NULL;
+}
\ No newline at end of file
/// Destructor
virtual ~PartSet_OperationSketch();
+ /// Returns True if the given operation is a Sketcher operation
+ virtual bool isValid(ModuleBase_IOperation* theOperation) const;
+
+
/// Returns the operation local selection mode
/// \param theFeature the feature object to get the selection mode
/// \return the selection mode
if (!aContext->HasOpenedContext()) {
aContext->ClearCurrents(false);
aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
+ //aContext->OpenLocalContext();
+ //aContext->NotUseDisplayedObjects();
}
+ //!!! Test
+ //aContext->UseDisplayedObjects();
+ //std::list<int>::const_iterator anIt = theModes.begin(), aLast = theModes.end();
+ //for (; anIt != aLast; anIt++) {
+ // aContext->ActivateStandardMode((TopAbs_ShapeEnum)(*anIt));
+ //}
+ //!!! Test end
// display or redisplay presentation
Handle(AIS_InteractiveObject) anAIS;
if (isVisible(theResult)) {
{
bool aCanStart = true;
ModuleBase_Operation* aCurrentOp = currentOperation();
- if (aCurrentOp && !theOperation->isGranted(aCurrentOp)) {
- if (canStopOperation()) {
- aCurrentOp->abort();
- } else {
- aCanStart = false;
+ if (aCurrentOp) {
+ if (!theOperation->isGranted()) {
+ if (!aCurrentOp->isValid(theOperation)) {
+ if (canStopOperation()) {
+ aCurrentOp->abort();
+ } else {
+ aCanStart = false;
+ }
+ }
}
}
return aCanStart;
void XGUI_Workshop::onOperationStarted()
{
ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+ aOperation->setNestedFeatures(myActionsMgr->nestedCommands(aOperation->id()));
if (aOperation->getDescription()->hasXmlRepresentation()) { //!< No need for property panel
connectWithOperation(aOperation);