Mercurial > octave-nkf
comparison libgui/graphics/Canvas.cc @ 20130:c164cfc24bdd
QtHandles: add annotations dialog
* libgui/graphics/annotation-dialog.h: new file
* libgui/graphics/annotation-dialog.cc: new file
* libgui/graphics/annotation-dialog.ui: new file
* libgui/graphics/Canvas.cc
(canvasMousePressEvent): call annotation_dialog when in TextMode.
* libgui/graphics/module.mk: add annotation-dialog to build
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Sun, 19 Apr 2015 09:54:54 -0400 |
parents | c6c5cb9c4743 |
children | 8eb72c4ed457 |
comparison
equal
deleted
inserted
replaced
20129:0b83a442ff78 | 20130:c164cfc24bdd |
---|---|
36 #include "Backend.h" | 36 #include "Backend.h" |
37 #include "Canvas.h" | 37 #include "Canvas.h" |
38 #include "ContextMenu.h" | 38 #include "ContextMenu.h" |
39 #include "GLCanvas.h" | 39 #include "GLCanvas.h" |
40 #include "QtHandlesUtils.h" | 40 #include "QtHandlesUtils.h" |
41 | |
42 #include "annotation-dialog.h" | |
41 | 43 |
42 #include "gl2ps-renderer.h" | 44 #include "gl2ps-renderer.h" |
43 #include "octave-qt-link.h" | 45 #include "octave-qt-link.h" |
44 | 46 |
45 #include "builtin-defun-decls.h" | 47 #include "builtin-defun-decls.h" |
572 QWidget *w = qWidget (); | 574 QWidget *w = qWidget (); |
573 | 575 |
574 if (! w) | 576 if (! w) |
575 break; | 577 break; |
576 | 578 |
577 bool ok; | |
578 | |
579 // FIXME: this dialog should allow multiple line text entry | |
580 // and also provide options for setting text properties of | |
581 // the text annotation. | |
582 | |
583 QString text = QInputDialog::getText (w, "Annotation", "", | |
584 QLineEdit::Normal, "", &ok); | |
585 | |
586 if (! ok || text.isEmpty ()) | |
587 break; | |
588 | |
589 Matrix bb = axesObj.get_properties ().get_boundingbox (false); | 579 Matrix bb = axesObj.get_properties ().get_boundingbox (false); |
580 Matrix position (1, 4); | |
590 | 581 |
591 QPoint pos = event->pos (); | 582 QPoint pos = event->pos (); |
592 | |
593 Matrix position (1, 4); | |
594 | 583 |
595 position(0) = pos.x () / bb(2); | 584 position(0) = pos.x () / bb(2); |
596 position(1) = 1.0 - (pos.y () / bb(3)); | 585 position(1) = 1.0 - (pos.y () / bb(3)); |
597 position(2) = pos.x () / bb(2); | 586 position(2) = pos.x () / bb(2); |
598 position(3) = 1.0 - (pos.y () / bb(3)); | 587 position(3) = 1.0 - (pos.y () / bb(3)); |
599 | 588 |
600 octave_link::post_event (this, &Canvas::annotation_callback, | 589 octave_value_list props = ovl("textbox", position); |
601 ovl ("textbox", position, | 590 |
602 "string", text.toStdString ())); | 591 annotation_dialog anno_dlg (w, props); |
592 | |
593 if (anno_dlg.exec () == QDialog::Accepted) | |
594 { | |
595 props = anno_dlg.get_properties (); | |
596 | |
597 octave_link::post_event (this, &Canvas::annotation_callback, | |
598 props); | |
599 } | |
603 } | 600 } |
604 break; | 601 break; |
605 | 602 |
606 case PanMode: | 603 case PanMode: |
607 case RotateMode: | 604 case RotateMode: |