Sketcher: VisualLayer
===================== New class allowing to define a VisualLayer: - whether it is visible or not. - the line width to be used by coin for this layer. - the line pattern to be used by coin for this layer.
This commit is contained in:
committed by
abdullahtahiriyo
parent
8dba7f1ddb
commit
a6588536e1
@@ -152,6 +152,8 @@ SET(SketcherGui_SRCS
|
||||
ViewProviderPython.h
|
||||
ViewProviderSketchGeometryExtension.h
|
||||
ViewProviderSketchGeometryExtension.cpp
|
||||
VisualLayer.cpp
|
||||
VisualLayer.h
|
||||
)
|
||||
|
||||
SET(Python_SRCS
|
||||
|
||||
86
src/Mod/Sketcher/Gui/VisualLayer.cpp
Normal file
86
src/Mod/Sketcher/Gui/VisualLayer.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2023 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com *
|
||||
* *
|
||||
* 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"
|
||||
|
||||
#include <Base/Reader.h>
|
||||
#include <Base/Writer.h>
|
||||
|
||||
#include "VisualLayer.h"
|
||||
|
||||
using namespace SketcherGui;
|
||||
|
||||
//**************** VisualClassConfig **************************************//
|
||||
|
||||
VisualLayer::VisualLayer(unsigned int linePattern, float lineWidth, bool visible): linePattern(linePattern), lineWidth(lineWidth), visible(visible)
|
||||
{}
|
||||
|
||||
unsigned int VisualLayer::getLinePattern() const
|
||||
{
|
||||
return linePattern;
|
||||
}
|
||||
|
||||
float VisualLayer::getLineWidth() const
|
||||
{
|
||||
return lineWidth;
|
||||
}
|
||||
|
||||
void VisualLayer::setLinePattern(unsigned int linepattern)
|
||||
{
|
||||
linePattern = linepattern;
|
||||
}
|
||||
|
||||
void VisualLayer::setLineWidth(float linewidth)
|
||||
{
|
||||
lineWidth = linewidth;
|
||||
}
|
||||
|
||||
bool VisualLayer::isVisible() const
|
||||
{
|
||||
return visible;
|
||||
}
|
||||
|
||||
void VisualLayer::setVisible(bool show)
|
||||
{
|
||||
visible = show;
|
||||
}
|
||||
|
||||
void VisualLayer::Save(Base::Writer &writer) const
|
||||
{
|
||||
writer.Stream() << writer.ind()
|
||||
<< "<VisualLayer " <<
|
||||
"visible=\"" << (visible?std::string("true"):std::string("false")).c_str() <<
|
||||
"\" linePattern=\"" << linePattern <<
|
||||
"\" lineWidth=\"" << lineWidth << "\"/>" << std::endl;
|
||||
}
|
||||
|
||||
void VisualLayer::Restore(Base::XMLReader &reader)
|
||||
{
|
||||
reader.readElement("VisualLayer");
|
||||
|
||||
std::string str = reader.getAttribute("visible");
|
||||
visible = ( str == "true");
|
||||
|
||||
linePattern = reader.getAttributeAsUnsigned("linePattern");
|
||||
lineWidth = reader.getAttributeAsFloat("lineWidth");
|
||||
}
|
||||
|
||||
71
src/Mod/Sketcher/Gui/VisualLayer.h
Normal file
71
src/Mod/Sketcher/Gui/VisualLayer.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2023 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com *
|
||||
* *
|
||||
* 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 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SKETCHERGUI_VisualLayer_H
|
||||
#define SKETCHERGUI_VisualLayer_H
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
namespace SketcherGui
|
||||
{
|
||||
|
||||
/** Provides the visual layer configuration for a class of geometry.
|
||||
* A class of geometry can be any grouping of geometry, for
|
||||
* which the user wants to provide a per coin layer specific
|
||||
* configuration.
|
||||
*/
|
||||
class VisualLayer {
|
||||
public:
|
||||
explicit VisualLayer(unsigned int linePattern = 0xFFFF, float lineWidth = 3.0, bool visible = true);
|
||||
|
||||
unsigned int getLinePattern() const;
|
||||
float getLineWidth() const;
|
||||
|
||||
void setLinePattern(unsigned int linepattern);
|
||||
void setLineWidth(float linewidth);
|
||||
|
||||
bool isVisible() const;
|
||||
void setVisible(bool show);
|
||||
|
||||
void Save(Base::Writer &/*writer*/) const;
|
||||
void Restore(Base::XMLReader &/*reader*/);
|
||||
|
||||
private:
|
||||
unsigned int linePattern;
|
||||
float lineWidth;
|
||||
bool visible;
|
||||
|
||||
friend inline bool operator==(VisualLayer const& lhs, VisualLayer const& rhs);
|
||||
};
|
||||
|
||||
bool operator==(VisualLayer const& lhs, VisualLayer const& rhs)
|
||||
{
|
||||
return ( lhs.linePattern == rhs.linePattern ) &&
|
||||
( lhs.lineWidth == rhs.lineWidth ) &&
|
||||
( lhs.visible == rhs.visible );
|
||||
}
|
||||
|
||||
} // namespace SketcherGui
|
||||
|
||||
|
||||
#endif // SKETCHERGUI_VisualLayer_H
|
||||
Reference in New Issue
Block a user