[TD]allow multiple primitives in complex selections
This commit is contained in:
@@ -612,3 +612,16 @@ Base::Vector3d DrawGuiUtil::toGuiPoint(DrawView* obj, const Base::Vector3d& toCo
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//! true if targetObj is in the selection list
|
||||
bool DrawGuiUtil::findObjectInSelection(const std::vector<Gui::SelectionObject>& selection,
|
||||
const App::DocumentObject& targetObject)
|
||||
{
|
||||
for (auto& selObj : selection) {
|
||||
if (&targetObject == selObj.getObject()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,9 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QGraphicsItem>
|
||||
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
|
||||
@@ -35,10 +37,6 @@ class QComboBox;
|
||||
class QPointF;
|
||||
class QRectF;
|
||||
|
||||
namespace App {
|
||||
class DocumentObject;
|
||||
}
|
||||
|
||||
namespace Part {
|
||||
class Feature;
|
||||
}
|
||||
@@ -85,6 +83,9 @@ class TechDrawGuiExport DrawGuiUtil {
|
||||
static Base::Vector3d fromSceneCoords(const Base::Vector3d& sceneCoord, bool invert = true);
|
||||
static Base::Vector3d toSceneCoords(const Base::Vector3d& pageCoord, bool invert = true);
|
||||
static Base::Vector3d toGuiPoint(TechDraw::DrawView* obj, const Base::Vector3d& toConvert);
|
||||
|
||||
static bool findObjectInSelection(const std::vector<Gui::SelectionObject>& selection,
|
||||
const App::DocumentObject& targetObject);
|
||||
};
|
||||
|
||||
} //end namespace TechDrawGui
|
||||
|
||||
@@ -39,10 +39,12 @@
|
||||
#include "QGIPrimPath.h"
|
||||
#include "PreferencesGui.h"
|
||||
#include "QGIView.h"
|
||||
#include "DrawGuiUtil.h"
|
||||
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
using DGU = DrawGuiUtil;
|
||||
|
||||
QGIPrimPath::QGIPrimPath():
|
||||
m_width(0),
|
||||
@@ -251,9 +253,9 @@ void QGIPrimPath::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
auto parent = dynamic_cast<QGIView *>(parentItem());
|
||||
if (parent) {
|
||||
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx();
|
||||
if (selection.size() == 1
|
||||
&& selection.front().getObject() == parent->getViewObject()) {
|
||||
|
||||
if (DGU::findObjectInSelection(selection, *(parent->getViewObject()))) {
|
||||
// if our parent is already in the selection, then allow addition
|
||||
// primitives to be selected.
|
||||
multiselectActivated = true;
|
||||
event->setModifiers(originalModifiers | Qt::ControlModifier);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user