26 #if defined (HAVE_CONFIG_H)
32 #include <QApplication>
34 #include <QMouseEvent>
55 return QString::fromUtf8 (s.c_str ());
61 return std::string (s.toUtf8 ().data ());
82 for (
const auto& s : l)
93 while ((tmp.length () > 0) && tmp.last ().isEmpty ())
105 template <
typename T>
111 static std::map<std::string, QFont::Weight> weightMap;
112 static std::map<std::string, QFont::Style> angleMap;
113 static bool mapsInitialized =
false;
115 if (! mapsInitialized)
117 weightMap[
"normal"] = QFont::Normal;
118 weightMap[
"bold"] = QFont::Bold;
120 angleMap[
"normal"] = QFont::StyleNormal;
121 angleMap[
"italic"] = QFont::StyleItalic;
122 angleMap[
"oblique"] = QFont::StyleOblique;
124 mapsInitialized =
true;
127 f.setPointSizeF (props.get___fontsize_points__ (height));
128 f.setWeight (weightMap[props.get_fontweight ()]);
129 f.setStyle (angleMap[props.get_fontangle ()]);
152 if (rgb.
numel () == 3)
153 c.setRgbF (rgb(0), rgb(1), rgb(2));
167 c.getRgbF (tmp, tmp+1, tmp+2);
168 rgbData[0] = tmp[0]; rgbData[1] = tmp[1]; rgbData[2] = tmp[2];
180 Qt::MouseButtons buttons = event->buttons ();
181 Qt::KeyboardModifiers mods = event->modifiers ();
183 if (mods == Qt::NoModifier)
185 if (buttons == Qt::LeftButton)
187 else if (buttons == Qt::RightButton)
189 else if (buttons == Qt::MiddleButton
190 || buttons == (Qt::LeftButton | Qt::RightButton))
193 else if (buttons == Qt::LeftButton)
195 if (mods == Qt::ShiftModifier)
197 else if (mods == Qt::ControlModifier)
221 QPoint
qp = c->mapFromGlobal (event->globalPos ());
223 return tkFig->
properties<figure> ().map_from_boundingbox (
qp.x (),
228 return Matrix (1, 2, 0.0);
244 QPoint
qp = c->mapFromGlobal (QCursor::pos ());
246 return tkFig->
properties<figure> ().map_from_boundingbox (
qp.x (),
251 return Matrix (1, 2, 0.0);
255 fromHVAlign (
const std::string& halign,
const std::string& valign)
260 flags |= Qt::AlignLeft;
262 flags |= Qt::AlignHCenter;
264 flags |= Qt::AlignRight;
266 flags |= Qt::AlignLeft;
269 flags |= Qt::AlignVCenter;
271 flags |= Qt::AlignTop;
273 flags |= Qt::AlignBottom;
275 flags |= Qt::AlignVCenter;
285 if (dv.
ndims () == 3 && dv(2) == 3)
292 int x_img_off = (
w < width ? (width -
w) / 2 : 0);
293 int y_img_off = (h < height ? (height - h) / 2 : 0);
294 int x_cdat_off = (dv(1) >
w ? (dv(1) -
w) / 2 : 0);
295 int y_cdat_off = (dv(0) > h ? (dv(0) - h) / 2 : 0);
297 QImage img (width, height, QImage::Format_ARGB32);
298 img.fill (qRgba (0, 0, 0, 0));
304 for (
int i = x_cdat_off; i <
w + x_cdat_off; i++)
305 for (
int j = y_cdat_off; j < h + y_cdat_off; j++)
312 img.setPixel (x_img_off + i - x_cdat_off,
313 y_img_off + j - y_cdat_off,
321 for (
int i = x_cdat_off; i <
w + x_cdat_off; i++)
322 for (
int j = y_cdat_off; j < h + y_cdat_off; j++)
324 float r =
f(j, i, 0);
325 float g =
f(j, i, 1);
326 float b =
f(j, i, 2);
330 img.setPixel (x_img_off + i - x_cdat_off,
331 y_img_off + j - y_cdat_off,
342 for (
int i = x_cdat_off; i <
w + x_cdat_off; i++)
343 for (
int j = y_cdat_off; j < h + y_cdat_off; j++)
345 double r =
d(j, i, 0);
346 double g =
d(j, i, 1);
347 double b =
d(j, i, 2);
351 img.setPixel (x_img_off + i - x_cdat_off,
352 y_img_off + j - y_cdat_off,
374 std::list<std::string> modList;
375 Qt::KeyboardModifiers mods =
event->modifiers ();
377 if (mods & Qt::ShiftModifier)
378 modList.push_back (
"shift");
379 if (mods & Qt::ControlModifier)
380 #if defined (Q_OS_MAC)
381 modList.push_back (
"command");
383 modList.push_back (
"control");
385 if (mods & Qt::AltModifier)
386 modList.push_back (
"alt");
387 #if defined (Q_OS_MAC)
388 if (mods & Qt::MetaModifier)
389 modList.push_back (
"control");
404 #if defined (HAVE_QWHEELEVENT_ANGLEDELTA)
405 int ydelta = -(
event->angleDelta().y ());
407 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)
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel(void) const
Number of elements in the array.
OCTARRAY_API T * fortran_vec(void)
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.
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
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
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)
template QFont computeFont< uibuttongroup >(const uibuttongroup::properties &props, int height)
std::string toStdString(const QString &s)
Matrix toRgb(const QColor &c)
Qt::Alignment fromHVAlign(const std::string &halign, const std::string &valign)
Cell toCellString(const QStringList &l)
template QFont computeFont< uipanel >(const uipanel::properties &props, int height)
QString fromStdString(const std::string &s)
template QFont computeFont< uitable >(const uitable::properties &props, int height)
string_vector toStringVector(const QStringList &l)
Matrix figureCurrentPoint(const graphics_object &fig)
octave_scalar_map makeKeyEventStruct(QKeyEvent *event)
QStringList fromStringVector(const string_vector &v)
template QFont computeFont< uicontrol >(const uicontrol::properties &props, int height)
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)
OCTAVE_API bool strcmpi(const T &str_a, const T &str_b)
True if strings are the same, ignoring case.