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