Skip to content

Commit

Permalink
[TD] Add TaskPanel for Balloons
Browse files Browse the repository at this point in the history
TaskPanel can be open by double clicking either Balloon label on drawing
page or Balloon object in tree view.
  • Loading branch information
fjullien authored and WandererFan committed May 22, 2019
1 parent 81bae31 commit 36d341f
Show file tree
Hide file tree
Showing 18 changed files with 987 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/Mod/TechDraw/App/DrawViewBalloon.h
Expand Up @@ -73,13 +73,14 @@ class TechDrawExport DrawViewBalloon : public TechDraw::DrawView
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
Expand Down
6 changes: 6 additions & 0 deletions src/Mod/TechDraw/Gui/CMakeLists.txt
Expand Up @@ -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})
Expand All @@ -70,6 +71,7 @@ set(TechDrawGui_UIC_SRCS
TaskLeaderLine.ui
TaskRichAnno.ui
mrichtextedit.ui
TaskBalloon.ui
)

if(BUILD_QT5)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -281,6 +286,7 @@ SET(TechDrawGuiTaskDlgs_SRCS
TaskLeaderLine.ui
TaskRichAnno.ui
mrichtextedit.ui
TaskBalloon.ui
)
SOURCE_GROUP("TaskDialogs" FILES ${TechDrawGuiTaskDlgs_SRCS})

Expand Down
12 changes: 11 additions & 1 deletion src/Mod/TechDraw/Gui/QGIViewBalloon.cpp
Expand Up @@ -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>
Expand All @@ -68,6 +69,7 @@
#include "QGIViewDimension.h"
#include "QGVPage.h"
#include "MDIViewPage.h"
#include "TaskBalloon.h"

#define PI 3.14159

Expand All @@ -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),
Expand All @@ -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();
Expand Down
19 changes: 17 additions & 2 deletions src/Mod/TechDraw/Gui/QGIViewBalloon.h
Expand Up @@ -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
Expand All @@ -76,6 +90,7 @@ class TechDrawGuiExport QGIViewBalloon : public QGIView
QString getLabelText(void);
void draw_modifier(bool modifier);
void placeBalloon(QPointF pos);
TechDraw::DrawViewBalloon *dvBalloon;

public Q_SLOTS:
void balloonLabelDragged(bool ctrl);
Expand All @@ -94,15 +109,15 @@ public Q_SLOTS:

protected:
bool hasHover;
QGIDatumLabel* balloonLabel;
QGIBalloonLabel* balloonLabel;
QGIDimLines* balloonLines;
QGIDimLines* balloonShape;
QGIArrow* arrow;
double m_lineWidth;
bool m_obtuse;
void parentViewMousePressed(QGIView *view, QPointF pos);
QPointF *oldLabelCenter;
QGIView *m_parent;
QGIView *parent;

};

Expand Down
1 change: 1 addition & 0 deletions src/Mod/TechDraw/Gui/QGVPage.cpp
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/Mod/TechDraw/Gui/Resources/TechDraw.qrc
Expand Up @@ -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>
Expand Down
66 changes: 66 additions & 0 deletions src/Mod/TechDraw/Gui/Resources/icons/circular.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions src/Mod/TechDraw/Gui/Resources/icons/hexagon.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 36d341f

Please sign in to comment.