23 #if defined (HAVE_CONFIG_H)
27 #include <QApplication>
30 #include <QInputDialog>
32 #include <QMouseEvent>
33 #include <QWheelEvent>
80 static QCursor origCursor = w->cursor ();
86 w->setCursor (Qt::OpenHandCursor);
90 w->setCursor (QPixmap (
":/images/zoom-in.png"));
94 w->setCursor (QPixmap (
":/images/zoom-out.png"));
98 w->setCursor (origCursor);
114 gl2ps_print (figObj, file_cmd.toStdString (), term.toStdString ());
135 for (
int i = 0;
i < num_children;
i++)
139 if (childObj.
isa (
"axes"))
152 cp(0,0) = p1(0); cp(0,1) = p1(1); cp(0,2) = p1(2);
153 cp(1,0) = p2(0); cp(1,1) = p2(1); cp(1,2) = p2(2);
173 for (
int i = 0;
i < num_children;
i++)
177 if (childObj.
isa (
"axes"))
182 QPoint
p = w->mapFromGlobal (QCursor::pos ());
192 cp(0,0) = p1(0); cp(0,1) = p1(1); cp(0,2) = p1(2);
193 cp(1,0) = p2(0); cp(1,1) = p2(1); cp(1,2) = p2(2);
331 = Utils::properties<figure> (figObj).get___pan_mode__ ();
343 = Utils::properties<figure> (figObj).get___pan_mode__ ();
355 = Utils::properties<figure> (figObj).get___zoom_mode__ ();
367 = Utils::properties<figure> (figObj).get___zoom_mode__ ();
377 bool axes_only, std::vector<std::string> omit)
383 for (
int i = 0;
i < num_children;
i++)
387 if (childObj.
isa (
"axes"))
389 auto p = omit.begin ();
390 bool omitfound =
false;
391 while (
p != omit.end () && ! omitfound)
397 axesList.append (childObj);
399 else if (childObj.
isa (
"uicontrol") || childObj.
isa (
"uipanel")
400 || childObj.
isa (
"uibuttongroup"))
403 QRectF r (bb(0), bb(1), bb(2), bb(3));
405 r.adjust (-5, -5, 5, 5);
408 bool rect_contains_pos = r.contains (event->posF ());
410 bool rect_contains_pos = r.contains (event->localPos ());
412 if (rect_contains_pos)
414 currentObj = childObj;
422 QPoint pt =
event->pos ();
425 it != axesList.end (); ++it)
434 if (xlim(0) < p0(0) && xlim(1) > p0(0)
435 && ylim(0) < p0(1) && ylim(1) > p0(1))
442 else if (! currentObj)
445 it != axesList.end (); ++it)
456 else if (it->get_properties ().is_hittest ())
458 Matrix bb = it->get_properties ().get_boundingbox (
true);
459 QRectF r (bb(0), bb(1), bb(2), bb(3));
461 #if defined (HAVE_QT4)
462 bool rect_contains_pos = r.contains (event->posF ());
464 bool rect_contains_pos = r.contains (event->localPos ());
466 if (rect_contains_pos)
470 if (axesObj && currentObj)
541 if (figObj.valid_object () &&
542 ! figObj.get (
"windowbuttonmotionfcn").is_empty ())
546 "windowbuttonmotionfcn");
558 std::vector<std::string> omit = {
"legend",
"colorbar",
"scribeoverlay"};
587 switch (event->button ())
597 case Qt::RightButton:
614 bool isdblclick = (
event->type () == QEvent::MouseButtonDblClick);
625 if (axesObj.get_properties ().handlevisibility_is (
"on")
626 && axesObj.get_properties ().get_tag () !=
"legend"
627 && axesObj.get_properties ().get_tag () !=
"colorbar")
628 Utils::properties<figure> (figObj)
629 .set_currentaxes (axesObj.get_handle ().as_octave_value ());
631 currentObj = axesObj;
637 if (currentObj.get_properties ().handlevisibility_is (
"on"))
638 Utils::properties<figure> (figObj)
639 .set_currentobject (currentObj.get_handle ().as_octave_value ());
641 Utils::properties<figure> (figObj).set_currentobject (
649 newMouseMode = fig->mouseMode ();
651 switch (newMouseMode)
660 "windowbuttondownfcn",
663 if (currentObj.get (
"buttondownfcn").is_empty ())
678 if (event->button () == Qt::RightButton)
680 event->globalPos ());
685 if (event->modifiers () == Qt::NoModifier)
687 switch (event->buttons ())
703 if (axesObj && axesObj.get_properties ().handlevisibility_is (
"on"))
705 bool redraw_figure =
true;
709 if (event->button () == Qt::LeftButton)
717 redraw_figure =
false;
720 else if (event->modifiers () == Qt::NoModifier)
722 switch (event->buttons ())
731 case Qt::RightButton:
745 Utils::properties<axes> (axesObj);
752 redraw_figure =
false;
756 else if (event->modifiers () == Qt::ShiftModifier)
758 switch (event->buttons ())
771 redraw_figure =
false;
830 ap.
zoom (zm, xl, yl);
847 "windowbuttonupfcn");
871 if (anno_dlg.exec () == QDialog::Accepted)
902 for (
int i = 0;
i < num_children;
i++)
906 if (childObj.
isa (
"axes"))
931 Utils::properties<figure> (figObj)
936 if (event->delta () > 0)
951 bool redrawFigure =
true;
953 switch (newMouseMode)
965 ? 1 / (1.0 - wheel_zoom_speed)
966 : 1.0 - wheel_zoom_speed);
970 ap.
zoom (mode, factor);
978 double factor =
event->delta () > 0 ? 0.1 : -0.1;
980 ap.
pan (mode, factor);
985 redrawFigure =
false;
1013 eventData.
getfield (
"Character"),
false);
1041 return new GLCanvas (parent, handle);
graphics_handle m_mouseAxes
virtual QWidget * qWidget(void)=0
void rotate3d(double x0, double x1, double y0, double y1, bool push_to_zoom_stack=true)
void set_ylimmode(const octave_value &val)
bool handlevisibility_is(const std::string &v) const
static void post_callback(const graphics_handle &h, const std::string &name, const octave_value &data=Matrix())
bool is_visible(void) const
octave_value get_xlim(void) const
void select_object(graphics_object obj, QMouseEvent *event, graphics_object ¤tObj, graphics_object &axesObj, bool axes_only=false, std::vector< std::string > omit=std::vector< std::string >())
bool isa(const std::string &go_name) const
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_integer_type())
octave_idx_type numel(void) const
Number of elements in the array.
const octave_value & contents(const_iterator p) const
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
void updateCurrentPoint(const graphics_object &fig, const graphics_object &obj, QMouseEvent *event)
void zoom(const std::string &mode, double factor, bool push_to_zoom_stack=true)
void set_visible(const octave_value &val)
virtual Matrix get_boundingbox(bool=false, const Matrix &=Matrix()) const
octave_value get_ylim(void) const
void translate_view(const std::string &mode, double x0, double x1, double y0, double y1, bool push_to_zoom_stack=true)
void print(const QString &file_cmd, const QString &term)
void set_zgrid(const octave_value &val)
Matrix figureCurrentPoint(const graphics_object &fig, QMouseEvent *event)
void redraw(bool sync=false)
void canvasToggleGrid(const graphics_handle &handle)
octave_value get(bool all=false) const
virtual void drawZoomBox(const QPoint &p1, const QPoint &p2)=0
static void autoscale_axes(axes::properties &ap)
void canvasMouseDoubleClickEvent(QMouseEvent *event)
graphics_xform get_transform(void) const
std::string get_zgrid(void) const
void canvasToggleAxes(const graphics_handle &handle)
static void executeAt(const base_properties &props, const QPoint &pt)
void pan(const std::string &mode, double factor, bool push_to_zoom_stack=true)
void canvasMousePressEvent(QMouseEvent *event)
void canvasWheelEvent(QWheelEvent *event)
bool canvasKeyPressEvent(QKeyEvent *event)
Matrix get_children(void) const
void canvasMouseMoveEvent(QMouseEvent *event)
std::string string_value(bool force=false) const
octave_scalar_map makeKeyEventStruct(QKeyEvent *event)
static bool zoom_enabled(const graphics_object figObj)
double get_mousewheelzoom(void) const
void canvasAutoAxes(const graphics_handle &handle)
std::complex< double > w(std::complex< double > z, double relerr=0)
void gl2ps_print(const graphics_object &fig, const std::string &stream, const std::string &term)
std::string get_ygrid(void) const
static void post_event(T *obj, void(T::*method)(void))
base_properties & get_properties(void)
void zoom_about_point(const std::string &mode, double x, double y, double factor, bool push_to_zoom_stack=true)
graphics_object get_ancestor(const std::string &type) const
Matrix matrix_value(bool frc_str_conv=false) const
std::string get_xgrid(void) const
void canvasPaintEvent(void)
static uint32_t state[624]
void set_xgrid(const octave_value &val)
void canvasMouseReleaseEvent(QMouseEvent *event)
bool valid_object(void) const
charNDArray max(char d, const charNDArray &m)
static Object * toolkitObject(const graphics_object &go)
std::string figureSelectionType(QMouseEvent *event, bool isDoubleClick)
bool canvasKeyReleaseEvent(QKeyEvent *event)
ColumnVector pixel2coord(double px, double py) const
virtual void draw(const graphics_handle &handle)=0
octave_scalar_map scalar_map_value(void) const
void setCursor(MouseMode mode)
void set_xlimmode(const octave_value &val)
=val(i)}if ode{val(i)}occurs in table i
void set_zlimmode(const octave_value &val)
octave_handle graphics_handle
static bool pan_enabled(const graphics_object figObj)
Matrix get_all_children(void) const
virtual graphics_object selectFromAxes(const graphics_object &ax, const QPoint &pt)=0
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol NaN(Not a Number).NaN is the result of operations which do not produce a well defined 0 result.Common operations which produce a NaN are arithmetic with infinity ex($\infty-\infty $)
void clear_zoom_stack(bool do_unzoom=true)
static Canvas * create(const std::string &name, QWidget *parent, const graphics_handle &handle)
static graphics_object get_object(double val)
octave_value_list get_properties() const
void annotation_callback(const octave_value_list &args)
static std::string pan_mode(const graphics_object figObj)
octave_value getfield(const std::string &key) const
OCTINTERP_API octave_value_list Ffeval(const octave_value_list &=octave_value_list(), int=0)
graphics_handle get_handle(void) const
void set_ygrid(const octave_value &val)
static double button_number(QMouseEvent *event)
Matrix get_transform_zlim(void) const
octave_value as_octave_value(void) const
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
octave_value_list & prepend(const octave_value &val)
static std::string zoom_mode(const graphics_object figObj)
void blockRedraw(bool block=true)
static void post_set(const graphics_handle &h, const std::string &name, const octave_value &value, bool notify_toolkit=true)
charNDArray min(char d, const charNDArray &m)