GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QtHandlesUtils.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2011-2015 Michael Goffioul
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifndef __QtHandles_Utils__
24 #define __QtHandles_Utils__ 1
25 
26 #include <QColor>
27 #include <QFont>
28 #include <QImage>
29 #include <QString>
30 #include <QStringList>
31 
32 #include <string>
33 
34 #include "graphics.h"
35 
36 class QKeyEvent;
37 class QMouseEvent;
38 
39 namespace QtHandles
40 {
41 
42 namespace Utils
43 {
44  QString fromStdString (const std::string& s);
45  std::string toStdString (const QString& s);
46 
47  QStringList fromStringVector (const string_vector& v);
48  string_vector toStringVector (const QStringList& l);
49 
50  Cell toCellString (const QStringList& l);
51 
52  template <class T>
53  QFont computeFont (const typename T::properties& props, int height = -1);
54 
55  QColor fromRgb (const Matrix& rgb);
56  Matrix toRgb (const QColor& c);
57 
58  Qt::Alignment fromHVAlign (const caseless_str& halign,
59  const caseless_str& valign);
60 
61  std::string figureSelectionType (QMouseEvent* event,
62  bool isDoubleClick = false);
63 
64  Matrix figureCurrentPoint (const graphics_object& fig, QMouseEvent* event);
66 
67  template <class T>
68  inline typename T::properties&
70  { return dynamic_cast<typename T::properties&> (obj.get_properties ()); }
71 
72  template <class T>
73  inline typename T::properties&
75  { return Utils::properties<T> (gh_manager::get_object (h)); }
76 
77  QImage makeImageFromCData (const octave_value& v, int width = -1,
78  int height = -1);
79 
80  octave_scalar_map makeKeyEventStruct (QKeyEvent* event);
81 };
82 
83 }; // namespace QtHandles
84 
85 #endif
Definition: Cell.h:35
T::properties & properties(const graphics_handle &h)
QString fromStdString(const std::string &s)
QStringList fromStringVector(const string_vector &v)
Matrix figureCurrentPoint(const graphics_object &fig, QMouseEvent *event)
QColor fromRgb(const Matrix &rgb)
octave_scalar_map makeKeyEventStruct(QKeyEvent *event)
Matrix toRgb(const QColor &c)
QFont computeFont(const typename T::properties &props, int height)
base_properties & get_properties(void)
Definition: graphics.h:3377
QImage makeImageFromCData(const octave_value &v, int width, int height)
Definition: dMatrix.h:35
Qt::Alignment fromHVAlign(const caseless_str &halign, const caseless_str &valign)
std::string figureSelectionType(QMouseEvent *event, bool isDoubleClick)
Cell toCellString(const QStringList &l)
static graphics_object get_object(double val)
Definition: graphics.h:13212
std::string toStdString(const QString &s)
string_vector toStringVector(const QStringList &l)
T::properties & properties(graphics_object obj)