1
/***************************************************************************
2
* Copyright (c) 2013 Luke Parry <l.parry@warwick.ac.uk> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
23
#include "PreCompiled.h"
26
# include <QPainterPath>
27
# include <QPainterPathStroker>
30
#include <App/Application.h>
31
#include <App/Material.h>
32
#include <Base/Console.h>
33
#include <Base/Parameter.h>
34
#include <Gui/Control.h>
35
#include <Mod/TechDraw/App/DrawUtil.h>
38
#include "PreferencesGui.h"
39
#include "TaskLineDecor.h"
42
using namespace TechDrawGui;
43
using namespace TechDraw;
45
QGIEdge::QGIEdge(int index) :
51
setFlag(QGraphicsItem::ItemIsFocusable, true); // to get key press events
52
setFlag(QGraphicsItem::ItemIsSelectable, true);
55
setCosmetic(isCosmetic);
59
// NOTE this refers to Qt cosmetic lines (a line with minimum width),
60
// not FreeCAD cosmetic lines
61
void QGIEdge::setCosmetic(bool state)
63
// Base::Console().Message("QGIE::setCosmetic(%d)\n", state);
70
void QGIEdge::setHiddenEdge(bool b) {
73
m_styleCurrent = getHiddenStyle();
75
m_styleCurrent = Qt::SolidLine;
79
void QGIEdge::setPrettyNormal() {
80
// Base::Console().Message("QGIE::setPrettyNormal()\n");
82
m_colCurrent = getHiddenColor();
84
m_colCurrent = getNormalColor();
86
//should call QGIPP::setPrettyNormal()?
89
QColor QGIEdge::getHiddenColor()
91
App::Color fcColor = App::Color((uint32_t) Preferences::getPreferenceGroup("Colors")->GetUnsigned("HiddenColor", 0x000000FF));
92
return PreferencesGui::getAccessibleQColor(fcColor.asValue<QColor>());
95
Qt::PenStyle QGIEdge::getHiddenStyle()
97
//Qt::PenStyle - NoPen, Solid, Dashed, ...
98
//Preferences::General - Solid, Dashed
99
// Dashed lines should use ISO Line #2 instead of Qt::DashedLine
100
Qt::PenStyle hidStyle = static_cast<Qt::PenStyle> (Preferences::getPreferenceGroup("General")->GetInt("HiddenLine", 0) + 1);
104
double QGIEdge::getEdgeFuzz() const
106
return PreferencesGui::edgeFuzz();
110
QRectF QGIEdge::boundingRect() const
112
return shape().controlPointRect();
115
QPainterPath QGIEdge::shape() const
117
QPainterPath outline;
118
QPainterPathStroker stroker;
119
stroker.setWidth(getEdgeFuzz());
120
outline = stroker.createStroke(path());
124
void QGIEdge::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
127
QGIView *parent = dynamic_cast<QGIView *>(parentItem());
128
if (parent && parent->getViewObject() && parent->getViewObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
129
TechDraw::DrawViewPart *baseFeat = static_cast<TechDraw::DrawViewPart *>(parent->getViewObject());
130
std::vector<std::string> edgeName(1, DrawUtil::makeGeomName("Edge", getProjIndex()));
132
Gui::Control().showDialog(new TaskDlgLineDecor(baseFeat, edgeName));
138
void QGIEdge::setLinePen(QPen linePen)