Skip to content

Commit

Permalink
[TD]allow multiple primitives in complex selections
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed May 26, 2024
1 parent f41c634 commit 5b17a73
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
13 changes: 13 additions & 0 deletions src/Mod/TechDraw/Gui/DrawGuiUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

9 changes: 5 additions & 4 deletions src/Mod/TechDraw/Gui/DrawGuiUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,16 @@
#include <QCoreApplication>
#include <QGraphicsItem>

#include <App/DocumentObject.h>
#include <Base/Vector3D.h>
#include <Gui/Selection.h>
#include <Mod/TechDraw/TechDrawGlobal.h>


class QComboBox;
class QPointF;
class QRectF;

namespace App {
class DocumentObject;
}

namespace Part {
class Feature;
}
Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/Mod/TechDraw/Gui/QGIPrimPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 5b17a73

Please sign in to comment.