23 #if defined (HAVE_CONFIG_H) 28 #include <QActionEvent> 29 #include <QActionGroup> 30 #include <QApplication> 33 #include <QFileDialog> 37 #include <QMainWindow> 40 #include <QMessageBox> 59 #include "builtin-defun-decls.h" 73 for (
int i = 0;
i < kids.
numel ();
i++)
77 if (go && (go.
isa (
"uicontrol") || go.
isa (
"uipanel")
78 || go.
isa (
"uibuttongroup")))
92 for (
int i = 0;
i < kids.
numel ();
i++)
96 if (go && go.
isa (
"uimenu") &&
109 if (bb.
numel () == 4)
127 :
Object (go, win), m_blockUpdates (
false), m_figureToolBar (nullptr),
128 m_menuBar (nullptr), m_innerRect (), m_outerRect (),
129 m_mouseModeGroup (nullptr)
144 if (fp.toolbar_is (
"figure") ||
145 (fp.toolbar_is (
"auto") && fp.menubar_is (
"figure") &&
158 toffset +=
m_menuBar->sizeHint ().height ();
165 win->setGeometry (
m_innerRect.adjusted (0, -toffset, 0, boffset));
174 update (figure::properties::ID_NUMBERTITLE);
178 update (figure::properties::ID_KEYPRESSFCN);
179 update (figure::properties::ID_KEYRELEASEFCN);
182 update (figure::properties::ID_WINDOWSTYLE);
185 update (figure::properties::ID_VISIBLE);
235 else if (
mode ==
"rotate")
237 else if (
mode ==
"zoom in")
239 else if (
mode ==
"zoom out")
241 else if (
mode ==
"pan")
243 else if (
mode ==
"text")
245 else if (
mode ==
"select")
270 fp.set_filename (
name.toStdString ());
288 mode +=
' ' + direction;
309 connect (toggle_axes, SIGNAL (triggered (
void)),
313 connect (toggle_grid, SIGNAL (triggered (
void)),
317 connect (auto_axes, SIGNAL (triggered (
void)),
324 fileMenu->menuAction ()->setObjectName (
"builtinMenu");
325 fileMenu->addAction (tr (
"&Save"),
this, SLOT (
fileSaveFigure (
bool)));
326 fileMenu->addAction (tr (
"Save &As"),
this, SLOT (
fileSaveFigureAs (
void)));
327 fileMenu->addSeparator ();
328 fileMenu->addAction (tr (
"&Close Figure"),
this,
332 editMenu->menuAction ()->setObjectName (
"builtinMenu");
333 editMenu->addAction (tr (
"Cop&y"),
this, SLOT (
editCopy (
bool)),
335 editMenu->addSeparator ();
339 helpMenu->menuAction ()->setObjectName (
"builtinMenu");
340 helpMenu->addAction (tr (
"About Octave"),
this,
374 foreach (QFrame *
frame,
375 qWidget<QWidget> ()->findChildren<QFrame*> ())
377 if (
frame->objectName () ==
"UIPanel" 378 ||
frame->objectName () ==
"UIButtonGroup")
396 canvas->
print (file_cmd, term);
425 qWidget<FigureWindow> ()->removeReceiver (
this);
436 if (fp.is___printing__ ())
449 case figure::properties::ID_POSITION:
455 foreach (QToolBar *tb, win->findChildren<QToolBar*> ())
456 if (! tb->isHidden ())
457 toffset += tb->sizeHint ().height ();
460 toffset +=
m_menuBar->sizeHint ().height ();
465 win->setGeometry (
m_innerRect.adjusted (0, -toffset, 0, boffset));
469 case figure::properties::ID_NAME:
470 case figure::properties::ID_NUMBERTITLE:
474 case figure::properties::ID_VISIBLE:
475 if (fp.is_visible ())
477 QTimer::singleShot (0, win, SLOT (show ()));
478 if (! fp.is___gl_window__ ())
481 fp.
set (
"__gl_window__",
"on");
488 case figure::properties::ID_TOOLBAR:
489 if (fp.toolbar_is (
"none"))
491 else if (fp.toolbar_is (
"figure"))
495 fp.menubar_is (
"figure"));
498 case figure::properties::ID_MENUBAR:
500 if (fp.toolbar_is (
"auto"))
504 case figure::properties::ID_KEYPRESSFCN:
505 if (fp.get_keypressfcn ().isempty ())
511 case figure::properties::ID_KEYRELEASEFCN:
512 if (fp.get_keyreleasefcn ().isempty ())
518 case figure::properties::ID_WINDOWSTYLE:
519 if (fp.windowstyle_is (
"modal"))
521 bool is_visible = win->isVisible ();
526 win->setVisible (
false);
528 win->setWindowModality (Qt::ApplicationModal);
529 win->setVisible (is_visible);
532 win->setWindowModality (Qt::NonModal);
550 QRect r = qWidget<QWidget> ()->geometry ();
553 r.adjust (0, dy1, 0, -dy2);
555 r.adjust (0, -dy1, 0, dy2);
558 qWidget<QWidget> ()->setGeometry (r);
575 if (
a->objectName () ==
"builtinMenu")
576 a->setVisible (visible);
578 int h2 =
m_menuBar->sizeHint ().height ();
584 if ((
m_menuBar->isVisible () && ! visible)
585 || (!
m_menuBar->isVisible () && visible))
587 int dy = qMax (h1, h2);
588 QRect r = qWidget<QWidget> ()->geometry ();
591 r.adjust (0, dy, 0, 0);
593 r.adjust (0, -dy, 0, 0);
596 qWidget<QWidget> ()->setGeometry (r);
610 showMenuBar (Utils::properties<figure> (go).menubar_is (
"figure"),
619 .
arg (pt(0), 0,
'g', 5)
620 .
arg (pt(1), 0,
'g', 5));
626 return qWidget<QMainWindow> ()->menuBar ();
658 QWidget *win = qWidget<QWidget> ();
666 r.moveTopLeft (win->mapToGlobal (
m_container->pos ()));
687 r.moveTopLeft (win->pos ());
689 r.setSize (win->frameGeometry ().size ());
707 d->m_internal =
internal;
718 octave_value fnum = fp.get___myhandle__ ().as_octave_value ();
720 Ffeval (
ovl (
"close", fnum));
729 if (xevent->type () == QEvent::MouseButtonPress)
733 if (fp.get_handlevisibility () ==
"on")
734 root.set (
"currentfigure",
735 fp.get___myhandle__ ().as_octave_value ());
744 switch (xevent->type ())
746 case QEvent::ActionChanged:
749 case QEvent::ActionRemoved:
751 QAction *
a =
dynamic_cast<QActionEvent *
> (xevent)->action ();
753 if (!
a->isSeparator ()
754 &&
a->objectName () !=
"builtinMenu")
765 switch (xevent->type ())
788 switch (xevent->type ())
794 case QEvent::ChildAdded:
795 if (dynamic_cast<QChildEvent *> (xevent)->child
799 update (figure::properties::ID_TOOLBAR);
805 case QEvent::ChildRemoved:
806 if (dynamic_cast<QChildEvent *> (xevent)->child
810 update (figure::properties::ID_TOOLBAR);
820 switch (xevent->type ())
822 case QEvent::ActionChanged:
825 QAction *
a =
dynamic_cast<QActionEvent *
> (xevent)->action ();
827 &&
a->objectName () !=
"builtinMenu" 828 && !
a->isSeparator ())
832 case QEvent::ActionAdded:
834 QAction *
a =
dynamic_cast<QActionEvent *
> (xevent)->action ();
836 if (!
a->isSeparator ()
837 &&
a->objectName () !=
"builtinMenu" 849 switch (xevent->type ())
873 QMessageBox::about (qWidget<QMainWindow> (), tr (
"About Octave"),
904 file =
"untitled.ofig";
907 if (prompt ||
file.isEmpty ())
909 QFileInfo finfo (
file);
911 file = QFileDialog::getSaveFileName (qWidget<FigureWindow> (),
912 tr (
"Save Figure As"),
913 finfo.absoluteFilePath (),
914 tr (
"Octave Figure File (*.ofig);;Vector Image Formats (*.eps *.epsc *.pdf *.svg *.ps *.tikz);;Bitmap Image Formats (*.gif *.jpg *.png *.tiff)"),
916 QFileDialog::DontUseNativeDialog);
919 if (!
file.isEmpty ())
921 QFileInfo finfo (
file);
926 file.toStdString ());
934 octave_value fnum = fp.get___myhandle__ ().as_octave_value ();
936 size_t flen =
file.length ();
938 if (flen > 5 &&
file.substr (flen-5) ==
".ofig")
939 Ffeval (
ovl (
"hgsave", fnum,
file));
941 Ffeval (
ovl (
"print", fnum,
file));
971 qWidget<QMainWindow> ()->close ();
985 QFileInfo finfo (
file);
987 format = QFileDialog::getSaveFileName (qWidget<FigureWindow> (),
988 tr (
"Save Figure As"),
989 finfo.absoluteFilePath (), 0, 0,
990 QFileDialog::DontUseNativeDialog);
1004 win->addToolBar (bar);
1007 QSize
sz = bar->sizeHint ();
1008 QRect r = win->geometry ();
1011 r.adjust (0, -
sz.height (), 0, 0);
1014 win->setGeometry (r);
1015 win->addToolBarBreak ();
1016 win->addToolBar (bar);
1029 if ((! bar->isHidden ()) != visible)
1031 QSize
sz = bar->sizeHint ();
1032 QRect r = win->geometry ();
1035 r.adjust (0, -
sz.height (), 0, 0);
1037 r.adjust (0,
sz.height (), 0, 0);
1040 win->setGeometry (r);
1041 bar->setVisible (visible);
1088 w->setMouseTracking (
true);
virtual QWidget * qWidget(void)=0
For example cd octave end example noindent changes the current working directory to file
static MouseMode mouse_mode_from_string(const std::string &mode)
std::string string_value(bool force=false) const
virtual void set(const caseless_str &, const octave_value &)
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
QList< QAction * > actions(void) const
virtual void autoAxes(const graphics_handle &handle)=0
std::string tempnam(const std::string &dir, const std::string &pfx)
QString fromStdString(const std::string &s)
void setMode(MouseMode mode)
void print(const QString &file_cmd, const QString &term)
static QRect boundingBoxToRect(const Matrix &bb)
void redraw(bool sync=false)
static bool hasUiControlChildren(const figure::properties &fp)
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
bool isa(const std::string &go_name) const
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
void message(const char *name, const char *fmt,...)
bool valid_object(void) const
nd deftypefn *std::string name
virtual uint8NDArray getPixels(void)
octave_value get(bool all=false) const
std::complex< double > w(std::complex< double > z, double relerr=0)
static bool copy_image_to_clipboard(const std::string &file)
static Object * fromQObject(QObject *obj)
static void post_event(T *obj, void(T::*method)(void))
void removeReceiver(GenericEventNotifyReceiver *r)
octave_value getfield(const std::string &key) const
graphics_object object(void) const
Matrix get_all_children(void) const
virtual void toggleAxes(const graphics_handle &handle)=0
virtual void toggleGrid(const graphics_handle &handle)=0
octave::unwind_protect frame
std::string octave_name_version_copyright_copying_warranty_and_bugs(bool html, const std::string &extra_info)
static bool hasUiMenuChildren(const figure::properties &fp)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
void setCursor(MouseMode mode)
static std::string mouse_mode_to_string(MouseMode mode)
static void post_function(graphics_event::event_fcn fcn, void *data=nullptr)
void addReceiver(GenericEventNotifyReceiver *r)
static graphics_object get_object(double val)
Canvas * canvas(const graphics_handle &handle, bool create=true)
#define DECLARE_GENERICEVENTNOTIFY_SENDER(T, B)
octave_idx_type numel(void) const
Number of elements in the array.
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
void blockRedraw(bool block=true)
void clearEventMask(int m)
static int process_events(void)