Handle(Prs3d_Drawer) ModuleBase_IViewer::DefaultHighlightDrawer;
-ModuleBase_IViewer::ModuleBase_IViewer(QObject* theParent) : QObject(theParent)
+ModuleBase_IViewer::ModuleBase_IViewer(QObject* theParent)
+ : QObject(theParent), myIs2dMode(false)
{
}
/// Show highlight for pre-highlighted sub-shape
virtual void updateHighlight() {}
+ /// Set flag which indicates that viewer is used for 2d operations
+ /// \param is2d a new 2d mode state
+ void set2dMode(bool is2d) {
+ myIs2dMode = is2d;
+ }
+
+ /// Returns current state of 2d mode flag
+ bool is2dMode() const {
+ return myIs2dMode;
+ }
+
static Handle(Prs3d_Drawer) DefaultHighlightDrawer;
signals:
/// A map for storing a scale factors dependent on view object
QMap<Handle(V3d_View), double> myWindowScale;
+ bool myIs2dMode;
};
#endif
createEditors();
myPreferences->retrieve();
- setMinimumSize(800, 240);
+ setMinimumSize(800, 300);
}
ModuleBase_PreferencesDlg::~ModuleBase_PreferencesDlg()
ModuleBase_Preferences::VIEWER_SECTION, "point-selection-sensitivity");
myPreferences->addItem(tr("Edge"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin,
ModuleBase_Preferences::VIEWER_SECTION, "edge-selection-sensitivity");
+
+ int highlightGroup = myPreferences->addItem(tr("Additional highlighting"), viewTab);
+ myPreferences->setItemProperty("columns", 2, highlightGroup);
+ myPreferences->addItem(tr("In 3d mode"), highlightGroup,
+ SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-3d");
+ myPreferences->addItem(tr("In 2d mode"), highlightGroup,
+ SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-2d");
}
void ModuleBase_PreferencesDlg::createMenuPage(int thePageId)
#include <QWidget>
#include <QLayout>
#include <QLabel>
-#include <QComboBox>
#include <QButtonGroup>
#include <QGroupBox>
#include <QRadioButton>
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
myExternalPointsMgr = new PartSet_ExternalPointsMgr(myModule->workshop(), myCurrentSketch);
+
+ workshop()->viewer()->set2dMode(true);
}
void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
}
workshop()->selectionActivate()->updateSelectionFilters();
workshop()->selectionActivate()->updateSelectionModes();
+ workshop()->viewer()->set2dMode(false);
}
void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
<parameter name="vertex-selection" value="true" />
<parameter name="point-selection-sensitivity" value="12" />
<parameter name="edge-selection-sensitivity" value="2" />
+ <parameter name="highlighting-3d" value="false" />
+ <parameter name="highlighting-2d" value="true" />
</section>
<section name="Menu" >
<!-- Menu bar preferences -->
aContext->HilightNextDetected(aView);
else if ((theEvent->key() == Qt::Key_P))
aContext->HilightPreviousDetected(aView);
- aViewer->updateHighlight();
+ //aViewer->updateHighlight();
isAccepted = true;
}
}
#endif
#include <ModuleBase_IViewWindow.h>
+#include <ModuleBase_Preferences.h>
#include <GeomAPI_Shape.h>
#include <ModelAPI_ResultConstruction.h>
#include <Config_PropManager.h>
+#include <SUIT_ResourceMgr.h>
#include <AIS_Shape.hxx>
#include <StdSelect_BRepOwner.hxx>
#include <QEvent>
+#include <QKeyEvent>
#define HIGHLIGHT_COLOR Quantity_NOC_YELLOW
XGUI_ViewerProxy::XGUI_ViewerProxy(XGUI_Workshop* theParent)
: ModuleBase_IViewer(theParent),
- myWorkshop(theParent)
+ myWorkshop(theParent), myShowHighlight(false)
{
}
void XGUI_ViewerProxy::onMouseMove(AppElements_ViewWindow* theWnd, QMouseEvent* theEvent)
{
- updateHighlight();
+ if (myIs2dMode) {
+ bool aHighlight2d =
+ ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "highlighting-2d", true);
+ if (aHighlight2d || myShowHighlight)
+ updateHighlight();
+ else
+ eraseHighlight();
+ }
+ else {
+ bool aHighlight3d =
+ ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "highlighting-3d", false);
+ if (aHighlight3d || myShowHighlight)
+ updateHighlight();
+ else
+ eraseHighlight();
+ }
emit mouseMove(theWnd, theEvent);
}
void XGUI_ViewerProxy::onKeyPress(AppElements_ViewWindow* theWnd, QKeyEvent* theEvent)
{
+ myShowHighlight = theEvent->key() == Qt::Key_H;
emit keyPress(theWnd, theEvent);
}
void XGUI_ViewerProxy::onKeyRelease(AppElements_ViewWindow* theWnd, QKeyEvent* theEvent)
{
+ if (theEvent->key() == Qt::Key_H) {
+ myShowHighlight = false;
+ }
emit keyRelease(theWnd, theEvent);
}
XGUI_Workshop* myWorkshop;
ResultPtr myResult;
AIS_ListOfInteractive myHighlights;
+
+ bool myShowHighlight;
};
#endif