gui: ctrl click to select multiple elements
This commit is contained in:
parent
83371248fc
commit
1fe1b99a5a
@ -80,10 +80,10 @@ BaseMainWindow::BaseMainWindow(std::unique_ptr<Context> context, QWidget *parent
|
||||
centralTabWidget->tabBar()->tabButton(0, QTabBar::RightSide)->resize(0, 0);
|
||||
|
||||
connect(this, SIGNAL(contextChanged(Context *)), fpgaView, SLOT(newContext(Context *)));
|
||||
connect(designview, SIGNAL(selected(std::vector<DecalXY>)), fpgaView,
|
||||
SLOT(onSelectedArchItem(std::vector<DecalXY>)));
|
||||
connect(fpgaView, SIGNAL(clickedBel(BelId)), designview, SLOT(onClickedBel(BelId)));
|
||||
connect(fpgaView, SIGNAL(clickedWire(WireId)), designview, SLOT(onClickedWire(WireId)));
|
||||
connect(designview, SIGNAL(selected(std::vector<DecalXY>, bool)), fpgaView,
|
||||
SLOT(onSelectedArchItem(std::vector<DecalXY>, bool)));
|
||||
connect(fpgaView, SIGNAL(clickedBel(BelId, bool)), designview, SLOT(onClickedBel(BelId, bool)));
|
||||
connect(fpgaView, SIGNAL(clickedWire(WireId, bool)), designview, SLOT(onClickedWire(WireId, bool)));
|
||||
|
||||
connect(designview, SIGNAL(highlight(std::vector<DecalXY>, int)), fpgaView,
|
||||
SLOT(onHighlightGroupChanged(std::vector<DecalXY>, int)));
|
||||
|
@ -507,18 +507,18 @@ QtProperty *DesignWidget::addSubGroup(QtProperty *topItem, const QString &name)
|
||||
return item;
|
||||
}
|
||||
|
||||
void DesignWidget::onClickedBel(BelId bel)
|
||||
void DesignWidget::onClickedBel(BelId bel, bool keep)
|
||||
{
|
||||
QTreeWidgetItem *item = nameToItem[getElementIndex(ElementType::BEL)].value(ctx->getBelName(bel).c_str(ctx));
|
||||
treeWidget->setCurrentItem(item);
|
||||
Q_EMIT selected(getDecals(ElementType::BEL, ctx->getBelName(bel)));
|
||||
Q_EMIT selected(getDecals(ElementType::BEL, ctx->getBelName(bel)), keep);
|
||||
}
|
||||
|
||||
void DesignWidget::onClickedWire(WireId wire)
|
||||
void DesignWidget::onClickedWire(WireId wire, bool keep)
|
||||
{
|
||||
QTreeWidgetItem *item = nameToItem[getElementIndex(ElementType::WIRE)].value(ctx->getWireName(wire).c_str(ctx));
|
||||
treeWidget->setCurrentItem(item);
|
||||
Q_EMIT selected(getDecals(ElementType::WIRE, ctx->getWireName(wire)));
|
||||
Q_EMIT selected(getDecals(ElementType::WIRE, ctx->getWireName(wire)), keep);
|
||||
}
|
||||
|
||||
void DesignWidget::onItemSelectionChanged()
|
||||
@ -534,7 +534,7 @@ void DesignWidget::onItemSelectionChanged()
|
||||
std::vector<DecalXY> d = getDecals(type, value);
|
||||
std::move(d.begin(), d.end(), std::back_inserter(decals));
|
||||
}
|
||||
Q_EMIT selected(decals);
|
||||
Q_EMIT selected(decals, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -555,7 +555,7 @@ void DesignWidget::onItemSelectionChanged()
|
||||
clearProperties();
|
||||
|
||||
IdString c = static_cast<IdStringTreeItem *>(clickItem)->getData();
|
||||
Q_EMIT selected(getDecals(type, c));
|
||||
Q_EMIT selected(getDecals(type, c), false);
|
||||
|
||||
if (type == ElementType::BEL) {
|
||||
BelId bel = ctx->getBelByName(c);
|
||||
@ -847,7 +847,7 @@ void DesignWidget::prepareMenuProperty(const QPoint &pos)
|
||||
std::vector<DecalXY> d = getDecals(type, value);
|
||||
std::move(d.begin(), d.end(), std::back_inserter(decals));
|
||||
}
|
||||
Q_EMIT selected(decals);
|
||||
Q_EMIT selected(decals, false);
|
||||
});
|
||||
menu.addAction(selectAction);
|
||||
|
||||
|
@ -64,7 +64,7 @@ class DesignWidget : public QWidget
|
||||
void updateHighlightGroup(QList<QTreeWidgetItem *> item, int group);
|
||||
Q_SIGNALS:
|
||||
void info(std::string text);
|
||||
void selected(std::vector<DecalXY> decal);
|
||||
void selected(std::vector<DecalXY> decal, bool keep);
|
||||
void highlight(std::vector<DecalXY> decal, int group);
|
||||
|
||||
private Q_SLOTS:
|
||||
@ -75,8 +75,8 @@ class DesignWidget : public QWidget
|
||||
public Q_SLOTS:
|
||||
void newContext(Context *ctx);
|
||||
void updateTree();
|
||||
void onClickedBel(BelId bel);
|
||||
void onClickedWire(WireId wire);
|
||||
void onClickedBel(BelId bel, bool keep);
|
||||
void onClickedWire(WireId wire, bool keep);
|
||||
|
||||
private:
|
||||
Context *ctx;
|
||||
|
@ -83,7 +83,7 @@ FPGAViewWidget::~FPGAViewWidget() {}
|
||||
void FPGAViewWidget::newContext(Context *ctx)
|
||||
{
|
||||
ctx_ = ctx;
|
||||
onSelectedArchItem(std::vector<DecalXY>());
|
||||
onSelectedArchItem(std::vector<DecalXY>(), false);
|
||||
for (int i = 0; i < 8; i++)
|
||||
onHighlightGroupChanged(std::vector<DecalXY>(), i);
|
||||
{
|
||||
@ -508,11 +508,15 @@ void FPGAViewWidget::renderLines(void)
|
||||
}
|
||||
}
|
||||
|
||||
void FPGAViewWidget::onSelectedArchItem(std::vector<DecalXY> decals)
|
||||
void FPGAViewWidget::onSelectedArchItem(std::vector<DecalXY> decals, bool keep)
|
||||
{
|
||||
{
|
||||
QMutexLocker locker(&rendererArgsLock_);
|
||||
rendererArgs_->selectedDecals = decals;
|
||||
if (keep) {
|
||||
std::copy(decals.begin(), decals.end(), std::back_inserter(rendererArgs_->selectedDecals));
|
||||
} else {
|
||||
rendererArgs_->selectedDecals = decals;
|
||||
}
|
||||
rendererArgs_->changed = true;
|
||||
}
|
||||
pokeRenderer();
|
||||
@ -576,6 +580,8 @@ void FPGAViewWidget::mousePressEvent(QMouseEvent *event)
|
||||
lastDragPos_ = event->pos();
|
||||
}
|
||||
if (event->buttons() & Qt::LeftButton) {
|
||||
bool ctrl = QApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
|
||||
|
||||
auto world = mouseToWorldCoordinates(event->x(), event->y());
|
||||
auto closestOr = pickElement(world.x(), world.y());
|
||||
if (!closestOr)
|
||||
@ -583,9 +589,9 @@ void FPGAViewWidget::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
auto closest = closestOr.value();
|
||||
if (closest.type == ElementType::BEL) {
|
||||
clickedBel(closest.element.bel);
|
||||
clickedBel(closest.element.bel, ctrl);
|
||||
} else if (closest.type == ElementType::WIRE) {
|
||||
clickedWire(closest.element.wire);
|
||||
clickedWire(closest.element.wire, ctrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
||||
|
||||
public Q_SLOTS:
|
||||
void newContext(Context *ctx);
|
||||
void onSelectedArchItem(std::vector<DecalXY> decals);
|
||||
void onSelectedArchItem(std::vector<DecalXY> decals, bool keep);
|
||||
void onHighlightGroupChanged(std::vector<DecalXY> decals, int group);
|
||||
void pokeRenderer(void);
|
||||
void zoomIn();
|
||||
@ -119,8 +119,8 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
||||
void zoomOutbound();
|
||||
|
||||
Q_SIGNALS:
|
||||
void clickedBel(BelId bel);
|
||||
void clickedWire(WireId wire);
|
||||
void clickedBel(BelId bel, bool add);
|
||||
void clickedWire(WireId wire, bool add);
|
||||
|
||||
private:
|
||||
const float zoomNear_ = 0.1f; // do not zoom closer than this
|
||||
|
Loading…
Reference in New Issue
Block a user