Do not override edit cursor with pre-selection

This commit is contained in:
wmayer 2013-04-10 13:57:44 +02:00
parent 42b54c1293
commit fe19cb09cc
8 changed files with 43 additions and 41 deletions

View File

@ -85,6 +85,14 @@ void MDIView::deleteSelf()
delete this;
}
void MDIView::setOverrideCursor(const QCursor& c)
{
}
void MDIView::restoreOverrideCursor()
{
}
void MDIView::onRelabel(Gui::Document *pDoc)
{
if (!bIsPassive) {

View File

@ -77,7 +77,10 @@ public:
/** @name Printing */
//@{
public Q_SLOTS:
virtual void setOverrideCursor(const QCursor&);
virtual void restoreOverrideCursor();
virtual void print(QPrinter* printer);
public:
/** Print content of view */
virtual void print();

View File

@ -465,32 +465,30 @@ bool SelectionSingleton::setPreselect(const char* pDocName, const char* pObjectN
if (DocName != "")
rmvPreselect();
if(ActiveGate)
{
if (ActiveGate) {
App::Document* pDoc = getDocument(pDocName);
if (pDoc) {
if(pObjectName){
if (pObjectName) {
App::DocumentObject* pObject = pDoc->getObject(pObjectName);
if(! ActiveGate->allow(pDoc,pObject,pSubName)){
if (!ActiveGate->allow(pDoc,pObject,pSubName)) {
snprintf(buf,512,"Not allowed: %s.%s.%s ",pDocName
,pObjectName
,pSubName
);
if (getMainWindow()){
if (getMainWindow()) {
getMainWindow()->showMessage(QString::fromAscii(buf),3000);
Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView();
if (mdi && mdi->isDerivedFrom(View3DInventor::getClassTypeId())) {
static_cast<View3DInventor*>(mdi)->setCursor(Qt::ForbiddenCursor);
}
mdi->setOverrideCursor(QCursor(Qt::ForbiddenCursor));
}
return false;
}
}else
}
else
return ActiveGate->allow(pDoc,0,0);
}else
}
else
return false;
}
@ -520,13 +518,13 @@ bool SelectionSingleton::setPreselect(const char* pDocName, const char* pObjectN
,Chng.pSubName
,x,y,z);
if (getMainWindow()){
getMainWindow()->showMessage(QString::fromAscii(buf),3000);
Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView();
if (mdi && mdi->isDerivedFrom(View3DInventor::getClassTypeId())) {
static_cast<View3DInventor*>(mdi)->setCursor(Qt::ArrowCursor);
}
}
//FIXME: We shouldn't replace the possibly defined edit cursor
//with the arrow cursor. But it seems that we don't even have to.
//if (getMainWindow()){
// getMainWindow()->showMessage(QString::fromAscii(buf),3000);
// Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView();
// mdi->restoreOverrideCursor();
//}
Notify(Chng);
signalSelectionChanged(Chng);
@ -587,11 +585,9 @@ void SelectionSingleton::rmvPreselect()
hy = 0;
hz = 0;
if (getMainWindow()){
if (ActiveGate && getMainWindow()) {
Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView();
if (mdi && mdi->isDerivedFrom(View3DInventor::getClassTypeId())) {
static_cast<View3DInventor*>(mdi)->setCursor(Qt::ArrowCursor);
}
mdi->restoreOverrideCursor();
}
//Base::Console().Log("Sel : Rmv preselect \n");
@ -605,7 +601,7 @@ const SelectionChanges &SelectionSingleton::getPreselection(void) const
// add a SelectionGate to control what is selectable
void SelectionSingleton::addSelectionGate(Gui::SelectionGate *gate)
{
if(ActiveGate)
if (ActiveGate)
rmvSelectionGate();
ActiveGate = gate;
@ -621,9 +617,7 @@ void SelectionSingleton::rmvSelectionGate(void)
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc) {
Gui::MDIView* mdi = doc->getActiveView();
if (mdi && mdi->isDerivedFrom(View3DInventor::getClassTypeId())) {
static_cast<View3DInventor*>(mdi)->setCursor(Qt::ArrowCursor);
}
mdi->restoreOverrideCursor();
}
}
}
@ -654,15 +648,12 @@ bool SelectionSingleton::addSelection(const char* pDocName, const char* pObjectN
temp.pObject = 0;
// check for a Selection Gate
if(ActiveGate)
{
if(! ActiveGate->allow(temp.pDoc,temp.pObject,pSubName)){
if (getMainWindow()){
if (ActiveGate) {
if (!ActiveGate->allow(temp.pDoc,temp.pObject,pSubName)) {
if (getMainWindow()) {
getMainWindow()->showMessage(QString::fromAscii("Selection not allowed by filter"),5000);
Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView();
if (mdi && mdi->isDerivedFrom(View3DInventor::getClassTypeId())) {
static_cast<View3DInventor*>(mdi)->setCursor(Qt::ForbiddenCursor);
}
mdi->setOverrideCursor(Qt::ForbiddenCursor);
}
QApplication::beep();
return false;

View File

@ -354,7 +354,7 @@ bool AbstractSplitView::onHasMsg(const char* pMsg) const
return false;
}
void AbstractSplitView::setCursor(const QCursor& aCursor)
void AbstractSplitView::setOverrideCursor(const QCursor& aCursor)
{
//_viewer->getWidget()->setCursor(aCursor);
}

View File

@ -54,7 +54,7 @@ public:
View3DInventorViewer *getViewer(unsigned int) const;
void setCursor(const QCursor&);
void setOverrideCursor(const QCursor&);
protected:
void setupSettings();

View File

@ -789,14 +789,14 @@ void View3DInventor::removeOverlayWidget()
if (overlay) stack->removeWidget(overlay);
}
void View3DInventor::setCursor(const QCursor& aCursor)
void View3DInventor::setOverrideCursor(const QCursor& aCursor)
{
_viewer->getWidget()->setCursor(aCursor);
}
void View3DInventor::setCursor(Qt::CursorShape aCursor)
void View3DInventor::restoreOverrideCursor()
{
_viewer->getWidget()->setCursor(aCursor);
_viewer->getWidget()->setCursor(QCursor(Qt::ArrowCursor));
}
void View3DInventor::dump(const char* filename)

View File

@ -107,8 +107,8 @@ public:
public Q_SLOTS:
/// override the cursor in this view
void setCursor(const QCursor&);
void setCursor(Qt::CursorShape s);
void setOverrideCursor(const QCursor&);
void restoreOverrideCursor();
void dump(const char* filename);

View File

@ -1046,7 +1046,7 @@ void CmdMeshRemoveCompByHand::activated(int iMsg)
if (view) {
Gui::View3DInventorViewer* viewer = view->getViewer();
viewer->setEditing(true);
//viewer->setEditingCursor(QCursor(Gui::BitmapFactory().pixmap("mesh_pipette"),4,29));
viewer->setEditingCursor(QCursor(Qt::OpenHandCursor));
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), MeshGui::ViewProviderMeshFaceSet::markPartCallback);
}
}