26#if defined (HAVE_CONFIG_H)
32#include <QApplication>
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::MiddleButton
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 ());
224 return tkFig->
properties<figure> ().map_from_boundingbox (
qp.x (),
229 return Matrix (1, 2, 0.0);
245 QPoint
qp = c->mapFromGlobal (QCursor::pos ());
247 return tkFig->
properties<figure> ().map_from_boundingbox (
qp.x (),
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)
293 int x_img_off = (
w < width ? (width -
w) / 2 : 0);
294 int y_img_off = (h < height ? (height - h) / 2 : 0);
295 int x_cdat_off = (dv(1) >
w ? (dv(1) -
w) / 2 : 0);
296 int y_cdat_off = (dv(0) > h ? (dv(0) - h) / 2 : 0);
298 QImage img (width, height, QImage::Format_ARGB32);
299 img.fill (qRgba (0, 0, 0, 0));
305 for (
int i = x_cdat_off; i <
w + x_cdat_off; i++)
306 for (
int j = y_cdat_off; j < h + y_cdat_off; j++)
313 img.setPixel (x_img_off + i - x_cdat_off,
314 y_img_off + j - y_cdat_off,
322 for (
int i = x_cdat_off; i <
w + x_cdat_off; i++)
323 for (
int j = y_cdat_off; j < h + y_cdat_off; j++)
325 float r =
f(j, i, 0);
326 float g =
f(j, i, 1);
327 float b =
f(j, i, 2);
331 img.setPixel (x_img_off + i - x_cdat_off,
332 y_img_off + j - y_cdat_off,
343 for (
int i = x_cdat_off; i <
w + x_cdat_off; i++)
344 for (
int j = y_cdat_off; j < h + y_cdat_off; j++)
346 double r =
d(j, i, 0);
347 double g =
d(j, i, 1);
348 double b =
d(j, i, 2);
352 img.setPixel (x_img_off + i - x_cdat_off,
353 y_img_off + j - y_cdat_off,
375 std::list<std::string> modList;
376 Qt::KeyboardModifiers mods =
event->modifiers ();
378 if (mods & Qt::ShiftModifier)
379 modList.push_back (
"shift");
380 if (mods & Qt::ControlModifier)
381#if defined (Q_OS_MAC)
382 modList.push_back (
"command");
384 modList.push_back (
"control");
386 if (mods & Qt::AltModifier)
387 modList.push_back (
"alt");
388#if defined (Q_OS_MAC)
389 if (mods & Qt::MetaModifier)
390 modList.push_back (
"control");
405#if defined (HAVE_QWHEELEVENT_ANGLEDELTA)
406 int ydelta = -(
event->angleDelta().y ());
408 int ydelta = -(
event->delta ());
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.
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
Vector representing the dimensions (size) of an Array.
octave_idx_type ndims(void) const
Number of dimensions.
virtual Container * innerContainer(void)=0
base_properties & properties(void)
void setfield(const std::string &key, const octave_value &val)
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
std::complex< double > w(std::complex< double > z, double relerr=0)
std::string qKeyToKeyString(int key)
octave_scalar_map makeScrollEventStruct(QWheelEvent *event)
QImage makeImageFromCData(const octave_value &v, int width, int height)
QStringList fromStringVector(const string_vector &v)
QColor fromRgb(const Matrix &rgb)
QString fromStdString(const std::string &s)
template QFont computeFont< uitable >(const uitable::properties &props, int height)
std::string figureSelectionType(QMouseEvent *event, bool isDoubleClick)
QFont computeFont(const typename T::properties &props, int height)
Qt::Alignment fromHVAlign(const std::string &halign, const std::string &valign)
T::properties & properties(graphics_object obj)
Matrix toRgb(const QColor &c)
octave_scalar_map makeKeyEventStruct(QKeyEvent *event)
Cell toCellString(const QStringList &l)
template QFont computeFont< uipanel >(const uipanel::properties &props, int height)
std::string toStdString(const QString &s)
template QFont computeFont< uicontrol >(const uicontrol::properties &props, int height)
template QFont computeFont< uibuttongroup >(const uibuttongroup::properties &props, int height)
string_vector toStringVector(const QStringList &l)
Matrix figureCurrentPoint(const graphics_object &fig, QMouseEvent *event)
OCTAVE_API bool strcmpi(const T &str_a, const T &str_b)
True if strings are the same, ignoring case.
static double f(double k, double l_nu, double c_pm)