27 #include <QApplication>
29 #include <QMouseEvent>
51 return QString::fromLocal8Bit (s.c_str ());
57 return std::string (s.toLocal8Bit ().data ());
78 foreach (
const QString& s, l)
89 while ((tmp.length () > 0) && (tmp.last ().length () == 0))
94 if (tmp.length () == 0)
107 static std::map<std::string, QFont::Weight> weightMap;
108 static std::map<std::string, QFont::Style> angleMap;
109 static bool mapsInitialized =
false;
111 if (! mapsInitialized)
113 weightMap[std::string (
"normal")] = QFont::Normal;
114 weightMap[std::string (
"light")] = QFont::Light;
115 weightMap[std::string (
"demi")] = QFont::DemiBold;
116 weightMap[std::string (
"bold")] = QFont::Normal;
118 angleMap[std::string (
"normal")] = QFont::StyleNormal;
119 angleMap[std::string (
"italic")] = QFont::StyleItalic;
120 angleMap[std::string (
"oblique")] = QFont::StyleOblique;
122 mapsInitialized =
true;
125 f.setPointSizeF (props.get_fontsize_points (height));
126 f.setWeight (weightMap[props.get_fontweight ()]);
127 f.setStyle (angleMap[props.get_fontangle ()]);
143 if (rgb.
numel () == 3)
144 c.setRgbF (rgb(0), rgb(1), rgb(2));
158 c.getRgbF (tmp, tmp+1, tmp+2);
159 rgbData[0] = tmp[0]; rgbData[1] = tmp[1]; rgbData[2] = tmp[2];
168 return std::string (
"open");
171 Qt::MouseButtons buttons = event->buttons ();
172 Qt::KeyboardModifiers mods = event->modifiers ();
174 if (mods == Qt::NoModifier)
176 if (buttons == Qt::LeftButton)
177 return std::string (
"normal");
178 else if (buttons == Qt::RightButton)
179 return std::string (
"alt");
180 #if defined (Q_WS_WIN)
181 else if (buttons == (Qt::LeftButton|Qt::RightButton))
182 return std::string (
"extend");
183 #elif defined (Q_WS_X11)
184 else if (buttons == Qt::MidButton)
185 return std::string (
"extend");
188 else if (buttons == Qt::LeftButton)
190 if (mods == Qt::ShiftModifier)
191 return std::string (
"extend");
192 else if (mods == Qt::ControlModifier)
193 return std::string (
"alt");
197 return std::string (
"normal");
216 QPoint
qp = c->mapFromGlobal (event->globalPos ());
223 return Matrix (1, 2, 0.0);
239 QPoint
qp = c->mapFromGlobal (QCursor::pos ());
246 return Matrix (1, 2, 0.0);
255 flags |= Qt::AlignLeft;
256 else if (halign.
compare (
"center"))
257 flags |= Qt::AlignHCenter;
258 else if (halign.
compare (
"right"))
259 flags |= Qt::AlignRight;
261 flags |= Qt::AlignLeft;
264 flags |= Qt::AlignVCenter;
265 else if (valign.
compare (
"top"))
266 flags |= Qt::AlignTop;
267 else if (valign.
compare (
"bottom"))
268 flags |= Qt::AlignBottom;
270 flags |= Qt::AlignVCenter;
280 if (dv.length () == 3 && dv(2) == 3)
282 int w = qMin (dv(1), static_cast<octave_idx_type> (width));
283 int h = qMin (dv(0), static_cast<octave_idx_type> (height));
285 int x_off = (w < width ? (width -
w) / 2 : 0);
286 int y_off = (h < height ? (height - h) / 2 : 0);
288 QImage img (width, height, QImage::Format_ARGB32);
289 img.fill (qRgba (0, 0, 0, 0));
295 for (
int i = 0; i <
w; i++)
296 for (
int j = 0; j < h; j++)
303 img.setPixel (x_off + i, y_off + j, qRgba (r, g, b, a));
310 for (
int i = 0; i <
w; i++)
311 for (
int j = 0; j < h; j++)
313 float r =
f(j, i, 0);
314 float g =
f(j, i, 1);
315 float b =
f(j, i, 2);
318 img.setPixel (x_off + i, y_off + j,
329 for (
int i = 0; i <
w; i++)
330 for (
int j = 0; j < h; j++)
332 double r =
d(j, i, 0);
333 double g =
d(j, i, 1);
334 double b =
d(j, i, 2);
337 img.setPixel (x_off + i, y_off + j,
359 std::list<std::string> modList;
360 Qt::KeyboardModifiers mods =
event->modifiers ();
362 if (mods & Qt::ShiftModifier)
363 modList.push_back (
"shift");
364 if (mods & Qt::ControlModifier)
366 modList.push_back (
"command");
368 modList.push_back (
"control");
370 if (mods & Qt::AltModifier)
371 modList.push_back (
"alt");
373 if (mods & Qt::MetaModifier)
374 modList.push_back (
"control");
uint8NDArray uint8_array_value(void) const
static int qp(const Matrix &H, const ColumnVector &q, const Matrix &Aeq, const ColumnVector &beq, const Matrix &Ain, const ColumnVector &bin, int maxit, ColumnVector &x, ColumnVector &lambda, int &iter)
bool is_real_type(void) const
octave_idx_type numel(void) const
Number of elements in the array.
QString fromStdString(const std::string &s)
void setfield(const std::string &key, const octave_value &val)
QStringList fromStringVector(const string_vector &v)
virtual Container * innerContainer(void)=0
Matrix figureCurrentPoint(const graphics_object &fig, QMouseEvent *event)
F77_RET_T const double const double double * d
template QFont computeFont< uicontrol >(const uicontrol::properties &props, int height)
QColor fromRgb(const Matrix &rgb)
std::string qKeyToKeyString(int key)
FloatNDArray float_array_value(bool frc_str_conv=false) const
F77_RET_T const double const double * f
octave_scalar_map makeKeyEventStruct(QKeyEvent *event)
Matrix toRgb(const QColor &c)
std::complex< double > w(std::complex< double > z, double relerr=0)
QFont computeFont(const typename T::properties &props, int height)
template QFont computeFont< uipanel >(const uipanel::properties &props, int height)
QImage makeImageFromCData(const octave_value &v, int width, int height)
dim_vector dims(void) const
octave_idx_type length(void) const
Number of elements in the array.
static Object * toolkitObject(const graphics_object &go)
NDArray array_value(bool frc_str_conv=false) const
Qt::Alignment fromHVAlign(const caseless_str &halign, const caseless_str &valign)
std::string figureSelectionType(QMouseEvent *event, bool isDoubleClick)
bool is_uint8_type(void) const
bool compare(const std::string &s, size_t limit=std::string::npos) const
Cell toCellString(const QStringList &l)
const T * fortran_vec(void) const
bool is_single_type(void) const
std::string toStdString(const QString &s)
base_properties & properties(void)
string_vector toStringVector(const QStringList &l)
T::properties & properties(graphics_object obj)