ShortcutTree,
BiColor,
Background,
- Directory
+ Directory,
+ Cursor
+ };
+
+ enum CursorType
+ {
+ ArrowCursor,
+ CrossCursor,
+ HandCursor
};
/**
Config_Prop::DblSpin, "0.04");
Config_PropManager::registerProp(SKETCH_TAB_NAME, "rotate_to_plane",
"Rotate to plane when selected", Config_Prop::Boolean, "false");
+ Config_PropManager::registerProp(SKETCH_TAB_NAME, "operation_cursor",
+ "Cursor for Sketch operation", Config_Prop::Cursor, "0");
// register this plugin
ModelAPI_Session::get()->registerPlugin(this);
// Add item
if (aProp->type() != Config_Prop::Disabled) {
SUIT_PreferenceMgr::PrefItemType aPrefType = SUIT_PreferenceMgr::Auto;
- if (aProp->type() == Config_Prop::Directory) {
+ switch (aProp->type()) {
+ case Config_Prop::Directory:
aPrefType = SUIT_PreferenceMgr::File;
- } else {
+ break;
+ case Config_Prop::Cursor:
+ aPrefType = SUIT_PreferenceMgr::Selector;
+ break;
+ default:
aPrefType = (SUIT_PreferenceMgr::PrefItemType) aProp->type();
}
+
int anId = thePref->addPreference(QObject::tr(aProp->title().c_str()), aTab, aPrefType,
QString::fromStdString(aProp->section()),
QString::fromStdString(aProp->name()));
- if(aProp->type() == Config_Prop::Directory) {
+
+ switch (aProp->type()) {
+ case Config_Prop::Directory:
thePref->setItemProperty("path_type", Qtx::PT_Directory, anId);
- }
- if (aPrefType == SUIT_PreferenceMgr::DblSpin) {
+ break;
+ case SUIT_PreferenceMgr::DblSpin:
if (aProp->min() != "") {
double aMin = QString(aProp->min().c_str()).toDouble();
thePref->setItemProperty("min", aMin, anId);
double aMax = QString(aProp->max().c_str()).toDouble();
thePref->setItemProperty("max", aMax, anId);
}
- }
- if (aPrefType == SUIT_PreferenceMgr::IntSpin) {
+ break;
+ case SUIT_PreferenceMgr::IntSpin:
if (aProp->min() != "") {
int aMin = QString(aProp->min().c_str()).toInt();
thePref->setItemProperty("min", aMin, anId);
int aMax = QString(aProp->max().c_str()).toInt();
thePref->setItemProperty("max", aMax, anId);
}
+ break;
+ case Config_Prop::Cursor:
+ {
+ QList<QVariant> aIndicesList;
+ QList<QVariant> aIconsList;
+ aIndicesList << 0 << 1 << 2;
+ aIconsList << QPixmap(":pictures/ArrowCursor.png") <<
+ QPixmap(":pictures/CrossCursor.png") <<
+ QPixmap(":pictures/HandCursor.png");
+
+ thePref->setItemProperty("indexes", aIndicesList, anId);
+ thePref->setItemProperty("icons", aIconsList, anId);
+ }
+ break;
}
}
}
}
// It is switched off because of
// Task #3067: 5.2.2 Drawing in the sketcher: change the mouse cursor arrow
- //else if (sketchMgr()->isNestedSketchOperation(theOperation)) {
- // mySketchMgr->startNestedSketch(theOperation);
- //}
+ else if (sketchMgr()->isNestedSketchOperation(theOperation)) {
+ mySketchMgr->startNestedSketch(theOperation);
+ }
}
//******************************************************
// It is switched off because of
// Task #3067: 5.2.2 Drawing in the sketcher: change the mouse cursor arrow
- // if (canChangeCursor(getCurrentOperation())) {
- // QCursor* aCurrentCursor = QApplication::overrideCursor();
- // if (!aCurrentCursor || aCurrentCursor->shape() != Qt::CrossCursor) {
- // QApplication::setOverrideCursor(QCursor(Qt::CrossCursor));
+ if (canChangeCursor(getCurrentOperation())) {
+ QCursor* aCurrentCursor = QApplication::overrideCursor();
+ if (!aCurrentCursor || aCurrentCursor->shape() != Qt::CrossCursor) {
+ QApplication::setOverrideCursor(PartSet_Tools::getOperationCursor());
//#ifdef DEBUG_CURSOR
// qDebug("onEnterViewPort() : Qt::CrossCursor");
//#endif
- // }
- // }
+ }
+ }
if (!isNestedCreateOperation(getCurrentOperation(), activeSketch()))
return;
return;
#endif
-// if (canChangeCursor(getCurrentOperation())) {
-// QApplication::restoreOverrideCursor();
+ if (canChangeCursor(getCurrentOperation())) {
+ QApplication::restoreOverrideCursor();
//#ifdef DEBUG_CURSOR
// qDebug("onLeaveViewPort() : None");
//#endif
-// }
+ }
if (!isNestedCreateOperation(getCurrentOperation(), activeSketch()))
return;
workshop()->viewer()->set2dMode(false);
}
-//void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
-//{
-// if (canChangeCursor(theOperation) && myIsMouseOverWindow) {
-// QCursor* aCurrentCursor = QApplication::overrideCursor();
-// if (!aCurrentCursor || aCurrentCursor->shape() != Qt::CrossCursor) {
-// QApplication::setOverrideCursor(QCursor(Qt::CrossCursor));
+void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
+{
+ if (canChangeCursor(theOperation) && myIsMouseOverWindow) {
+ QCursor* aCurrentCursor = QApplication::overrideCursor();
+ if (!aCurrentCursor || aCurrentCursor->shape() != Qt::CrossCursor) {
+ QApplication::setOverrideCursor(PartSet_Tools::getOperationCursor());
//#ifdef DEBUG_CURSOR
// qDebug("startNestedSketch() : Qt::CrossCursor");
//#endif
-// }
-// }
-//}
+ }
+ }
+}
void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOperation)
{
myIsMouseOverViewProcessed = true;
operationMgr()->onValidateOperation();
// when sketch nested operation is stopped the cursor should be restored unconditionally
- //if (canChangeCursor(theOperation)) {
- //QApplication::restoreOverrideCursor();
+ if (canChangeCursor(theOperation)) {
+ QApplication::restoreOverrideCursor();
#ifdef DEBUG_CURSOR
qDebug("stopNestedSketch() : None");
#endif
- //}
+ }
/// improvement to deselect automatically all eventual selected objects, when
// returning to the neutral point of the Sketcher
bool isClearSelectionPossible = true;
/// Starts sketch operation, connects to the opeation property panel
/// \param theOperation a committed operation
- //void startNestedSketch(ModuleBase_Operation* theOperation);
+ void startNestedSketch(ModuleBase_Operation* theOperation);
/// Stop sketch operation, disconnects from the opeation property panel
/// \param theOperation a stopped operation
{
return Config_PropManager::integer("Visualization", "shaper_default_transparency") / 100.;
}
+
+QCursor PartSet_Tools::getOperationCursor()
+{
+ int aId = Config_PropManager::integer(SKETCH_TAB_NAME, "operation_cursor");
+ switch (aId) {
+ case 0:
+ return QCursor(Qt::ArrowCursor);
+ case 1:
+ return QCursor(Qt::CrossCursor);
+ case 2:
+ return QCursor(Qt::PointingHandCursor);
+ }
+ return QCursor();
+}
#include <QPoint>
#include <QList>
+#include <QCursor>
#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_Object.h>
* Returns default transparency value
*/
static double getDefaultTransparency();
+
+ /**
+ * Returns cursor according to (SKETCH_TAB_NAME, "operation_cursor") property value
+ */
+ static QCursor getOperationCursor();
};
#endif
<file>pictures/normal-view.png</file>
<file>pictures/move_to_end.png</file>
<file>pictures/move_to_end_split.png</file>
+ <file>pictures/ArrowCursor.png</file>
+ <file>pictures/CrossCursor.png</file>
+ <file>pictures/HandCursor.png</file>
</qresource>
</RCC>