[TD] Add TaskPanel for Balloons

TaskPanel can be open by double clicking either Balloon label on drawing
page or Balloon object in tree view.
This commit is contained in:
Franck Jullien
2019-04-22 22:16:40 +02:00
committed by WandererFan
parent 81bae31085
commit 36d341f3df
18 changed files with 987 additions and 6 deletions

View File

@@ -73,13 +73,14 @@ public:
return "TechDrawGui::ViewProviderBalloon";
}
static const char* balloonTypeEnums[];
static const char* endTypeEnums[];
protected:
void onChanged(const App::Property* prop);
virtual void onDocumentRestored();
private:
static const char* endTypeEnums[];
static const char* balloonTypeEnums[];
};
} //namespace TechDraw

View File

@@ -48,6 +48,7 @@ set(TechDrawGui_MOC_HDRS
QGMText.h
mrichtextedit.h
mtextedit.h
TaskBalloon.h
)
fc_wrap_cpp(TechDrawGui_MOC_SRCS ${TechDrawGui_MOC_HDRS})
@@ -70,6 +71,7 @@ set(TechDrawGui_UIC_SRCS
TaskLeaderLine.ui
TaskRichAnno.ui
mrichtextedit.ui
TaskBalloon.ui
)
if(BUILD_QT5)
@@ -123,6 +125,9 @@ SET(TechDrawGui_SRCS
TaskSectionView.ui
TaskSectionView.cpp
TaskSectionView.h
TaskBalloon.ui
TaskBalloon.cpp
TaskBalloon.h
TaskGeomHatch.ui
TaskGeomHatch.cpp
TaskGeomHatch.h
@@ -281,6 +286,7 @@ SET(TechDrawGuiTaskDlgs_SRCS
TaskLeaderLine.ui
TaskRichAnno.ui
mrichtextedit.ui
TaskBalloon.ui
)
SOURCE_GROUP("TaskDialogs" FILES ${TechDrawGuiTaskDlgs_SRCS})

View File

@@ -48,6 +48,7 @@
#include <Base/Parameter.h>
#include <Base/UnitsApi.h>
#include <Gui/Command.h>
#include <Gui/Control.h>
#include <string>
#include <Mod/Part/App/PartFeature.h>
@@ -68,6 +69,7 @@
#include "QGIViewDimension.h"
#include "QGVPage.h"
#include "MDIViewPage.h"
#include "TaskBalloon.h"
#define PI 3.14159
@@ -76,6 +78,12 @@
using namespace TechDraw;
using namespace TechDrawGui;
void QGIBalloonLabel::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event)
{
Gui::Control().showDialog(new TaskDlgBalloon(parent));
QGraphicsItem::mouseDoubleClickEvent(event);
}
//**************************************************************
QGIViewBalloon::QGIViewBalloon() :
hasHover(false),
@@ -85,7 +93,9 @@ QGIViewBalloon::QGIViewBalloon() :
setFlag(QGraphicsItem::ItemIsMovable, false);
setCacheMode(QGraphicsItem::NoCache);
balloonLabel = new QGIDatumLabel();
balloonLabel = new QGIBalloonLabel();
balloonLabel->parent = this;
addToGroup(balloonLabel);
balloonLabel->setColor(getNormalColor());
balloonLabel->setPrettyNormal();

View File

@@ -52,6 +52,20 @@ class QGIArrow;
class QGIDimLines;
class QGIViewBalloon;
class QGIBalloonLabel : public QGIDatumLabel
{
Q_OBJECT
public:
enum {Type = QGraphicsItem::UserType + 141};
int type() const override { return Type;}
QGIViewBalloon *parent;
protected:
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
};
//*******************************************************************
class TechDrawGuiExport QGIViewBalloon : public QGIView
@@ -76,6 +90,7 @@ public:
QString getLabelText(void);
void draw_modifier(bool modifier);
void placeBalloon(QPointF pos);
TechDraw::DrawViewBalloon *dvBalloon;
public Q_SLOTS:
void balloonLabelDragged(bool ctrl);
@@ -94,7 +109,7 @@ protected:
protected:
bool hasHover;
QGIDatumLabel* balloonLabel;
QGIBalloonLabel* balloonLabel;
QGIDimLines* balloonLines;
QGIDimLines* balloonShape;
QGIArrow* arrow;
@@ -102,7 +117,7 @@ protected:
bool m_obtuse;
void parentViewMousePressed(QGIView *view, QPointF pos);
QPointF *oldLabelCenter;
QGIView *m_parent;
QGIView *parent;
};

View File

@@ -426,6 +426,7 @@ QGIView * QGVPage::addViewBalloon(TechDraw::DrawViewBalloon *balloon)
ourScene->addItem(vBalloon);
vBalloon->setViewPartFeature(balloon);
vBalloon->dvBalloon = balloon;
QGIView *parent = 0;
parent = findParent(vBalloon);

View File

@@ -75,6 +75,13 @@
<file>icons/arrow-cw.svg</file>
<file>icons/techdraw-lock.png</file>
<file>icons/cursor-balloon.png</file>
<file>icons/none.svg</file>
<file>icons/circular.svg</file>
<file>icons/hexagon.svg</file>
<file>icons/inspection.svg</file>
<file>icons/rectangle.svg</file>
<file>icons/triangle.svg</file>
<file>icons/square.svg</file>
<file>icons/MRTE/menu.svg</file>
<file>icons/MRTE/bgColor.svg</file>
<file>icons/MRTE/fgColor.svg</file>

View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="48"
height="48"
id="svg4024"
sodipodi:docname="circular.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1121"
id="namedview9"
showgrid="true"
inkscape:zoom="13.906433"
inkscape:cx="37.330109"
inkscape:cy="20.212742"
inkscape:window-x="1920"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg4024"
showguides="false"
inkscape:lockguides="false" />
<defs
id="defs4026" />
<metadata
id="metadata4029">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<path
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:6;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path3733"
sodipodi:type="arc"
sodipodi:cx="23.931456"
sodipodi:cy="24.140453"
sodipodi:rx="17"
sodipodi:ry="17"
sodipodi:start="0.00034116474"
sodipodi:end="6.981317e-05"
sodipodi:open="true"
d="M 40.931455,24.146253 A 17,17 0 0 1 23.926809,41.140453 17,17 0 0 1 6.931456,24.13696 17,17 0 0 1 23.933796,7.1404535 17,17 0 0 1 40.931456,24.14164" />
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="48"
height="48"
id="svg4024"
sodipodi:docname="hexagon.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1121"
id="namedview9"
showgrid="true"
inkscape:zoom="13.906433"
inkscape:cx="25.179163"
inkscape:cy="21.702017"
inkscape:window-x="1920"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg4024"
showguides="true"
inkscape:lockguides="false"
inkscape:guide-bbox="true">
<sodipodi:guide
position="15,35"
orientation="1,0"
id="guide4943"
inkscape:locked="false" />
<sodipodi:guide
position="30,35"
orientation="1,0"
id="guide4945"
inkscape:locked="false" />
<inkscape:grid
type="xygrid"
id="grid4947" />
<sodipodi:guide
position="14,40"
orientation="0,1"
id="guide4949"
inkscape:locked="false" />
<sodipodi:guide
position="19,20"
orientation="0,1"
id="guide4951"
inkscape:locked="false" />
<sodipodi:guide
position="22,30"
orientation="0,1"
id="guide4953"
inkscape:locked="false" />
<sodipodi:guide
position="9,30"
orientation="1,0"
id="guide4955"
inkscape:locked="false" />
<sodipodi:guide
position="36,30"
orientation="1,0"
id="guide4957"
inkscape:locked="false" />
</sodipodi:namedview>
<defs
id="defs4026" />
<metadata
id="metadata4029">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<path
style="fill:none;stroke:#000000;stroke-width:5.99999952;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 7.0000007,23.5 14.428572,7.9999993 H 33 L 40.428571,23.5 33,39 H 14.428572 Z"
id="path4965"
inkscape:connector-curvature="0" />
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="48"
height="48"
id="svg4024"
sodipodi:docname="inspection.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1121"
id="namedview9"
showgrid="true"
inkscape:zoom="13.906433"
inkscape:cx="37.330109"
inkscape:cy="20.212742"
inkscape:window-x="1920"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg4024"
showguides="false"
inkscape:lockguides="false" />
<defs
id="defs4026" />
<metadata
id="metadata4029">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<path
style="fill:none;stroke:#000000;stroke-width:6.00000048;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 14.07441,15.176999 33.296063,15.033181"
id="path4561"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:6;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4567"
sodipodi:type="arc"
sodipodi:cx="15.470214"
sodipodi:cy="24.556917"
sodipodi:rx="9.9536495"
sodipodi:ry="9.3841457"
sodipodi:start="1.5626439"
sodipodi:end="4.6823693"
sodipodi:open="true"
d="M 15.551359,33.940751 A 9.9536495,9.3841457 0 0 1 5.5183773,24.736013 9.9536495,9.3841457 0 0 1 15.171453,15.177" />
<path
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:6;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4567-3"
sodipodi:type="arc"
sodipodi:cx="-32.631432"
sodipodi:cy="24.413099"
sodipodi:rx="10.008474"
sodipodi:ry="9.3841457"
sodipodi:start="1.5626439"
sodipodi:end="4.6823693"
sodipodi:open="true"
d="m -32.549839,33.796933 a 10.008474,9.3841457 0 0 1 -10.088244,-9.204738 10.008474,9.3841457 0 0 1 9.706245,-9.559013"
transform="scale(-1,1)" />
<path
style="fill:none;stroke:#000000;stroke-width:6;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 15.133592,33.94075 33.38428,33.796932"
id="path4561-6"
inkscape:connector-curvature="0" />
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="48"
height="48"
id="svg4024"
sodipodi:docname="none.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1121"
id="namedview9"
showgrid="true"
inkscape:zoom="13.906433"
inkscape:cx="21.941547"
inkscape:cy="20.212742"
inkscape:window-x="1920"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg4024"
showguides="false"
inkscape:lockguides="false" />
<defs
id="defs4026" />
<metadata
id="metadata4029">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="48"
height="48"
id="svg4024"
sodipodi:docname="rectangle.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1121"
id="namedview9"
showgrid="true"
inkscape:zoom="13.906433"
inkscape:cx="37.330109"
inkscape:cy="20.212742"
inkscape:window-x="1920"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg4024"
showguides="false"
inkscape:lockguides="false" />
<defs
id="defs4026" />
<metadata
id="metadata4029">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<rect
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:6;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4752"
width="36.755505"
height="21.788477"
x="5.3113585"
y="13.986965" />
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="48"
height="48"
id="svg4024"
sodipodi:docname="square.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1121"
id="namedview9"
showgrid="true"
inkscape:zoom="13.906433"
inkscape:cx="37.330109"
inkscape:cy="20.212742"
inkscape:window-x="1920"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg4024"
showguides="false"
inkscape:lockguides="false" />
<defs
id="defs4026" />
<metadata
id="metadata4029">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<rect
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:6;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4752"
width="34.742046"
height="30.41758"
x="6.533814"
y="7.8746858" />
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="48"
height="48"
id="svg4024"
sodipodi:docname="triangle.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1121"
id="namedview9"
showgrid="true"
inkscape:zoom="13.906433"
inkscape:cx="37.330109"
inkscape:cy="20.212742"
inkscape:window-x="1920"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg4024"
showguides="false"
inkscape:lockguides="false" />
<defs
id="defs4026" />
<metadata
id="metadata4029">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<path
style="fill:none;stroke:#000000;stroke-width:5.99999952;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 24.424112,11.071 8.832708,37.464806 39.750129,37.597107 Z"
id="path4540"
inkscape:connector-curvature="0" />
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,148 @@
/***************************************************************************
* Copyright (c) 2016 WandererFan <wandererfan@gmail.com> *
* Copyright (c) 2019 Franck Jullien <franck.jullien@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"
#ifndef _PreComp_
#include <cmath>
#endif // #ifndef _PreComp_
#include <Base/Console.h>
#include <Base/Vector3D.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
#include <Gui/Document.h>
#include <Gui/Selection.h>
#include <Gui/ViewProvider.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Mod/Part/App/PartFeature.h>
#include <Mod/TechDraw/App/DrawViewBalloon.h>
#include <Mod/TechDraw/App/DrawPage.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/Gui/ui_TaskBalloon.h>
#include "QGIViewBalloon.h"
#include "TaskBalloon.h"
using namespace Gui;
using namespace TechDraw;
using namespace TechDrawGui;
TaskBalloon::TaskBalloon(QGIViewBalloon *parent) :
ui(new Ui_TaskBalloon)
{
int i = 0;
m_parent = parent;
ui->setupUi(this);
QString qs = QString::number(parent->dvBalloon->SymbolScale.getValue(), 'f', 2);
ui->inputScale->setText(qs);
std::string value = parent->dvBalloon->Text.getValue();
qs = QString::fromUtf8(value.data(), value.size());
ui->inputValue->setText(qs);
ui->inputValue->selectAll();
QTimer::singleShot(0, ui->inputValue, SLOT(setFocus()));
i = ui->comboEndType->findText(QString::fromUtf8(parent->dvBalloon->EndType.getValueAsString()));
ui->comboEndType->setCurrentIndex(i);
i = ui->comboSymbol->findText(QString::fromUtf8(parent->dvBalloon->Symbol.getValueAsString()));
ui->comboSymbol->setCurrentIndex(i);
}
TaskBalloon::~TaskBalloon()
{
delete ui;
}
bool TaskBalloon::accept()
{
m_parent->dvBalloon->Text.setValue(ui->inputValue->text().toUtf8().constData());
m_parent->dvBalloon->SymbolScale.setValue(ui->inputScale->text().toDouble());
m_parent->dvBalloon->EndType.setValue(ui->comboEndType->currentText().toUtf8().constData());
m_parent->dvBalloon->Symbol.setValue(ui->comboSymbol->currentText().toUtf8().constData());
m_parent->updateView(true);
return true;
}
bool TaskBalloon::reject()
{
return false;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TaskDlgBalloon::TaskDlgBalloon(QGIViewBalloon *parent) :
TaskDialog()
{
widget = new TaskBalloon(parent);
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("TechDraw_Balloon"), widget->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);
}
TaskDlgBalloon::~TaskDlgBalloon()
{
}
void TaskDlgBalloon::update()
{
//widget->updateTask();
}
//==== calls from the TaskView ===============================================================
void TaskDlgBalloon::open()
{
}
void TaskDlgBalloon::clicked(int i)
{
Q_UNUSED(i);
}
bool TaskDlgBalloon::accept()
{
widget->accept();
return true;
}
bool TaskDlgBalloon::reject()
{
widget->reject();
return true;
}
#include <Mod/TechDraw/Gui/moc_TaskBalloon.cpp>

View File

@@ -0,0 +1,91 @@
/***************************************************************************
* Copyright (c) 2016 WandererFan <wandererfan@gmail.com> *
* Copyright (c) 2019 Franck Jullien <franck.jullien@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 GUI_TASKVIEW_TASKBALLOON_H
#define GUI_TASKVIEW_TASKBALLOON_H
#include <Gui/TaskView/TaskView.h>
#include <Gui/TaskView/TaskDialog.h>
#include <Mod/TechDraw/Gui/ui_TaskBalloon.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
#include "QGIViewBalloon.h"
class Ui_TaskBalloon;
namespace TechDrawGui
{
class TaskBalloon : public QWidget
{
Q_OBJECT
public:
TaskBalloon(QGIViewBalloon *parent);
~TaskBalloon();
public:
virtual bool accept();
virtual bool reject();
private:
Ui_TaskBalloon *ui;
QGIViewBalloon *m_parent;
};
class TaskDlgBalloon : public Gui::TaskView::TaskDialog
{
Q_OBJECT
public:
TaskDlgBalloon(QGIViewBalloon *parent);
~TaskDlgBalloon();
public:
/// is called the TaskView when the dialog is opened
virtual void open();
/// is called by the framework if an button is clicked which has no accept or reject role
virtual void clicked(int);
/// is called by the framework if the dialog is accepted (Ok)
virtual bool accept();
/// is called by the framework if the dialog is rejected (Cancel)
virtual bool reject();
/// is called by the framework if the user presses the help button
virtual void helpRequested() { return;}
virtual bool isAllowedAlterDocument(void) const
{ return false; }
void update();
protected:
private:
TaskBalloon * widget;
Gui::TaskView::TaskBox* taskbox;
};
} //namespace TechDrawGui
#endif // #ifndef GUI_TASKVIEW_TASKBALLOON_H

View File

@@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TechDrawGui::TaskBalloon</class>
<widget class="QWidget" name="TechDrawGui::TaskBalloon">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>306</height>
</rect>
</property>
<property name="windowTitle">
<string>Balloon</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="1">
<widget class="QComboBox" name="comboEndType">
<item>
<property name="text">
<string>Arrow</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/arrowfilled.svg</normaloff>:/icons/arrowfilled.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Dot</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/arrowdot.svg</normaloff>:/icons/arrowdot.svg</iconset>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Start Symbol</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Symbol:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Value:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboSymbol">
<item>
<property name="text">
<string>Circular</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/circular.svg</normaloff>:/icons/circular.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>None</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/none.svg</normaloff>:/icons/none.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Triangle</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/triangle.svg</normaloff>:/icons/triangle.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Inspection</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/inspection.svg</normaloff>:/icons/inspection.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Hexagon</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/hexagon.svg</normaloff>:/icons/hexagon.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Square</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/square.svg</normaloff>:/icons/square.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Rectangle</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/rectangle.svg</normaloff>:/icons/rectangle.svg</iconset>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Scale:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="inputValue"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="inputScale"/>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="Resources/TechDraw.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -37,9 +37,18 @@
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Control.h>
#include <Gui/Command.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/Selection.h>
#include <Gui/ViewProviderDocumentObject.h>
#include <Mod/TechDraw/App/LineGroup.h>
#include "TaskBalloon.h"
#include "ViewProviderBalloon.h"
using namespace TechDrawGui;
@@ -104,6 +113,41 @@ std::vector<std::string> ViewProviderBalloon::getDisplayModes(void) const
return StrList;
}
bool ViewProviderBalloon::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default ) {
if (Gui::Control().activeDialog()) {
return false;
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
auto qgivBalloon(dynamic_cast<QGIViewBalloon*>(getQView()));
if (qgivBalloon) {
Gui::Control().showDialog(new TaskDlgBalloon(qgivBalloon));
}
return true;
} else {
return ViewProviderDrawingView::setEdit(ModNum);
}
return true;
}
void ViewProviderBalloon::unsetEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
Gui::Control().closeDialog();
}
else {
ViewProviderDrawingView::unsetEdit(ModNum);
}
}
bool ViewProviderBalloon::doubleClicked(void)
{
setEdit(ViewProvider::Default);
return true;
}
void ViewProviderBalloon::updateData(const App::Property* p)
{
ViewProviderDrawingView::updateData(p);

View File

@@ -58,6 +58,9 @@ public:
virtual std::vector<std::string> getDisplayModes(void) const;
virtual void updateData(const App::Property*);
virtual void onChanged(const App::Property* p);
virtual bool setEdit(int ModNum);
virtual void unsetEdit(int ModNum);
virtual bool doubleClicked(void);
virtual TechDraw::DrawViewBalloon* getViewObject() const;
};