5 #include <QGraphicsView> 10 #include <QAbstractGraphicsShapeItem> 11 #include <QGestureEvent> 14 namespace frechet {
namespace view {
17 class GraphicsHoverLineItem;
34 bool event(QEvent*)
override;
51 void singleStep(QAbstractSlider*,
double factor);
56 void pageStep(QAbstractSlider*,
double factor);
89 BaseView(QWidget *parent = 0, QString title=
"",
bool showRotate=
true);
92 QGraphicsView *
view()
const;
102 void zoomIn(
int level = -1);
112 virtual void saveSettings(QSettings& settings, QString group);
208 virtual void render(QPainter* painter, QRectF target=QRectF());
216 static void setPenWidth(QGraphicsItem* item,
double width);
220 static void addLine(QPainterPath& ppath,
const QLineF& line);
224 static void addPolygon(QPainterPath& ppath,
const QPolygonF& poly);
229 static void addPoint(QPainterPath& ppath,
const QPointF& point,
double diameter=1.0);
269 QGraphicsItemGroup* group);
void singleStep(QAbstractSlider *, double factor)
perform a single step on a slider
base class for view widgets.
GraphicsView(BaseView *view)
default constructor
void saveAs()
save the contents of the graphics scene to disk (as PDF, or SVG)
void zoomIn(int level=-1)
zoom in; connected to the zomm controls
used for segments that are not mouse sensitive
void saveAsPdf(QString file)
save content of scene to a PDF file
void resetView()
reset zoom to default
void mouseMoveEvent(QMouseEvent *event)
bool event(QEvent *) override
static int distance(int a, int b, int n)
BaseView(QWidget *parent=0, QString title="", bool showRotate=true)
constructore with parent and title
int rot0
initial rotation angle
void keyPressEvent(QKeyEvent *) override
bool gestureEvent(QGestureEvent *)
QGraphicsView * view() const
int zoomStepMouse
zoom step for mouse wheel
global definitions for all algorithms.
void zoomOut(int level=-1)
connected to the zomm controls
bool is_close_to(QPointF scene_pos, int distance) const
check if the mouse is close to the line segment
double normalizedValue(QAbstractSlider *slider)
void wheelEvent(QWheelEvent *) override
void pageStep(QAbstractSlider *, double factor)
perform a page step on a slider
QSlider * rotateSlider
the slider control for rotate
a segment of the feasible paht (displayed in the free-space diagram)
void rotateLeft(double angle=10)
rotate the scene to the left
a QGraphicsView with additional support for mouse and gesture events. re-implements a couple of event...
static void addPolygon(QPainterPath &ppath, const QPolygonF &poly)
add a polygon curve segment to a QPainterPath
bool isFlipped
true if the scene should be flipped vertically
void setupMatrix()
set up transformation matrix to account for zoom,rotate,scroll
const Location loc
location on screen
static const int ROTATE_DEFAULT_VALUE
what this?
QPoint mapSceneToGlobal(QPointF p) const
map scene coordinates to window coordinate
void setNormalizedValue(QAbstractSlider *slider, double nval)
update slider with a normalized value
QGraphicsScene * scene
scene that is displayed by graphicsView
static const QPen PEN_SELECT
pen for drawing selected polygon segment
GraphicsHoverLineItem * selected_item
the currently selected mouse sensitve polyon segment (or nullptr)
a QGraphicsLitem that can handle mouse hover events. It is used to highlight mouse sensitve polygon s...
void update(int a, int b)
update identifiers
void resizeEvent(QResizeEvent *) override
handles window resizes; adjusts controls to new window size
void flipVertical(bool flip)
flip graphics scene vertically
static void addPoint(QPainterPath &ppath, const QPointF &point, double diameter=1.0)
add a dot to a QPainterPath
void mouseMoveEvent(QMouseEvent *event)
handles a mouse move event and detects mouse sensitve polygon segments
void setRotation(double angle)
update rotation angle
const int a
parameters loc,a, and b identify a segment.
virtual void segmentSelected(GraphicsHoverLineItem *item)
called when the mouse hovers over a polygon segment; implemented by derived classes.
void rotateRight(double angle=10)
rotate the scene to the right
virtual void restoreSettings(QSettings &settings, QString group)
load view settings to application prefs
BaseView * view
parent widget
QGraphicsView * graphicsView
the embedded QGraphicsView
void print()
print the contents of the graphics scene
QToolButton * resetButton
the reset button
void mousePressEvent(QMouseEvent *event) override
void saveAsSvg(QString file)
save content of scene to an SVG file
virtual void saveSettings(QSettings &settings, QString group)
store view settings to application prefs
virtual void render(QPainter *painter, QRectF target=QRectF())
render the scene into a QPainter used for printing and saving to disk
void setResetButtonEnabled()
enabled reset button
QSlider * zoomSlider
the slider control for zoom
GraphicsHoverLineItem(QLineF line, Location loc, int a, int b, QGraphicsItemGroup *group)
default constructor
virtual void dropUnusedItems()
clean up graphics scene items after free-space is modified implemented by FreeSpaceView.
Location
location of the polygon segment
int zoomStepDefault
default zoom step
static void setPenWidth(QGraphicsItem *item, double width)
update the pen width of a graphics item
static const QStringList OUTPUT_FILTERS
file name filters for save dialog
static void addLine(QPainterPath &ppath, const QLineF &line)
add a line segment to a QPainterPath