/*************************************************************************** * Copyright (c) 2019 WandererFan * * Copyright (c) 2022 Benjamin Bræstrup Sayoc * * * * 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 * * * ***************************************************************************/ //! CosmeticVertex point is stored in unscaled, unrotated form #include #include #include #include "CosmeticVertex.h" #include "CosmeticVertexPy.h" #include "LineGroup.h" #include "Preferences.h" #include "DrawUtil.h" #include "DrawViewPart.h" using namespace TechDraw; using namespace std; using DU = DrawUtil; TYPESYSTEM_SOURCE(TechDraw::CosmeticVertex, Base::Persistence) CosmeticVertex::CosmeticVertex() : TechDraw::Vertex() { color = Preferences::vertexColor(); size = Preferences::vertexScale() * LineGroup::getDefaultWidth("Thin"); hlrVisible = true; cosmetic = true; cosmeticTag = getTagAsString(); } CosmeticVertex::CosmeticVertex(const TechDraw::CosmeticVertex* cv) : TechDraw::Vertex(cv), permaPoint(cv->permaPoint), linkGeom(cv->linkGeom), color(cv->color), size(cv->size), style(cv->style), visible(cv->visible) { // Base fields hlrVisible = true; cosmetic = true; cosmeticTag = getTagAsString(); } CosmeticVertex::CosmeticVertex(const Base::Vector3d& loc) : TechDraw::Vertex(loc), permaPoint(loc), color(Preferences::vertexColor()) { size = Preferences::vertexScale() * LineGroup::getDefaultWidth("Thick"); hlrVisible = true; cosmetic = true; cosmeticTag = getTagAsString(); } void CosmeticVertex::move(const Base::Vector3d& newPos) { point(newPos); } void CosmeticVertex::moveRelative(const Base::Vector3d& movement) { point( point() += movement); } std::string CosmeticVertex::toString() const { std::stringstream ss; ss << point().x << ", " << point().y << ", " << point().z << ", " << " / " << linkGeom << ", " << " / " << color.asHexString() << ", " << " / " << size << ", " << " / " << style << ", " << " / " << visible << " / " ; ss << getTagAsString(); return ss.str(); } // Persistence implementers unsigned int CosmeticVertex::getMemSize () const { return 1; } void CosmeticVertex::Save(Base::Writer &writer) const { TechDraw::Vertex::Save(writer); writer.Stream() << writer.ind() << "" << '\n'; writer.Stream() << writer.ind() << "" << '\n'; writer.Stream() << writer.ind() << "" << '\n'; writer.Stream() << writer.ind() << "" << '\n'; writer.Stream() << writer.ind() << "