mirror of https://github.com/CGAL/cgal
Merge pull request #4761 from maxGimeno/GraphicsView-Fixes_for_Regular_triangulation_2-maxGimeno
GraphicsView: Regular_triangulation_2 enhancements
This commit is contained in:
commit
9a9acceb10
|
|
@ -94,6 +94,7 @@ MainWindow::MainWindow()
|
|||
dgi, SLOT(modelChanged()));
|
||||
|
||||
dgi->setVerticesPen(QPen(Qt::red, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
dgi->setEdgesPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
scene.addItem(dgi);
|
||||
|
||||
// Add a GraphicItem for the Powerdiagram diagram
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ protected:
|
|||
Converter<K> convert;
|
||||
QGraphicsScene *scene_;
|
||||
Point p;
|
||||
bool do_insert;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -44,7 +45,7 @@ template <typename T>
|
|||
TriangulationPointInputAndConflictZone<T>::TriangulationPointInputAndConflictZone(QGraphicsScene* s,
|
||||
T * dt_,
|
||||
QObject* parent)
|
||||
: GraphicsViewInput(parent), dt(dt_), scene_(s)
|
||||
: GraphicsViewInput(parent), dt(dt_), scene_(s), do_insert(true)
|
||||
{}
|
||||
|
||||
|
||||
|
|
@ -54,6 +55,12 @@ template <typename T>
|
|||
void
|
||||
TriangulationPointInputAndConflictZone<T>::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if(event->modifiers() & ::Qt::ShiftModifier){
|
||||
do_insert = false;
|
||||
return;
|
||||
}
|
||||
else
|
||||
do_insert = true;
|
||||
p = convert(event->scenePos());
|
||||
if(dt->dimension() < 2 ||
|
||||
event->modifiers() != 0 ||
|
||||
|
|
@ -91,6 +98,7 @@ TriangulationPointInputAndConflictZone<T>::mouseReleaseEvent(QGraphicsSceneMouse
|
|||
delete *it;
|
||||
}
|
||||
qfaces.clear();
|
||||
if(do_insert)
|
||||
Q_EMIT( generate(CGAL::make_object(p)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include <QStyleOption>
|
||||
#include <QKeyEvent>
|
||||
|
||||
|
||||
#include <CGAL/Qt/Converter.h>
|
||||
#include <CGAL/Qt/GraphicsViewInput.h>
|
||||
|
||||
|
|
@ -71,6 +72,7 @@ GraphicsViewCircleInput<K>::GraphicsViewCircleInput(QObject *parent, QGraphicsSc
|
|||
: GraphicsViewInput(parent), m_pointsOnCircle(pointsOnCircle),
|
||||
count(0), qcircle(new QGraphicsEllipseItem()), scene_(s)
|
||||
{
|
||||
qcircle->setPen(QPen(::Qt::red, 0, ::Qt::SolidLine, ::Qt::RoundCap, ::Qt::RoundJoin));
|
||||
qcircle->hide();
|
||||
s->addItem(qcircle);
|
||||
}
|
||||
|
|
@ -194,6 +196,13 @@ GraphicsViewCircleInput<K>::eventFilter(QObject *obj, QEvent *event)
|
|||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
keyPressEvent(keyEvent);
|
||||
return true;
|
||||
} else if(event->type() == QEvent::GraphicsSceneMouseDoubleClick) {
|
||||
QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
|
||||
qp = mouseEvent->scenePos();
|
||||
p = convert(qp);
|
||||
Q_EMIT generate(CGAL::make_object(std::make_pair(p, 0.0)));
|
||||
count = 0;
|
||||
return true;
|
||||
} else{
|
||||
// standard event processing
|
||||
return QObject::eventFilter(obj, event);
|
||||
|
|
|
|||
Loading…
Reference in New Issue