Files
create/src/Mod/TechDraw/App/LineFormat.h
WandererFan 50f970efd7 [TD]Cosmetic function overhaul (#14216)
* [TD]Cosmetic geometry and tools update

- all cosmetics to store geometry in same form
- all cosmetics to survive scaling and rotation
- extension functions to survive scaling and rotation

* [TD]overhaul leader point storage and editing

- add py routine makeLeader(points)

* [TD]add leader conversion utility

* [TD]Set Leader RotateWithView default to true

* [TD]fix intersection vertex position

* [TD]add CosmeticEdge::makeLineFromCanonicalPoints

* [TD]fix 2 Extension tools

- positioning in DrawCosmeticCircle
- mishandling of points in execLineParallelPerpendicular

* [TD]Remove duplicate constexpr

* [TD]fix 2x Cosmetic arc tools

* [TD]refactor LineFormat out of Cosmetic

* [TD]move cosmetic appearance settings to LineFormat

* [TD]remove 2 unused methods

* [TD]apply format to blue line & circle tools

* [TD]fix ballon arrowhead does not rotate with view

* [TD]fix CosmeticCircle3Points

* [TD]allow multiple cosmetic object deletions

* [TD]fix extend/shorten centerline
2024-05-23 09:41:42 -04:00

97 lines
3.6 KiB
C++

// SPDX-License-Identifier: LGPL-2.0-or-later
/***************************************************************************
* Copyright (c) 2024 wandererfan <wandererfan at gmail dot 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 TECHDRAW_LINEFORMAT_H
#define TECHDRAW_LINEFORMAT_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <QColor>
#include <App/Color.h>
namespace TechDraw {
//! general purpose line format specifier
class TechDrawExport LineFormat
{
public:
static constexpr size_t InvalidLine{0};
LineFormat();
LineFormat(const int style,
const double weight,
const App::Color& color,
const bool visible,
const int lineNumber);
// TODO: phase out the old 4 parameter constructor
LineFormat(const int style,
const double weight,
const App::Color& color,
const bool visible);
~LineFormat() = default;
// style was used to specify QPen styles. line number (from LineGenerator) should be used now.
int getStyle() const { return m_style; }
void setStyle(int style) { m_style = style; }
double getWidth() const { return m_weight; }
void setWidth(double width) {m_weight = width; }
App::Color getColor() const { return m_color; }
void setColor(App::Color color) { m_color = color; }
QColor getQColor() const { return m_color.asValue<QColor>(); }
void setQColor(QColor qColor) { m_color.set(qColor.redF(), qColor.greenF(), qColor.blueF(), 1.0 - qColor.alphaF()); }
bool getVisible() const { return m_visible; }
void setVisible(bool viz) { m_visible = viz; }
int getLineNumber() const { return m_lineNumber; }
void setLineNumber(int number) { m_lineNumber = number; }
static double getDefEdgeWidth();
static App::Color getDefEdgeColor();
static int getDefEdgeStyle();
void dump(const char* title);
std::string toString() const;
static void initCurrentLineFormat();
static LineFormat& getCurrentLineFormat();
static void setCurrentLineFormat(LineFormat& newformat);
private:
int m_style;
double m_weight;
App::Color m_color;
bool m_visible;
int m_lineNumber {1};
};
} //end namespace TechDraw
#endif //TECHDRAW_LINEFORMAT_H