CONFIG_EXPORT void setInternal(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
#include <GeomAPI_AISObject.h>
#include <AIS_Shape.hxx>
+#include <StdSelect_FaceFilter.hxx>
+#include <StdSelect_TypeOfFace.hxx>
+
#include <QObject>
#include <QMouseEvent>
#include <QString>
void PartSet_Module::onCloseLocalContext()
{
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ aDisplayer->deactivateObjectsOutOfContext();
aDisplayer->closeLocalContexts();
}
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
std::list<int> aModes = aPreviewOp->getSelectionModes(theFeature);
aDisplayer->activateInLocalContext(theFeature, aModes, isUpdateViewer);
+
+ // If this is a Sketcher then activate objects (planar faces) outside of context
+ PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
+ if (aSketchOp) {
+ Handle(StdSelect_FaceFilter) aFilter = new StdSelect_FaceFilter(StdSelect_Plane);
+ aDisplayer->activateObjectsOutOfContext(aModes, aFilter);
+ }
}
}
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) {
+ 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;
+}
+
/// 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
void PartSet_OperationSketchBase::restartOperation(const std::string& theType, ObjectPtr theFeature)
{
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theFeature);
+ if (aFeature) {
+ QStringList aNested = this->nestedFeatures();
+ if (!aNested.isEmpty()) {
+ if (aNested.contains(QString(aFeature->getKind().c_str())))
+ emit launchOperation(theType, theFeature);
+ else
+ return;
+ }
+ }
emit launchOperation(theType, theFeature);
}
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_DimensionSelectionMode.hxx>
-
#include <AIS_Shape.hxx>
#include <set>
// Open local context if there is no one
if (!aContext->HasOpenedContext()) {
aContext->ClearCurrents(false);
- aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
+ //aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
+ aContext->OpenLocalContext();
+ aContext->NotUseDisplayedObjects();
}
// display or redisplay presentation
Handle(AIS_InteractiveObject) anAIS;
void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
{
+ AISContext()->ClearSelected(false);
closeAllContexts(true);
}
}
}
+void XGUI_Displayer::activateObjectsOutOfContext(const std::list<int>& theModes,
+ Handle(SelectMgr_Filter) theFilter)
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ // Open local context if there is no one
+ if (!aContext->HasOpenedContext())
+ return;
+
+ aContext->UseDisplayedObjects();
+ std::list<int>::const_iterator anIt = theModes.begin(), aLast = theModes.end();
+ for (; anIt != aLast; anIt++) {
+ aContext->ActivateStandardMode((TopAbs_ShapeEnum)(*anIt));
+ }
+
+ if (!theFilter.IsNull())
+ aContext->AddFilter(theFilter);
+}
+
+
+void XGUI_Displayer::deactivateObjectsOutOfContext()
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ // Open local context if there is no one
+ if (!aContext->HasOpenedContext())
+ return;
+
+ aContext->RemoveFilters();
+ aContext->NotUseDisplayedObjects();
+}
\ No newline at end of file
void activate(ObjectPtr theFeature);
+ /// Activates in local context displayed outside of the context.
+ /// \param theModes - selection modes to activate
+ /// \param theFilter - filter for selection
+ void activateObjectsOutOfContext(const std::list<int>& theModes,
+ Handle(SelectMgr_Filter) theFilter);
+
+ void deactivateObjectsOutOfContext();
+
protected:
/// Deactivate local selection
/// \param isUpdateViewer the state wether the viewer should be updated immediatelly
{
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);