\r
#include <QString>\r
#include <QObject>\r
+#include <QMap>\r
\r
#include <string>\r
#include <map>\r
\r
/// Add menu atems for viewer into the given menu\r
/// \param theMenu a popup menu to be shown in the viewer\r
- virtual void addViewerItems(QMenu* theMenu) const {}\r
+ /// \param theStdActions a map of standard actions\r
+ /// \return true if items are added and there is no necessity to provide standard menu\r
+ virtual bool addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const { return false; }\r
\r
/// Add menu atems for object browser into the given menu\r
/// \param theMenu a popup menu to be shown in the object browser\r
return aCanDisplay;
}
-void PartSet_Module::addViewerItems(QMenu* theMenu) const
+bool PartSet_Module::addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const
{
ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
if (!PartSet_SketcherMgr::isSketchOperation(anOperation) &&
!PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
- return;
+ return false;
ModuleBase_ISelection* aSelection = myWorkshop->selection();
QObjectPtrList aObjects = aSelection->selectedPresentations();
}
}
if (hasFeature) {
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
- XGUI_Workshop* aWorkshop = aConnector->workshop();
- QAction* anAction = aWorkshop->contextMenuMgr()->action("DELETE_CMD");
- theMenu->addAction(anAction);
+ theMenu->addAction(theStdActions["DELETE_CMD"]);
}
}
bool isAuxiliary;
theMenu->addAction(anAction);
anAction->setChecked(isAuxiliary);
}
+ return true;
}
void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
/// Add menu atems for viewer into the given menu
/// \param theMenu a popup menu to be shown in the viewer
- virtual void addViewerItems(QMenu* theMenu) const;
+ /// \param theStdActions a map of standard actions
+ /// \return true if items are added and there is no necessity to provide standard menu
+ virtual bool addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
public slots:
/// SLOT, that is called by no more widget signal emitted by property panel
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_Root.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Select3D_SensitivePoint.hxx>
IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Coincident, AIS_InteractiveObject);
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
: AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
{
+
}
return;
std::shared_ptr<GeomAPI_Pnt> aPoint = myPlane->to3D(aPnt->x(), aPnt->y());
-
- static Handle(Graphic3d_AspectMarker3d) aPtA = new Graphic3d_AspectMarker3d ();
- aPtA->SetType(Aspect_TOM_RING1);
- aPtA->SetScale(2.);
- aPtA->SetColor(myOwnColor);
+ myPoint = aPoint->impl<gp_Pnt>();
+
+ static Handle(Graphic3d_AspectMarker3d) aPtA;
+ if (aPtA.IsNull()) {
+ aPtA = new Graphic3d_AspectMarker3d ();
+ aPtA->SetType(Aspect_TOM_RING1);
+ aPtA->SetScale(2.);
+ aPtA->SetColor(myOwnColor);
+ }
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
aGroup->SetPrimitivesAspect(aPtA);
Handle(Graphic3d_ArrayOfPoints) aPntArray = new Graphic3d_ArrayOfPoints(1);
void SketcherPrs_Coincident::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode)
{
+ Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this, 10);
+ Handle(Select3D_SensitivePoint) aSp = new Select3D_SensitivePoint(aOwn, myPoint);
+ aSelection->Add(aSp);
}
void SketcherPrs_Coincident::SetColor(const Quantity_NameOfColor aCol)
private:
SketchPlugin_Constraint* myConstraint;
std::shared_ptr<GeomAPI_Ax3> myPlane;
+ gp_Pnt myPoint;
};
void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const
{
- XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
- QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects();
- if (aObjects.size() > 0) {
- //if (aObjects.size() == 1)
- // theMenu->addAction(action("EDIT_CMD"));
- bool isVisible = false;
- bool isShading = false;
- bool canBeShaded = false;
- foreach(ObjectPtr aObject, aObjects)
- {
- ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
- if (aRes && myWorkshop->displayer()->isVisible(aRes)) {
- isVisible = true;
- canBeShaded = myWorkshop->displayer()->canBeShaded(aObject);
- isShading = (myWorkshop->displayer()->displayMode(aObject) == XGUI_Displayer::Shading);
- break;
+ bool aIsDone = false;
+ ModuleBase_IModule* aModule = myWorkshop->module();
+ if (aModule)
+ aIsDone = aModule->addViewerItems(theMenu, myActions);
+
+ if (!aIsDone) {
+ XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
+ QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects();
+ if (aObjects.size() > 0) {
+ //if (aObjects.size() == 1)
+ // theMenu->addAction(action("EDIT_CMD"));
+ bool isVisible = false;
+ bool isShading = false;
+ bool canBeShaded = false;
+ foreach(ObjectPtr aObject, aObjects)
+ {
+ ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+ if (aRes && myWorkshop->displayer()->isVisible(aRes)) {
+ isVisible = true;
+ canBeShaded = myWorkshop->displayer()->canBeShaded(aObject);
+ isShading = (myWorkshop->displayer()->displayMode(aObject) == XGUI_Displayer::Shading);
+ break;
+ }
}
+ if (isVisible) {
+ if (canBeShaded) {
+ if (isShading)
+ theMenu->addAction(action("WIREFRAME_CMD"));
+ else
+ theMenu->addAction(action("SHADING_CMD"));
+ }
+ theMenu->addSeparator();
+ theMenu->addAction(action("SHOW_ONLY_CMD"));
+ theMenu->addAction(action("HIDE_CMD"));
+ } else
+ theMenu->addAction(action("SHOW_CMD"));
+ //theMenu->addAction(action("DELETE_CMD"));
}
- if (isVisible) {
- if (canBeShaded) {
- if (isShading)
- theMenu->addAction(action("WIREFRAME_CMD"));
- else
- theMenu->addAction(action("SHADING_CMD"));
- }
- theMenu->addSeparator();
- theMenu->addAction(action("SHOW_ONLY_CMD"));
- theMenu->addAction(action("HIDE_CMD"));
- } else
- theMenu->addAction(action("SHOW_CMD"));
- //theMenu->addAction(action("DELETE_CMD"));
+ if (myWorkshop->canChangeColor())
+ theMenu->addAction(action("COLOR_CMD"));
+ if (myWorkshop->displayer()->objectsCount() > 0)
+ theMenu->addAction(action("HIDEALL_CMD"));
}
- if (myWorkshop->displayer()->objectsCount() > 0)
- theMenu->addAction(action("HIDEALL_CMD"));
if (!myWorkshop->isSalomeMode()) {
theMenu->addSeparator();
QMdiArea* aMDI = myWorkshop->mainWindow()->mdiArea();
aSubMenu->addActions(aMDI->actions());
}
}
- if (myWorkshop->canChangeColor())
- theMenu->addAction(action("COLOR_CMD"));
- ModuleBase_IModule* aModule = myWorkshop->module();
- if (aModule)
- aModule->addViewerItems(theMenu);
}
void XGUI_ContextMenuMgr::connectObjectBrowser() const