activate="true"
shape_types="face"
/>
- <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="10" icon=":icons/dimension_v.png" tooltip="Set size of extrusion">
+ <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="0" icon=":icons/dimension_v.png" tooltip="Set size of extrusion">
<validator id="GeomValidators_Positive"/>
</doublevalue>
<boolvalue id="extrusion_reverse" label="Reverse" default="false" tooltip="Reverse default direction"/>
aValue.setObject(aPrs.object());
if (aActiveWgt->setValue(&aValue)) {
myPreSelection.remove(aPrs);
- if(isValid()) {
- //myActiveWidget = NULL;
- commit();
- } else {
- myPropertyPanel->activateNextWidget();
- //emit activateNextWidget(myActiveWidget);
- }
+ myPropertyPanel->activateNextWidget();
}
// If preselection is enough to make a valid feature - apply it immediately
}
/// Returns pointer to the root document.
boost::shared_ptr<ModelAPI_Document> document() const;
- ///
+ /// Activates widgets by preselection if it is accepted
virtual void activateByPreselection();
/// Set value to the active widget
#include <ModelAPI_Tools.h>
#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Result.h>
#include <ModelAPI_AttributeReference.h>
return;
setObject(aObject);
+ emit focusOutWidget(this);
}
}
updateSelectionName();
activateSelection(false);
emit valuesChanged();
- emit focusOutWidget(this);
}
//********************************************************************
return false;
}
}
+ // Check that object belongs to active document or PartSet
+ DocumentPtr aDoc = aResult->document();
+ SessionPtr aMgr = ModelAPI_Session::get();
+ if (!(aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument()))
+ return false;
+
+ // Check that the shape of necessary type
boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
if (!aShapePtr)
return false;
connect(myWorkshop, SIGNAL(operationStopped(ModuleBase_Operation*)), this,
SLOT(onOperationStopped(ModuleBase_Operation*)));
- XGUI_ContextMenuMgr* aContextMenuMgr = xWorkshop()->contextMenuMgr();
+ XGUI_Workshop* aXWshop = xWorkshop();
+ XGUI_ContextMenuMgr* aContextMenuMgr = aXWshop->contextMenuMgr();
connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this,
SLOT(onContextMenuCommand(const QString&, bool)));
SLOT(onKeyRelease(QKeyEvent*)));
connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this,
SLOT(onMouseDoubleClick(QMouseEvent*)));
+
+ myDocumentShapeFilter = new XGUI_ShapeDocumentFilter(aXWshop->displayer());
}
PartSet_Module::~PartSet_Module()
*/
void PartSet_Module::onFeatureTriggered()
{
- //PartSet_TestOCC::local_selection_change_shape(myWorkshop->viewer()->AISContext(),
- // myWorkshop->viewer()->activeView());
-
- //PartSet_TestOCC::local_selection_erase(myWorkshop->viewer()->AISContext(),
- // myWorkshop->viewer()->activeView());
QAction* aCmd = dynamic_cast<QAction*>(sender());
//Do nothing on uncheck
if (aCmd->isCheckable() && !aCmd->isChecked())
launchOperation(aCmd->data().toString());
}
-//void PartSet_Module::launchOperation(const QString& theCmdId)
-//{
-// ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
-// //PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-// //if (aPreviewOp) {
-// XGUI_Selection* aSelection = myWorkshop->selector()->selection();
-// // Initialise operation with preliminary selection
-// std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
-// std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
-// anOperation->initSelection(aSelected, aHighlighted);
-// //}
-// sendOperation(anOperation);
-//}
void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
{
XGUI_Displayer* aDisplayer = aXWshp->displayer();
aDisplayer->openLocalContext();
aDisplayer->deactivateObjectsOutOfContext();
+ } else {
+ Handle(AIS_InteractiveContext) aAIS = xWorkshop()->viewer()->AISContext();
+ aAIS->AddFilter(myDocumentShapeFilter);
}
}
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
if (aPreviewOp) {
XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
- //disconnect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
- // this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)));
} else {
// Activate results of current feature for selection
FeaturePtr aFeature = theOperation->feature();
for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
aDisplayer->activate(*aIt);
}
+
+ Handle(AIS_InteractiveContext) aAIS = xWorkshop()->viewer()->AISContext();
+ aAIS->RemoveFilter(myDocumentShapeFilter);
}
}
#include <ModuleBase_IModule.h>
#include <ModuleBase_Definitions.h>
#include <XGUI_Command.h>
+#include <XGUI_ViewerFilters.h>
#include <ModelAPI_Feature.h>
#include <QMap>
PartSet_Listener* myListener;
std::map<std::string, std::string> myFeaturesInFiles;
+
+ /// A filter which provides selection within a current document or whole PartSet
+ Handle(XGUI_ShapeDocumentFilter) myDocumentShapeFilter;
};
#endif
#include <PartSet_Tools.h>
#include <ModelAPI_ResultBody.h>
+#include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_WidgetValueFeature.h>
+
#include <SketchPlugin_Feature.h>
#include <V3d_View.hxx>
#include <AIS_Shape.hxx>
}
emit restartRequired(theType, theFeature);
}
+
+
+
+void PartSet_OperationSketchBase::activateByPreselection()
+{
+ if (!myPropertyPanel)
+ return;
+ ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
+ if ((myPreSelection.size() > 0) && aActiveWgt) {
+ const ModuleBase_ViewerPrs& aPrs = myPreSelection.front();
+ ModuleBase_WidgetValueFeature aValue;
+ aValue.setObject(aPrs.object());
+ if (aActiveWgt->setValue(&aValue)) {
+ myPreSelection.remove(aPrs);
+ if(isValid()) {
+ //myActiveWidget = NULL;
+ commit();
+ } else {
+ myPropertyPanel->activateNextWidget();
+ //emit activateNextWidget(myActiveWidget);
+ }
+ }
+ // If preselection is enough to make a valid feature - apply it immediately
+ }
+}
/// \param theFlushMessage the flag whether the create message should be flushed
/// \returns the created feature
virtual FeaturePtr createFeature(const bool theFlushMessage = true);
+
+ /// Activates widgets by preselection if it is accepted
+ virtual void activateByPreselection();
};
#endif
XGUI_Preferences.h
XGUI_IPrefMgr.h
XGUI_QtEvents.h
+ XGUI_ViewerFilters.h
)
SET(PROJECT_AUTOMOC
XGUI_Selection.cpp
XGUI_Preferences.cpp
XGUI_QtEvents.cpp
+ XGUI_ViewerFilters.cpp
)
SET(PROJECT_RESOURCES
/// Destructor
virtual ~XGUI_Displayer();
- /// Set AIS_InteractiveContext object in case if it was changed
- /// or can not be initialized in constructor
- void setAISContext(const Handle(AIS_InteractiveContext)& theAIS);
-
/// Returns the feature visibility state.
/// \param theFeature a feature instance
bool isVisible(ObjectPtr theObject) const;
--- /dev/null
+// File: XGUI_ViewerFilters.cpp
+// Created: 07 Okt 2014
+// Author: Vitaly SMETANNIKOV
+
+
+#include "XGUI_ViewerFilters.h"
+#include "XGUI_Displayer.h"
+
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Document.h>
+
+#include <AIS_InteractiveObject.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
+IMPLEMENT_STANDARD_RTTIEXT(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
+
+
+//TODO (VSV): Check bug in OCCT: Filter result is ignored
+Standard_Boolean XGUI_ShapeDocumentFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
+{
+ if (theOwner->HasSelectable()) {
+ Handle(AIS_InteractiveObject) aAisObj =
+ Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+ if (!aAisObj.IsNull()) {
+ ObjectPtr aObj = myDisplayer->getObject(aAisObj);
+ if (aObj) {
+ DocumentPtr aDoc = aObj->document();
+ SessionPtr aMgr = ModelAPI_Session::get();
+ return (aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument());
+ }
+ }
+ }
+ return Standard_False;
+}
\ No newline at end of file
--- /dev/null
+// File: XGUI_ViewerFilters.h
+// Created: 07 Okt 2014
+// Author: Vitaly SMETANNIKOV
+
+
+#ifndef XGUI_ViewerFilters_H
+#define XGUI_ViewerFilters_H
+
+#include <SelectMgr_Filter.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+
+class XGUI_Displayer;
+
+DEFINE_STANDARD_HANDLE(XGUI_ShapeDocumentFilter, SelectMgr_Filter);
+
+class XGUI_ShapeDocumentFilter: public SelectMgr_Filter
+{
+public:
+ Standard_EXPORT XGUI_ShapeDocumentFilter(XGUI_Displayer* myDisp): SelectMgr_Filter(),
+ myDisplayer(myDisp) {}
+
+ Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
+
+ DEFINE_STANDARD_RTTI(XGUI_ShapeDocumentFilter)
+
+private:
+ XGUI_Displayer* myDisplayer;
+};
+
+#endif
\ No newline at end of file