35 #include "../vinteractivetool.h"
36 #include "../ifc/exception/vexceptionbadid.h"
37 #include "../vdatatool.h"
38 #include "../vgeometry/vpointf.h"
39 #include "../vmisc/vabstractapplication.h"
40 #include "../vmisc/def.h"
41 #include "../vmisc/vabstractapplication.h"
42 #include "../vwidgets/vabstractmainwindow.h"
43 #include "../vwidgets/vmaingraphicsscene.h"
44 #include "../vwidgets/vmaingraphicsview.h"
45 #include "../vtools/undocommands/addgroup.h"
46 #include "../vtools/undocommands/add_groupitem.h"
47 #include "../vtools/undocommands/remove_groupitem.h"
49 #include <qcompilerdetection.h>
53 #include <QDomElement>
54 #include <QGraphicsSceneContextMenuEvent>
57 #include <QMetaObject>
87 virtual
void ShowTool(quint32
id,
bool enable);
91 virtual
void Disable(
bool disable, const QString &draftBlockName)=0;
112 virtual
void AddToFile() Q_DECL_OVERRIDE;
117 bool CorrectDisable(
bool disable, const QString &draftBlockName) const;
123 template <typename Dialog>
128 template <typename
Item>
131 template <typename T>
134 template <typename T>
142 template <typename Dialog>
173 qCDebug(vTool,
"Creating tool context menu.");
175 QAction *actionOption = menu.addAction(QIcon::fromTheme(
"preferences-other"), tr(
"Properties"));
178 QAction *actionShowPointName = menu.addAction(QIcon(
"://icon/16x16/open_eye.png"), tr(
"Show Point Name"));
179 actionShowPointName->setCheckable(
true);
187 actionShowPointName->setVisible(
false);
190 QAction *actionDelete = menu.addAction(QIcon::fromTheme(
"edit-delete"), tr(
"Delete"));
197 qCDebug(vTool,
"Delete disabled. Tool has children.");
198 actionDelete->setEnabled(
false);
202 qCDebug(vTool,
"Delete enabled. Tool has no children.");
203 actionDelete->setEnabled(
true);
208 qCDebug(vTool,
"Delete enabled. Ignore referens value.");
209 actionDelete->setEnabled(
true);
214 qCDebug(vTool,
"Delete disabled.");
215 actionDelete->setEnabled(
false);
220 QActionGroup* actionAddGroupMenu=
new QActionGroup(
this);
222 if(not groupsNotContainingItem.empty())
224 QMenu *menuAddGroupItem = menu.addMenu(QIcon(
"://icon/32x32/add.png"), tr(
"Add Group Object"));
225 QStringList list = QStringList(groupsNotContainingItem.values());
226 list.sort(Qt::CaseInsensitive);
228 for(
int i=0; i<list.count(); ++i)
230 QAction *actionAddGroupItem = menuAddGroupItem->addAction(list[i]);
231 actionAddGroupMenu->addAction(actionAddGroupItem);
232 const quint32 groupId = groupsNotContainingItem.key(list[i]);
233 actionAddGroupItem->setData(groupId);
234 groupsNotContainingItem.remove(groupId);
240 QActionGroup* actionDeleteGroupMenu =
new QActionGroup(
this);
242 if(not groupsContainingItem.empty())
244 QMenu *menuRemoveGroupItem = menu.addMenu(QIcon(
"://icon/32x32/remove.png"), tr(
"Remove Group Object"));
246 QStringList list = QStringList(groupsContainingItem.values());
247 list.sort(Qt::CaseInsensitive);
249 for(
int i=0; i<list.count(); ++i)
251 QAction *actionRemoveGroupItem = menuRemoveGroupItem->addAction(list[i]);
252 actionDeleteGroupMenu->addAction(actionRemoveGroupItem);
253 const quint32 groupId = groupsContainingItem.key(list[i]);
254 actionRemoveGroupItem->setData(groupId);
255 groupsContainingItem.remove(groupId);
259 QAction *selectedAction = menu.exec(event->screenPos());
260 if(selectedAction ==
nullptr)
264 if (selectedAction == actionOption)
266 qCDebug(vTool,
"Show options.");
267 qApp->getSceneView()->itemClicked(
nullptr);
278 else if (selectedAction == actionDelete)
280 qCDebug(vTool,
"Deleting Object.");
284 else if (selectedAction == actionShowPointName)
288 else if (selectedAction->actionGroup() == actionAddGroupMenu)
290 quint32 groupId = selectedAction->data().toUInt();
295 scene->clearSelection();
302 qApp->getUndoStack()->push(command);
305 else if (selectedAction->actionGroup() == actionDeleteGroupMenu)
307 quint32 groupId = selectedAction->data().toUInt();
312 scene->clearSelection();
319 qApp->getUndoStack()->push(command);
325 template <
typename Item>
335 if (
id == item->m_id)
342 template <
typename T>
355 qCDebug(vTool,
"Error! Couldn't get object name by id = %s. %s %s", qUtf8Printable(QString().setNum(
id)),
363 template <
typename T>
virtual void updateGroups()=0
QDomElement removeGroupItem(quint32 toolId, quint32 objectId, quint32 groupId)
Removes the item of given toolId and objectId from the group of given groupId.
QDomElement addGroupItem(quint32 toolId, quint32 objectId, quint32 groupId)
Adds an item to the given group with the given toolId and objectId.
QMap< quint32, QString > getGroupsContainingItem(quint32 toolId, quint32 objectId, bool containsItem)
Returns the groups that contain or do not contain the item identified by the toolid and the objectid.
The VContainer class container of all variables.
const QSharedPointer< VGObject > GetGObject(quint32 id) const
GetGObject returns a point by id.
const QSharedPointer< T > GeometricObject(const quint32 &id) const
The VExceptionBadId class for exception bad id.
virtual QString ErrorMessage() const Q_DECL_OVERRIDE
ErrorMessage return main error message.
virtual QString DetailedInformation() const
DetailedInformation return detailed information about error.
The VGObject class keep information graphical objects.
The VMainGraphicsScene class main scene.
void chosenItem(quint32 id, const SceneObject &type)
chosenItem emit ChosenObject signal.
void curvePiecesMode(bool mode)
void ItemSelection(const SelectionType &type)
void EnableToolMove(bool move)
void DisableItem(bool disable, const QString &draftBlockName)
void SelectedItem(bool selected, quint32 object, quint32 tool)