From 8537926edc8db5d54bf384afa66419c3b46c17ac Mon Sep 17 00:00:00 2001 From: jriegel Date: Sun, 1 Apr 2012 15:02:40 +0200 Subject: [PATCH] Finally fixing the highlight code --- src/Gui/Tree.cpp | 63 +++++++++++----------- src/Gui/Tree.h | 2 +- src/Gui/View3DPy.cpp | 4 +- src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp | 6 +-- src/Mod/Sketcher/Gui/DrawSketchHandler.cpp | 1 + 5 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index fdb7fef3c..bda4f985e 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -638,23 +638,23 @@ void TreeWidget::slotActiveDocument(const Gui::Document& Doc) } } -void TreeWidget::markItem(const App::DocumentObject* Obj,bool mark) -{ - // never call without Object! - assert(Obj); - Gui::Document* Doc = Gui::Application::Instance->getDocument(Obj->getDocument()); - - std::map::iterator jt = DocumentMap.find(Doc); - for (std::map::iterator it = DocumentMap.begin(); - it != DocumentMap.end(); ++it) - { - it->second->markItem(Obj,mark); - - QFont f = it->second->font(0); - f.setBold(it == jt); - it->second->setFont(0,f); - } -} +//void TreeWidget::markItem(const App::DocumentObject* Obj,bool mark) +//{ +// // never call without Object! +// assert(Obj); +// Gui::Document* Doc = Gui::Application::Instance->getDocument(Obj->getDocument()); +// +// std::map::iterator jt = DocumentMap.find(Doc); +// for (std::map::iterator it = DocumentMap.begin(); +// it != DocumentMap.end(); ++it) +// { +// it->second->markItem(Obj,mark); +// +// QFont f = it->second->font(0); +// f.setBold(it == jt); +// it->second->setFont(0,f); +// } +//} void TreeWidget::onTestStatus(void) { @@ -1053,6 +1053,7 @@ void DocumentItem::slotHighlightObject (const Gui::ViewProviderDocumentObject& o break; } jt->second->setFont(0,f); + } void DocumentItem::slotExpandObject (const Gui::ViewProviderDocumentObject& obj,const Gui::TreeItemMode& mode) @@ -1087,20 +1088,20 @@ const Gui::Document* DocumentItem::document() const return this->pDocument; } -void DocumentItem::markItem(const App::DocumentObject* Obj,bool mark) -{ - // never call without Object! - assert(Obj); - - - std::map::iterator pos; - pos = ObjectMap.find(Obj->getNameInDocument()); - if (pos != ObjectMap.end()) { - QFont f = pos->second->font(0); - f.setUnderline(mark); - pos->second->setFont(0,f); - } -} +//void DocumentItem::markItem(const App::DocumentObject* Obj,bool mark) +//{ +// // never call without Object! +// assert(Obj); +// +// +// std::map::iterator pos; +// pos = ObjectMap.find(Obj->getNameInDocument()); +// if (pos != ObjectMap.end()) { +// QFont f = pos->second->font(0); +// f.setUnderline(mark); +// pos->second->setFont(0,f); +// } +//} //void DocumentItem::markItem(const App::DocumentObject* Obj,bool mark) //{ diff --git a/src/Gui/Tree.h b/src/Gui/Tree.h index 0b39b9a42..a10313746 100644 --- a/src/Gui/Tree.h +++ b/src/Gui/Tree.h @@ -149,7 +149,7 @@ public: void selectItems(void); void testStatus(void); void setData(int column, int role, const QVariant & value); - void markItem(const App::DocumentObject* Obj,bool mark); +// void markItem(const App::DocumentObject* Obj,bool mark); protected: /** Adds a view provider to the document item. diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 9f83361ef..eee00ecd6 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -464,7 +464,7 @@ Py::Object View3DInventorPy::viewRotateLeft(const Py::Tuple& args) SbRotation rot = cam->orientation.getValue(); SbVec3f vdir(0, 0, -1); rot.multVec(vdir, vdir); - SbRotation nrot(vdir,float( M_PI/2)); + SbRotation nrot(vdir, (float)M_PI/2); cam->orientation.setValue(rot*nrot); } catch (const Base::Exception& e) { @@ -490,7 +490,7 @@ Py::Object View3DInventorPy::viewRotateRight(const Py::Tuple& args) SbRotation rot = cam->orientation.getValue(); SbVec3f vdir(0, 0, -1); rot.multVec(vdir, vdir); - SbRotation nrot(vdir, float(-M_PI/2)); + SbRotation nrot(vdir, (float)-M_PI/2); cam->orientation.setValue(rot*nrot); } catch (const Base::Exception& e) { diff --git a/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp b/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp index de412629a..0409d69ae 100644 --- a/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp +++ b/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp @@ -55,17 +55,17 @@ static PyObject * setActiveAssembly(PyObject *self, PyObject *args) // get the gui document of the Assembly Item if(ActiveAsmObject){ - ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::None); + ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,false); ActiveAsmObject = 0; } ActiveAsmObject = Item; ActiveGuiDoc = Gui::Application::Instance->getDocument(Item->getDocument()); ActiveVp = dynamic_cast (ActiveGuiDoc->getViewProvider(Item)) ; - ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Underlined); + ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,true); }else{ - ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::None); + ActiveGuiDoc->signalHighlightObject(*ActiveVp,Gui::Blue,false); ActiveAsmObject = 0; } diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp index 302a64d6f..c3dfa3c54 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp @@ -236,6 +236,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector &suggested int tangId = Constraint::GeoUndef; + float smlTangDist = 1e15f; // Do not consider if distance is more than that. // Decrease this value when a candidate is found. double tangDeviation = 0.1 * sketchgui->getScaleFactor();