/*************************************************************************** * Copyright (c) 2004 Jürgen Riegel * * Copyright (c) 2019 Wanderer Fan * * * * This file is part of the FreeCAD CAx development system. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; see the file COPYING.LIB. If not, * * write to the Free Software Foundation, Inc., 59 Temple Place, * * Suite 330, Boston, MA 02111-1307, USA * * * ***************************************************************************/ #include "PreCompiled.h" #ifndef _PreComp_ #endif /// Here the FreeCAD includes sorted by Base,App,Gui...... #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "MDIViewPage.h" #include "QGVPage.h" #include "QGIView.h" #include "TaskRichAnno.h" #include "ViewProviderRichAnno.h" using namespace TechDrawGui; PROPERTY_SOURCE(TechDrawGui::ViewProviderRichAnno, TechDrawGui::ViewProviderDrawingView) //************************************************************************** // Construction/Destruction ViewProviderRichAnno::ViewProviderRichAnno() { sPixmap = "actions/techdraw-textleader"; static const char *group = "Text Format"; ADD_PROPERTY_TYPE(Color,(getDefLineColor()),group,App::Prop_None,"The color of the Markup"); ADD_PROPERTY_TYPE(Font ,(getDefFont().c_str()),group,App::Prop_None, "The name of the font to use"); ADD_PROPERTY_TYPE(Fontsize,(getDefFontSize()) ,group,(App::PropertyType)(App::Prop_None), "Text size in internal units"); Color.setStatus(App::Property::ReadOnly,true); Font.setStatus(App::Property::ReadOnly,true); Fontsize.setStatus(App::Property::ReadOnly,true); } ViewProviderRichAnno::~ViewProviderRichAnno() { } void ViewProviderRichAnno::attach(App::DocumentObject *pcFeat) { ViewProviderDrawingView::attach(pcFeat); } bool ViewProviderRichAnno::setEdit(int ModNum) { // Base::Console().Message("VPRA::setEdit(%d)\n",ModNum); if (ModNum == ViewProvider::Default ) { if (Gui::Control().activeDialog()) { //TaskPanel already open! return false; } // clear the selection (convenience) Gui::Selection().clearSelection(); Gui::Control().showDialog(new TaskDlgRichAnno(this)); return true; } else { return ViewProviderDrawingView::setEdit(ModNum); } return true; } void ViewProviderRichAnno::unsetEdit(int ModNum) { Q_UNUSED(ModNum); if (ModNum == ViewProvider::Default) { Gui::Control().closeDialog(); } else { ViewProviderDrawingView::unsetEdit(ModNum); } } bool ViewProviderRichAnno::doubleClicked(void) { // Base::Console().Message("VPRA::doubleClicked()\n"); setEdit(ViewProvider::Default); return true; } void ViewProviderRichAnno::updateData(const App::Property* p) { ViewProviderDrawingView::updateData(p); } void ViewProviderRichAnno::onChanged(const App::Property* p) { // if ((p == &Font) || // (p == &Fontsize) || // (p == &Color)) { // QGIView* qgiv = getQView(); // if (qgiv) { // qgiv->updateView(true); // } // } ViewProviderDrawingView::onChanged(p); } TechDraw::DrawRichAnno* ViewProviderRichAnno::getViewObject() const { return dynamic_cast(pcObject); } TechDraw::DrawRichAnno* ViewProviderRichAnno::getFeature() const { return dynamic_cast(pcObject); } App::Color ViewProviderRichAnno::getDefLineColor(void) { Base::Reference hGrp = App::GetApplication().GetUserParameter(). GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Markups"); App::Color result; result.setPackedValue(hGrp->GetUnsigned("Color", 0x00000000)); return result; } std::string ViewProviderRichAnno::getDefFont(void) { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels"); std::string fontName = hGrp->GetASCII("LabelFont", "osifont"); return fontName; } double ViewProviderRichAnno::getDefFontSize() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions"); double fontSize = hGrp->GetFloat("FontSize", 5.0); return fontSize; }