1
/***************************************************************************
2
* Copyright (c) 2020 WandererFan <wandererfan@gmail.com> *
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"
25
# include <QGraphicsSceneEvent>
28
#include <Mod/TechDraw/App/DrawUtil.h>
30
#include "QGIGhostHighlight.h"
31
#include "PreferencesGui.h"
35
using namespace TechDrawGui;
36
using namespace TechDraw;
38
QGIGhostHighlight::QGIGhostHighlight()
43
//make the ghost very visible
44
QFont f(Preferences::labelFontQString());
45
double fontSize = Preferences::labelFontSizeMM();
48
setStyle(Qt::SolidLine);
49
setColor(prefSelectColor());
50
setWidth(Rez::guiX(1.0));
51
setRadius(10.0); //placeholder
54
QGIGhostHighlight::~QGIGhostHighlight()
59
void QGIGhostHighlight::mousePressEvent(QGraphicsSceneMouseEvent * event)
61
// Base::Console().Message("QGIGhostHighlight::mousePress() - %X\n", this);
62
if ( (event->button() == Qt::LeftButton) &&
63
(flags() & QGraphicsItem::ItemIsMovable) ) {
67
QGIHighlight::mousePressEvent(event);
70
void QGIGhostHighlight::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
72
// Base::Console().Message("QGIGhostHighlight::mouseRelease() - pos: %s scenePos: %s\n",
73
// DrawUtil::formatVector(pos()).c_str(),
74
// DrawUtil::formatVector(mapToScene(pos())).c_str());
77
Q_EMIT positionChange(scenePos());
80
QGIHighlight::mouseReleaseEvent(event);
83
void QGIGhostHighlight::setInteractive(bool state)
85
setFlag(QGraphicsItem::ItemIsSelectable, state);
86
setFlag(QGraphicsItem::ItemIsMovable, state);
87
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, state);
88
setFlag(QGraphicsItem::ItemSendsGeometryChanges, state);
91
//radius should scaled, but not Rez::guix()
92
void QGIGhostHighlight::setRadius(double r)
94
setBounds(-r, r, r, -r);
97
#include <Mod/TechDraw/Gui/moc_QGIGhostHighlight.cpp>