/*************************************************************************** * Copyright (c) 2019 WandererFan * * * * 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_ #include #include #include #include #include #include #include #include #include #include #include #include #endif // #ifndef _PreComp_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "DrawUtil.h" #include "GeometryObject.h" #include "Geometry.h" #include "DrawViewPart.h" #include "Cosmetic.h" using namespace TechDraw; LineFormat::LineFormat() { m_style = getDefEdgeStyle(); m_weight = getDefEdgeWidth(); m_color = getDefEdgeColor(); m_visible = true; } LineFormat::LineFormat(int style, double weight, App::Color color, bool visible ) : m_style(style), m_weight(weight), m_color(color), m_visible(visible) { } void LineFormat::dump(char* title) { Base::Console().Message("LF::dump - %s \n",title); Base::Console().Message("LF::dump - %s \n",toString().c_str()); } std::string LineFormat::toString(void) const { std::stringstream ss; ss << m_style << "," << m_weight << "," << m_color.asHexString() << "," << m_visible; return ss.str(); } //static preference getters. double LineFormat::getDefEdgeWidth() { Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations"); std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm"); auto lg = TechDraw::LineGroup::lineGroupFactory(lgName); double width = lg->getWeight("Graphic"); delete lg; return width; } App::Color LineFormat::getDefEdgeColor() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors"); App::Color fcColor; fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000)); //black return fcColor; } int LineFormat::getDefEdgeStyle() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations"); int style = hGrp->GetInt("CosmoCLStyle", 2); //dashed return style; } //**************************************************************************************** TYPESYSTEM_SOURCE(TechDraw::CosmeticVertex, Base::Persistence) CosmeticVertex::CosmeticVertex() : TechDraw::Vertex() { point(Base::Vector3d(0.0, 0.0, 0.0)); Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations"); App::Color fcColor; fcColor.setPackedValue(hGrp->GetUnsigned("VertexColor", 0x00000000)); linkGeom = -1; color = fcColor; size = 3.0; style = 1; visible = true; } CosmeticVertex::CosmeticVertex(const TechDraw::CosmeticVertex* cv) : TechDraw::Vertex(cv) { linkGeom = cv->linkGeom; color = cv->color; size = cv->size; style = cv->style; visible = cv->visible; } CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc) { Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations"); App::Color fcColor; fcColor.setPackedValue(hGrp->GetUnsigned("VertexColor", 0xff000000)); linkGeom = -1; color = fcColor; //TODO: size = hGrp->getFloat("VertexSize",30.0); size = 30.0; style = 1; //TODO: implement styled vertexes visible = true; } std::string CosmeticVertex::toString(void) const { std::stringstream ss; ss << point().x << "," << point().y << "," << point().z << "," << linkGeom << "," << color.asHexString() << "," << size << "," << style << "," << visible; return ss.str(); } // Persistence implementers unsigned int CosmeticVertex::getMemSize (void) const { return 1; } void CosmeticVertex::Save(Base::Writer &writer) const { TechDraw::Vertex::Save(writer); writer.Stream() << writer.ind() << "" << endl; writer.Stream() << writer.ind() << "" << endl; writer.Stream() << writer.ind() << "" << endl; writer.Stream() << writer.ind() << "