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, SLOT(modelChanged()));
|
||||||
|
|
||||||
dgi->setVerticesPen(QPen(Qt::red, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
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);
|
scene.addItem(dgi);
|
||||||
|
|
||||||
// Add a GraphicItem for the Powerdiagram diagram
|
// Add a GraphicItem for the Powerdiagram diagram
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ protected:
|
||||||
Converter<K> convert;
|
Converter<K> convert;
|
||||||
QGraphicsScene *scene_;
|
QGraphicsScene *scene_;
|
||||||
Point p;
|
Point p;
|
||||||
|
bool do_insert;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -44,7 +45,7 @@ template <typename T>
|
||||||
TriangulationPointInputAndConflictZone<T>::TriangulationPointInputAndConflictZone(QGraphicsScene* s,
|
TriangulationPointInputAndConflictZone<T>::TriangulationPointInputAndConflictZone(QGraphicsScene* s,
|
||||||
T * dt_,
|
T * dt_,
|
||||||
QObject* parent)
|
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
|
void
|
||||||
TriangulationPointInputAndConflictZone<T>::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
TriangulationPointInputAndConflictZone<T>::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
if(event->modifiers() & ::Qt::ShiftModifier){
|
||||||
|
do_insert = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
do_insert = true;
|
||||||
p = convert(event->scenePos());
|
p = convert(event->scenePos());
|
||||||
if(dt->dimension() < 2 ||
|
if(dt->dimension() < 2 ||
|
||||||
event->modifiers() != 0 ||
|
event->modifiers() != 0 ||
|
||||||
|
|
@ -91,7 +98,8 @@ TriangulationPointInputAndConflictZone<T>::mouseReleaseEvent(QGraphicsSceneMouse
|
||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
qfaces.clear();
|
qfaces.clear();
|
||||||
Q_EMIT( generate(CGAL::make_object(p)));
|
if(do_insert)
|
||||||
|
Q_EMIT( generate(CGAL::make_object(p)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
#include <QStyleOption>
|
#include <QStyleOption>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
||||||
|
|
||||||
#include <CGAL/Qt/Converter.h>
|
#include <CGAL/Qt/Converter.h>
|
||||||
#include <CGAL/Qt/GraphicsViewInput.h>
|
#include <CGAL/Qt/GraphicsViewInput.h>
|
||||||
|
|
||||||
|
|
@ -71,6 +72,7 @@ GraphicsViewCircleInput<K>::GraphicsViewCircleInput(QObject *parent, QGraphicsSc
|
||||||
: GraphicsViewInput(parent), m_pointsOnCircle(pointsOnCircle),
|
: GraphicsViewInput(parent), m_pointsOnCircle(pointsOnCircle),
|
||||||
count(0), qcircle(new QGraphicsEllipseItem()), scene_(s)
|
count(0), qcircle(new QGraphicsEllipseItem()), scene_(s)
|
||||||
{
|
{
|
||||||
|
qcircle->setPen(QPen(::Qt::red, 0, ::Qt::SolidLine, ::Qt::RoundCap, ::Qt::RoundJoin));
|
||||||
qcircle->hide();
|
qcircle->hide();
|
||||||
s->addItem(qcircle);
|
s->addItem(qcircle);
|
||||||
}
|
}
|
||||||
|
|
@ -194,6 +196,13 @@ GraphicsViewCircleInput<K>::eventFilter(QObject *obj, QEvent *event)
|
||||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
keyPressEvent(keyEvent);
|
keyPressEvent(keyEvent);
|
||||||
return true;
|
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{
|
} else{
|
||||||
// standard event processing
|
// standard event processing
|
||||||
return QObject::eventFilter(obj, event);
|
return QObject::eventFilter(obj, event);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue