26 #if defined (HAVE_CONFIG_H)
32 #include <QApplication>
34 #include <QMouseEvent>
56 return QString::fromUtf8 (s.c_str ());
62 return std::string (s.toUtf8 ().data ());
83 for (
const auto& s : l)
94 while ((tmp.length () > 0) && tmp.last ().isEmpty ())
106 template <
typename T>
112 static std::map<std::string, QFont::Weight> weightMap;
113 static std::map<std::string, QFont::Style> angleMap;
114 static bool mapsInitialized =
false;
116 if (! mapsInitialized)
118 weightMap[
"normal"] = QFont::Normal;
119 weightMap[
"bold"] = QFont::Bold;
121 angleMap[
"normal"] = QFont::StyleNormal;
122 angleMap[
"italic"] = QFont::StyleItalic;
123 angleMap[
"oblique"] = QFont::StyleOblique;
125 mapsInitialized =
true;
128 f.setPointSizeF (props.get___fontsize_points__ (height));
129 f.setWeight (weightMap[props.get_fontweight ()]);
130 f.setStyle (angleMap[props.get_fontangle ()]);
153 if (rgb.
numel () == 3)
154 c.setRgbF (rgb(0), rgb(1), rgb(2));
168 c.getRgbF (tmp, tmp+1, tmp+2);
169 rgbData[0] = tmp[0]; rgbData[1] = tmp[1]; rgbData[2] = tmp[2];
181 Qt::MouseButtons buttons = event->buttons ();
182 Qt::KeyboardModifiers mods = event->modifiers ();
184 if (mods == Qt::NoModifier)
186 if (buttons == Qt::LeftButton)
188 else if (buttons == Qt::RightButton)
190 else if (buttons == Qt::MidButton
191 || buttons == (Qt::LeftButton | Qt::RightButton))
194 else if (buttons == Qt::LeftButton)
196 if (mods == Qt::ShiftModifier)
198 else if (mods == Qt::ControlModifier)
222 QPoint
qp = c->mapFromGlobal (event->globalPos ());
229 return Matrix (1, 2, 0.0);
245 QPoint
qp = c->mapFromGlobal (QCursor::pos ());
252 return Matrix (1, 2, 0.0);
256 fromHVAlign (
const std::string& halign,
const std::string& valign)
261 flags |= Qt::AlignLeft;
263 flags |= Qt::AlignHCenter;
265 flags |= Qt::AlignRight;
267 flags |= Qt::AlignLeft;
270 flags |= Qt::AlignVCenter;
272 flags |= Qt::AlignTop;
274 flags |= Qt::AlignBottom;
276 flags |= Qt::AlignVCenter;
286 if (dv.
ndims () == 3 && dv(2) == 3)
291 int x_off = (
w < width ? (width -
w) / 2 : 0);
292 int y_off = (h < height ? (height - h) / 2 : 0);
294 QImage img (width, height, QImage::Format_ARGB32);
295 img.fill (qRgba (0, 0, 0, 0));
301 for (
int i = 0; i <
w; i++)
302 for (
int j = 0; j < h; j++)
309 img.setPixel (x_off + i, y_off + j, qRgba (
r, g, b, a));
316 for (
int i = 0; i <
w; i++)
317 for (
int j = 0; j < h; j++)
319 float r =
f(j, i, 0);
320 float g =
f(j, i, 1);
321 float b =
f(j, i, 2);
325 img.setPixel (x_off + i, y_off + j,
336 for (
int i = 0; i <
w; i++)
337 for (
int j = 0; j < h; j++)
339 double r =
d(j, i, 0);
340 double g =
d(j, i, 1);
341 double b =
d(j, i, 2);
345 img.setPixel (x_off + i, y_off + j,
367 std::list<std::string> modList;
368 Qt::KeyboardModifiers mods =
event->modifiers ();
370 if (mods & Qt::ShiftModifier)
371 modList.push_back (
"shift");
372 if (mods & Qt::ControlModifier)
373 #if defined (Q_OS_MAC)
374 modList.push_back (
"command");
376 modList.push_back (
"control");
378 if (mods & Qt::AltModifier)
379 modList.push_back (
"alt");
380 #if defined (Q_OS_MAC)
381 if (mods & Qt::MetaModifier)
382 modList.push_back (
"control");
397 #if defined (HAVE_QWHEELEVENT_ANGLEDELTA)
398 int ydelta = -(
event->angleDelta().y ());
400 int ydelta = (
event->orientation () == Qt::Vertical
401 ? -(
event->delta ()) : 0);
static int qp(const Matrix &H, const ColumnVector &q, const Matrix &Aeq, const ColumnVector &beq, const Matrix &Ain, const ColumnVector &bin, int maxit, double rtol, ColumnVector &x, ColumnVector &lambda, int &iter)
octave_idx_type numel(void) const
Number of elements in the array.
const T * fortran_vec(void) const
Size of the specified dimension.
base_properties & properties(void)
virtual Container * innerContainer(void)=0
Vector representing the dimensions (size) of an Array.
octave_idx_type ndims(void) const
Number of dimensions.
uint8NDArray uint8_array_value(void) const
NDArray array_value(bool frc_str_conv=false) const
bool is_single_type(void) const
FloatNDArray float_array_value(bool frc_str_conv=false) const
bool is_uint8_type(void) const
dim_vector dims(void) const
octave_idx_type numel(void) const
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE const F77_DBLE * f
std::complex< double > w(std::complex< double > z, double relerr=0)
std::string qKeyToKeyString(int key)
QColor fromRgb(const Matrix &rgb)
QFont computeFont(const typename T::properties &props, int height)
template QFont computeFont< uipanel >(const uipanel::properties &props, int height)
template QFont computeFont< uicontrol >(const uicontrol::properties &props, int height)
string_vector toStringVector(const QStringList &l)
std::string figureSelectionType(QMouseEvent *event, bool isDoubleClick)
template QFont computeFont< uitable >(const uitable::properties &props, int height)
QStringList fromStringVector(const string_vector &v)
Qt::Alignment fromHVAlign(const std::string &halign, const std::string &valign)
octave_scalar_map makeScrollEventStruct(QWheelEvent *event)
octave_scalar_map makeKeyEventStruct(QKeyEvent *event)
template QFont computeFont< uibuttongroup >(const uibuttongroup::properties &props, int height)
Matrix figureCurrentPoint(const graphics_object &fig, QMouseEvent *event)
Cell toCellString(const QStringList &l)
Matrix toRgb(const QColor &c)
QString fromStdString(const std::string &s)
std::string toStdString(const QString &s)
T::properties & properties(graphics_object obj)
QImage makeImageFromCData(const octave_value &v, int width, int height)
bool strcmpi(const T &str_a, const T &str_b)
True if strings are the same, ignoring case.
octave_value::octave_value(const Array< char > &chm, char type) return retval