23 #if defined (HAVE_CONFIG_H) 27 #include <QApplication> 30 #include <QInputDialog> 32 #include <QMouseEvent> 33 #include <QWheelEvent> 47 #include "builtin-defun-decls.h" 79 static QCursor origCursor =
w->cursor ();
85 w->setCursor (Qt::OpenHandCursor);
89 w->setCursor (QPixmap (
":/images/zoom-in.png"));
93 w->setCursor (QPixmap (
":/images/zoom-out.png"));
97 w->setCursor (origCursor);
120 for (
int i = 0;
i < num_children;
i++)
124 if (childObj.
isa (
"axes"))
137 cp(0,0) = p1(0); cp(0,1) = p1(1); cp(0,2) = p1(2);
138 cp(1,0) = p2(0); cp(1,1) = p2(1); cp(1,2) = p2(2);
158 for (
int i = 0;
i < num_children;
i++)
162 if (childObj.
isa (
"axes"))
167 QPoint
p =
w->mapFromGlobal (QCursor::pos ());
177 cp(0,0) = p1(0); cp(0,1) = p1(1); cp(0,2) = p1(2);
178 cp(1,0) = p2(0); cp(1,1) = p2(1); cp(1,2) = p2(2);
189 Ffeval (
ovl (
"annotation").
append (args));
213 if (ap.handlevisibility_is (
"on"))
215 ap.set_visible (! ap.is_visible ());
248 || ap.get_ygrid () ==
"off" 249 || ap.get_zgrid () ==
"off")
252 ap.set_xgrid (
state);
253 ap.set_ygrid (
state);
254 ap.set_zgrid (
state);
266 ap.set_xlimmode (
"auto");
267 ap.set_ylimmode (
"auto");
268 ap.set_zlimmode (
"auto");
316 = Utils::properties<figure> (figObj).get___pan_mode__ ();
328 = Utils::properties<figure> (figObj).get___pan_mode__ ();
340 = Utils::properties<figure> (figObj).get___zoom_mode__ ();
352 = Utils::properties<figure> (figObj).get___zoom_mode__ ();
362 bool axes_only, std::vector<std::string> omit)
368 for (
int i = 0;
i < num_children;
i++)
372 if (childObj.
isa (
"axes"))
374 auto p = omit.begin ();
375 bool omitfound =
false;
376 while (
p != omit.end () && ! omitfound)
382 axesList.append (childObj);
384 else if (childObj.
isa (
"uicontrol") || childObj.
isa (
"uipanel")
385 || childObj.
isa (
"uibuttongroup"))
388 QRectF r (bb(0), bb(1), bb(2), bb(3));
390 r.adjust (-5, -5, 5, 5);
392 #if defined (HAVE_QMOUSEEVENT_LOCALPOS) 393 bool rect_contains_pos = r.contains (event->localPos ());
395 bool rect_contains_pos = r.contains (event->posF ());
397 if (rect_contains_pos)
399 currentObj = childObj;
407 QPoint pt =
event->pos ();
410 it != axesList.end (); ++it)
419 if (xlim(0) < p0(0) && xlim(1) > p0(0)
420 && ylim(0) < p0(1) && ylim(1) > p0(1))
427 else if (! currentObj)
430 it != axesList.end (); ++it)
441 else if (it->get_properties ().is_hittest ())
443 Matrix bb = it->get_properties ().get_boundingbox (
true);
444 QRectF r (bb(0), bb(1), bb(2), bb(3));
446 #if defined (HAVE_QMOUSEEVENT_LOCALPOS) 447 bool rect_contains_pos = r.contains (event->localPos ());
449 bool rect_contains_pos = r.contains (event->posF ());
451 if (rect_contains_pos)
455 if (axesObj && currentObj)
526 if (figObj.valid_object () &&
527 ! figObj.get (
"windowbuttonmotionfcn").isempty ())
531 "windowbuttonmotionfcn");
543 std::vector<std::string> omit = {
"legend",
"colorbar",
"scribeoverlay"};
572 switch (event->button ())
582 case Qt::RightButton:
599 bool isdblclick = (
event->type () == QEvent::MouseButtonDblClick);
609 Utils::properties<root_figure> (root)
610 .set_currentfigure (figObj.get_handle ().as_octave_value ());
644 Utils::properties<figure> (figObj)
655 switch (newMouseMode)
660 auto& fprop = Utils::properties<figure> (figObj);
664 fprop.set_currentobject (currentObj.
get_handle ()
667 fprop.set_currentobject (
Matrix ());
671 figObj.get_handle (),
"selectiontype",
677 "windowbuttondownfcn",
682 if (currentObj && ! currentObj.
get (
"buttondownfcn").
isempty ())
686 else if (figObj && ! figObj.get (
"buttondownfcn").isempty ())
692 if (currentObj && event->button () == Qt::RightButton)
694 event->globalPos ());
700 if (event->modifiers () == Qt::NoModifier)
702 switch (event->buttons ())
718 if (axesObj && axesObj.
get_properties ().handlevisibility_is (
"on"))
720 bool redraw_figure =
true;
724 if (event->button () == Qt::LeftButton)
732 redraw_figure =
false;
735 else if (event->modifiers () == Qt::NoModifier)
737 switch (event->buttons ())
746 case Qt::RightButton:
760 Utils::properties<axes> (axesObj);
767 redraw_figure =
false;
771 else if (event->modifiers () == Qt::ShiftModifier)
773 switch (event->buttons ())
786 redraw_figure =
false;
845 ap.
zoom (zm, xl, yl);
862 "windowbuttonupfcn");
886 if (anno_dlg.exec () == QDialog::Accepted)
917 for (
int i = 0;
i < num_children;
i++)
921 if (childObj.
isa (
"axes"))
946 Utils::properties<figure> (figObj)
951 if (event->delta () > 0)
966 bool redrawFigure =
true;
968 switch (newMouseMode)
976 double wheel_zoom_speed = ap.get_mousewheelzoom ();
980 ? 1 / (1.0 - wheel_zoom_speed)
981 : 1.0 - wheel_zoom_speed);
993 double factor = (
event->delta () > 0 ? 0.1 : -0.1);
995 if (event->modifiers () == Qt::NoModifier
996 &&
mode !=
"horizontal")
997 ap.
pan (
"vertical", factor);
998 else if (event->modifiers () == Qt::ShiftModifier
999 &&
mode !=
"vertical")
1000 ap.
pan (
"horizontal", factor);
1005 redrawFigure =
false;
1033 eventData.
getfield (
"Character"),
false);
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)
static void post_callback(const graphics_handle &h, const std::string &name, const octave_value &data=Matrix())
octave_value_list get_properties() const
std::string string_value(bool force=false) 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 >())
graphics_handle get_handle(void) 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 translate_view(const std::string &mode, double x0, double x1, double y0, double y1, bool push_to_zoom_stack=true)
graphics_xform get_transform(void) const
virtual Matrix get_boundingbox(bool=false, const Matrix &=Matrix()) const
Matrix figureCurrentPoint(const graphics_object &fig, QMouseEvent *event)
void redraw(bool sync=false)
Matrix get_children(void) const
void canvasToggleGrid(const graphics_handle &handle)
ColumnVector pixel2coord(double px, double py) const
virtual void drawZoomBox(const QPoint &p1, const QPoint &p2)=0
static void autoscale_axes(axes::properties &ap)
void canvasMouseDoubleClickEvent(QMouseEvent *event)
bool isa(const std::string &go_name) 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)
bool valid_object(void) const
void canvasMousePressEvent(QMouseEvent *event)
void canvasWheelEvent(QWheelEvent *event)
bool canvasKeyPressEvent(QKeyEvent *event)
void canvasMouseMoveEvent(QMouseEvent *event)
virtual octave_value get_xlim(void) const
octave_scalar_map makeKeyEventStruct(QKeyEvent *event)
octave_value get(bool all=false) const
static bool zoom_enabled(const graphics_object figObj)
void canvasAutoAxes(const graphics_handle &handle)
std::complex< double > w(std::complex< double > z, double relerr=0)
octave_value as_octave_value(void) const
virtual octave_value get_ylim(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)
octave_value getfield(const std::string &key) const
octave_handle graphics_handle
Matrix get_transform_zlim(void) const
graphics_handle get_parent(void) const
void canvasPaintEvent(void)
Matrix get_all_children(void) const
static uint32_t state[624]
void canvasMouseReleaseEvent(QMouseEvent *event)
charNDArray max(char d, const charNDArray &m)
octave_scalar_map scalar_map_value(void) const
static Object * toolkitObject(const graphics_object &go)
const octave_value & contents(const_iterator p) const
std::string figureSelectionType(QMouseEvent *event, bool isDoubleClick)
bool canvasKeyReleaseEvent(QKeyEvent *event)
virtual void draw(const graphics_handle &handle)=0
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
void setCursor(MouseMode mode)
static bool pan_enabled(const graphics_object figObj)
virtual graphics_object selectFromAxes(const graphics_object &ax, const QPoint &pt)=0
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)
void annotation_callback(const octave_value_list &args)
static std::string pan_mode(const graphics_object figObj)
octave_idx_type numel(void) const
Number of elements in the array.
graphics_object get_ancestor(const std::string &type) const
static double button_number(QMouseEvent *event)
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)
Matrix matrix_value(bool frc_str_conv=false) const
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)