33
33
#include "KviError.h"
34
34
#include "KviIconManager.h"
35
35
#include "KviMemory.h"
36
#include <QPrintDialog>
36
#include <QPrintDialog>
37
37
#include <QTextDocument>
40
40
#define PAINTER_ROTATE(__angle,__axis)\
41
QTransform transform;\
42
transform.rotate(__angle,__axis);\
43
m_pPainter->setTransform(transform,true);
41
QTransform transform;\
42
transform.rotate(__angle,__axis);\
43
m_pPainter->setTransform(transform,true);
45
45
#define PAINTER_TRANSLATE(__x,__y)\
46
QTransform transform;\
47
transform.translate(__x,__y);\
48
m_pPainter->setTransform(transform,true);
46
QTransform transform;\
47
transform.translate(__x,__y);\
48
m_pPainter->setTransform(transform,true);
50
50
#define PAINTER_SHEAR(__sH,__sV)\
51
QTransform transform;\
52
transform.shear(__sH,__sV);\
53
m_pPainter->setTransform(transform,true);
51
QTransform transform;\
52
transform.shear(__sH,__sV);\
53
m_pPainter->setTransform(transform,true);
55
55
#define PAINTER_SCALE(__sX,__sY)\
56
QTransform transform;\
57
transform.scale(__sX,__sY);\
58
m_pPainter->setTransform(transform,true);
56
QTransform transform;\
57
transform.scale(__sX,__sY);\
58
m_pPainter->setTransform(transform,true);
61
61
const Qt::PenStyle penstyles_cod[] = {
78
const int align_cod[] = {
90
Qt::TextIncludeTrailingSpaces
92
const char * const align_tbl[] = {
104
"TextIncludeTrailingSpaces"
106
#define align_num (sizeof(align_tbl) / sizeof(align_tbl[0]))
79
109
const QPainter::CompositionMode composition_cod[] = {
80
QPainter::CompositionMode_SourceOver,
81
QPainter::CompositionMode_DestinationOver,
82
QPainter::CompositionMode_Clear,
83
QPainter::CompositionMode_Source,
84
QPainter::CompositionMode_Destination,
85
QPainter::CompositionMode_SourceIn,
86
QPainter::CompositionMode_DestinationIn,
87
QPainter::CompositionMode_SourceOut,
88
QPainter::CompositionMode_DestinationOut,
89
QPainter::CompositionMode_SourceAtop,
90
QPainter::CompositionMode_DestinationAtop,
91
QPainter::CompositionMode_Xor,
92
QPainter::CompositionMode_Plus,
93
QPainter::CompositionMode_Multiply,
94
QPainter::CompositionMode_Screen,
95
QPainter::CompositionMode_Overlay,
96
QPainter::CompositionMode_Darken,
97
QPainter::CompositionMode_Lighten,
98
QPainter::CompositionMode_ColorDodge,
99
QPainter::CompositionMode_ColorBurn,
100
QPainter::CompositionMode_HardLight,
101
QPainter::CompositionMode_SoftLight,
102
QPainter::CompositionMode_Difference,
103
QPainter::CompositionMode_Exclusion,
110
QPainter::CompositionMode_SourceOver,
111
QPainter::CompositionMode_DestinationOver,
112
QPainter::CompositionMode_Clear,
113
QPainter::CompositionMode_Source,
114
QPainter::CompositionMode_Destination,
115
QPainter::CompositionMode_SourceIn,
116
QPainter::CompositionMode_DestinationIn,
117
QPainter::CompositionMode_SourceOut,
118
QPainter::CompositionMode_DestinationOut,
119
QPainter::CompositionMode_SourceAtop,
120
QPainter::CompositionMode_DestinationAtop,
121
QPainter::CompositionMode_Xor,
122
QPainter::CompositionMode_Plus,
123
QPainter::CompositionMode_Multiply,
124
QPainter::CompositionMode_Screen,
125
QPainter::CompositionMode_Overlay,
126
QPainter::CompositionMode_Darken,
127
QPainter::CompositionMode_Lighten,
128
QPainter::CompositionMode_ColorDodge,
129
QPainter::CompositionMode_ColorBurn,
130
QPainter::CompositionMode_HardLight,
131
QPainter::CompositionMode_SoftLight,
132
QPainter::CompositionMode_Difference,
133
QPainter::CompositionMode_Exclusion,
105
135
const char * const composition_tbl[] = {
132
162
#define penstyles_num (sizeof(penstyles_tbl) / sizeof(penstyles_tbl[0]))
235
265
!fn: $drawRect(<x:integer>,<y:integer>,<w:unsigned integer>,<h:unsigned integer>)
236
266
Draws a rectangle with upper left corner at (x, y) and with width w and height h.
237
!fn: $drawRoundRect(<start_angle:integer>,<angle_length:integer>,<width:unsigned integer>,<height:unsigned integer>,<xr:integer>,<y:integer>)
267
!fn: $drawRoundRect(<start_angle:integer>,<angle_length:integer>,<width:unsigned integer>,<height:unsigned integer>,<xr:integer>,<y:integer>)
238
268
Draws a rectangle with rounded corners at (x, y), with width w and height h.[rb]
239
269
The xCor and yCor arguments specify how rounded the corners should be (range is 0->99).
240
270
!fn: $drawPie(<x:integer>,<y:integer>,<w:unsigned integer>,<h:unsigned integer>,<angle:integer>,<alen:integer>)
281
311
Returns the font metrics width for the painter's current font.
282
312
!fn: <integer>$fontMetricsHeight()
283
313
Returns the font metrics height for the painter's current font.
284
!fn: $rotate(<angle:real>,[<axis:string>])
285
Rotates the coordinate system a degrees counterclockwise by the given angle about the optional parameter <axis>.
286
Valid values for axis are: ZAxis, XAxis, YAxis.
287
Optional parameter <axis>
314
!fn: $rotate(<angle:real>,[<axis:string>])
315
Rotates the coordinate system a degrees counterclockwise by the given angle about the optional parameter <axis>.
316
Valid values for axis are: ZAxis, XAxis, YAxis.
317
Optional parameter <axis>
288
318
!fn: $translate(<dx:real>,<dy:real>)
289
319
Translates the coordinate system by <dx>, <dy>.
290
320
!fn: $shear(<dh:real>,<dv:real>)
295
325
Sets the background mode of the painter to <bgMode>: valid values are:[br]
296
326
- Transparent (that is the default value);[br]
298
!fn: $setOpacity(<opacity_factor:real>)
328
!fn: $setOpacity(<opacity_factor:real>)
299
329
Sets the painter opacity that affects all painter operations (drawpixmap, drawtext...). Valid values range are from 0 (total transparency) to 1 (total opacity)[br]
300
330
You must invoke the [classfnc]$begin[/classfnc] before using it.
301
!fn: $setTextAntialiasing(<boolean>)
331
!fn: $setTextAntialiasing(<boolean>)
302
332
Enable/disable antialias in text if possible.
303
333
You must call the [classfnc]$begin[/classfnc] before using it.
304
!fn: $setAntialiasing(<boolean>)
334
!fn: $setAntialiasing(<boolean>)
305
335
Enable/disable antialias in edges of primitives if possible.
306
336
You must call the [classfnc]$begin[/classfnc] before using it.
307
!fn: $setSmoothPixmapTransform(<boolean>)
337
!fn: $setSmoothPixmapTransform(<boolean>)
308
338
Enable/disable smooth bilinear pixmap transformation algorithm (such as bilinear).
309
339
You must call the [classfnc]$begin[/classfnc] before using it.
506
536
// Text & Pixmap & Icons
507
537
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_painter,drawText)
508
538
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_painter,drawPixmap)
539
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_painter,drawPixmapMirrored)
540
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_painter,drawPixmapWithColorEffect)
509
541
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_painter,drawIcon)
510
542
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_painter,drawHtmlText)
511
543
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_painter,htmlTextSize)
514
// Transform Operation
546
// Transform Operation
515
547
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_painter,rotate)
516
548
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_painter,shear)
517
549
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_painter,scale)
981
KVSO_CLASS_FUNCTION(painter,pen)
983
CHECK_INTERNAL_POINTER(m_pPainter)
985
KVSO_PARAMETERS_BEGIN(c)
986
KVSO_PARAMETER("flags",KVS_PT_STRING,KVS_PF_OPTIONAL,szFlags)
987
KVSO_PARAMETERS_END(c)
988
if(szFlags.isEmpty()){
989
c->returnValue()->setString(m_pPainter->pen().color().name());
992
QColor col=m_pPainter->pen().color();
993
KviKvsVariant *pRed = new KviKvsVariant((kvs_int_t)col.red());
994
KviKvsVariant *pGreen = new KviKvsVariant((kvs_int_t)col.green());
995
KviKvsVariant *pBlue = new KviKvsVariant((kvs_int_t)col.blue());
996
if (szFlags.indexOf('a',0,Qt::CaseInsensitive) != -1){
997
KviKvsArray *pArray = new KviKvsArray();
999
pArray->set(1,pGreen);
1000
pArray->set(2,pBlue);
1001
c->returnValue()->setArray(pArray);
1002
} else if (szFlags.indexOf('h',0,Qt::CaseInsensitive) != -1){
1003
KviKvsHash *pHash = new KviKvsHash();
1004
pHash->set("red",pRed);
1005
pHash->set("green",pGreen);
1006
pHash->set("blue",pBlue);
949
1010
KVSO_CLASS_FUNCTION(painter,setPen)
951
1012
CHECK_INTERNAL_POINTER(m_pPainter)
1078
1139
CHECK_INTERNAL_POINTER(m_pPainter)
1079
1140
KviKvsObject * pObject;
1080
1141
kvs_hobject_t hObject;
1083
KVSO_PARAMETERS_BEGIN(c)
1084
KVSO_PARAMETER("paint_device",KVS_PT_VARIANT,0,v)
1085
KVSO_PARAMETER("file_name",KVS_PT_STRING,KVS_PF_OPTIONAL,szFileName)
1144
KVSO_PARAMETERS_BEGIN(c)
1145
KVSO_PARAMETER("paint_device",KVS_PT_VARIANT,0,v)
1146
KVSO_PARAMETER("file_name",KVS_PT_STRING,KVS_PF_OPTIONAL,szFileName)
1086
1147
KVSO_PARAMETERS_END(c)
1092
if(KviQString::equalCI(szDev,"printer") || KviQString::equalCI(szDev,"pdf"))
1094
if (m_pPrinter) delete m_pPrinter;
1095
m_pPrinter=new QPrinter();
1096
if ( KviQString::equalCI(szDev,"pdf"))
1098
// m_pPrinter=new QPrinter();
1099
if(szFileName.isEmpty())
1101
c->warning(__tr2qs_ctx("Missing filename","objects"));
1104
m_pPrinter->setOutputFormat(QPrinter::PdfFormat);
1105
m_pPrinter->setOutputFileName(szFileName);
1109
QPrintDialog printDialog(m_pPrinter, 0);
1110
if (printDialog.exec() == QDialog::Accepted)
1112
qDebug("papersize %d",m_pPrinter->paperSize());
1113
m_pPainter->begin(m_pPrinter);
1122
//if (i==3) m_pPrinter->setPaperSize(QPrinter::A3);
1123
//if (i==4) m_pPrinter->setPaperSize(QPrinter::A4);
1127
c->warning(__tr2qs_ctx("No valid paint device","objects"));
1130
m_pPainter->begin(m_pPrinter);
1133
else if (v->isHObject())
1135
v->asHObject(hObject);
1136
pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
1139
c->warning(__tr2qs_ctx("Pixmap or Widget parameter is not an object","objects"));
1142
if(pObject->inheritsClass("pixmap"))pd=((KvsObject_pixmap *)pObject)->getImage();
1143
else if (pObject->inheritsClass("widget")) pd=((KvsObject_widget *)pObject)->widget();
1146
c->warning(__tr2qs_ctx("Widget or Pixmap required ","objects"));
1152
c->warning(__tr2qs_ctx("No valid paint device","objects"));
1155
attachDevice(pObject,pd);
1156
//if (pObject->inheritsClass("pixmap")) ((KvsObject_pixmap *)pObject)->pixmapChanged();
1153
if(KviQString::equalCI(szDev,"printer") || KviQString::equalCI(szDev,"pdf"))
1155
if (m_pPrinter) delete m_pPrinter;
1156
m_pPrinter=new QPrinter();
1157
if ( KviQString::equalCI(szDev,"pdf"))
1159
//m_pPrinter=new QPrinter();
1160
if(szFileName.isEmpty())
1162
c->warning(__tr2qs_ctx("Missing filename","objects"));
1165
m_pPrinter->setOutputFormat(QPrinter::PdfFormat);
1166
m_pPrinter->setOutputFileName(szFileName);
1168
QPrintDialog printDialog(m_pPrinter, 0);
1169
if (printDialog.exec() == QDialog::Accepted)
1171
qDebug("papersize %d",m_pPrinter->paperSize());
1172
m_pPainter->begin(m_pPrinter);
1179
//if (i==3) m_pPrinter->setPaperSize(QPrinter::A3);
1180
//if (i==4) m_pPrinter->setPaperSize(QPrinter::A4);
1182
c->warning(__tr2qs_ctx("No valid paint device","objects"));
1185
m_pPainter->begin(m_pPrinter);
1187
} else if (v->isHObject()) {
1188
v->asHObject(hObject);
1189
pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
1192
c->warning(__tr2qs_ctx("Pixmap or Widget parameter is not an object","objects"));
1195
if(pObject->inheritsClass("pixmap"))
1196
pd=((KvsObject_pixmap *)pObject)->getImage();
1197
else if (pObject->inheritsClass("widget"))
1198
pd=((KvsObject_widget *)pObject)->widget();
1201
c->warning(__tr2qs_ctx("Widget or Pixmap required ","objects"));
1205
c->warning(__tr2qs_ctx("No valid paint device","objects"));
1208
attachDevice(pObject,pd);
1209
//if (pObject->inheritsClass("pixmap")) ((KvsObject_pixmap *)pObject)->pixmapChanged();
1160
1213
void KvsObject_painter::attachDevice(KviKvsObject * o,QPaintDevice * p)
1216
1268
KVSO_CLASS_FUNCTION(painter,drawText)
1218
1270
CHECK_INTERNAL_POINTER(m_pPainter)
1219
QString szText,szMode;
1220
kvs_int_t iX,iY,iN=-1,iW,iH;
1272
QStringList szAlignList;
1273
kvs_int_t iX,iY,iW,iH; //,iN=-1;
1221
1274
KVSO_PARAMETERS_BEGIN(c)
1222
1275
KVSO_PARAMETER("x",KVS_PT_INT,0,iX)
1223
1276
KVSO_PARAMETER("y",KVS_PT_INT,0,iY)
1224
1277
KVSO_PARAMETER("w",KVS_PT_INT,0,iW)
1225
1278
KVSO_PARAMETER("h",KVS_PT_INT,0,iH)
1226
1279
KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
1280
KVSO_PARAMETER("align",KVS_PT_STRINGLIST,KVS_PF_OPTIONAL,szAlignList)
1228
1281
KVSO_PARAMETERS_END(c)
1229
if (!szMode.isEmpty() && !KviQString::equalCI(szMode,"Auto"))
1283
if(szAlignList.count())
1231
if(KviQString::equalCI(szMode,"RTL"))m_pPainter->setLayoutDirection(Qt::RightToLeft);
1232
else if(KviQString::equalCI(szMode,"LTR"))m_pPainter->setLayoutDirection(Qt::LeftToRight);
1285
for ( QStringList::Iterator it = szAlignList.begin(); it != szAlignList.end(); ++it )
1235
c->warning(__tr2qs_ctx("Invalid mode '%Q'","objects"),&szMode);
1288
for(unsigned int j = 0; j < align_num; j++)
1290
if(KviQString::equalCI((*it), align_tbl[j]))
1299
c->warning(__tr2qs_ctx("Unknown alignment '%Q'","objects"),&(*it));
1239
//if(!iN) iN = szText.length();
1243
1305
rect.setWidth(iW);
1244
1306
rect.setHeight(iH);
1246
m_pPainter->drawText(rect,szText);
1307
if(szAlignList.count()){
1308
m_pPainter->drawText(rect,sum,szText);
1310
else m_pPainter->drawText(rect,szText);
1250
1314
KVSO_CLASS_FUNCTION(painter,drawPixmap)
1252
1316
CHECK_INTERNAL_POINTER(m_pPainter)
1254
kvs_int_t iStartx,iStarty,iEndx,iEndy;
1317
kvs_real_t iX,iY,iWidth,iHeight,iStartx,iStarty;
1256
1319
KviKvsObject *obj;
1257
1320
kvs_hobject_t hObject;
1259
1322
KVSO_PARAMETER("x",KVS_PT_REAL,0,iX)
1260
1323
KVSO_PARAMETER("y",KVS_PT_REAL,0,iY)
1261
1324
KVSO_PARAMETER("pixmap",KVS_PT_HOBJECT,0,hObject)
1262
KVSO_PARAMETER("start_x",KVS_PT_INT,0,iStartx)
1263
KVSO_PARAMETER("start_y",KVS_PT_INT,0,iStarty)
1264
KVSO_PARAMETER("end_x",KVS_PT_INT,0,iEndx)
1265
KVSO_PARAMETER("end_y",KVS_PT_INT,0,iEndy)
1325
KVSO_PARAMETER("start_x",KVS_PT_REAL,0,iStartx)
1326
KVSO_PARAMETER("start_y",KVS_PT_REAL,0,iStarty)
1327
KVSO_PARAMETER("end_x",KVS_PT_REAL,0,iWidth)
1328
KVSO_PARAMETER("end_y",KVS_PT_REAL,0,iHeight)
1266
1329
KVSO_PARAMETER("b_Tiled",KVS_PT_BOOLEAN,KVS_PF_OPTIONAL,bTiled)
1267
1330
KVSO_PARAMETERS_END(c)
1268
1331
obj=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
1276
1339
c->warning(__tr2qs_ctx("Pixmap object required","objects"));
1279
QImage *pImage=((KvsObject_pixmap *)obj)->getImage();
1281
m_pPainter->drawImage(QPointF(iX,iY),*pImage,QRect(iStartx,iStarty,iEndx,iEndy));
1343
QPixmap *pPixmap=((KvsObject_pixmap *)obj)->getPixmap();
1344
//QPoint point(iX,iY);
1346
//QRectF rectf(QPointF(iStartx,iStarty),QSizeF(iWidth,iHeight));
1347
//m_pPainter->drawTiledPixmap(rectf,*pPixmap,pointf);
1348
//m_pPainter->drawTiledPixmap((int)iX,(int)iY,(int)iWidth,(int)iHeight,*pPixmap,(int)iStartx,(int)iStarty);
1349
qDebug("drawing at x %i - y %i - w %i - h %i - startpx %i - startpy %i casted",(int)iX,(int)iY,(int)iWidth,(int)iHeight,(int)iStartx,(int)iStarty);
1350
m_pPainter->drawTiledPixmap(iX,iY,iWidth,iHeight,*pPixmap,iStartx,iStarty);
1353
QImage *pImage=((KvsObject_pixmap *)obj)->getImage();
1354
QPoint pointf(iX,iY);
1355
QRectF rectf(QPointF(iStartx,iStarty),QSizeF(iWidth,iHeight));
1356
m_pPainter->drawImage(pointf,*pImage,rectf);
1284
KVSO_CLASS_FUNCTION(painter,drawPixmapWithEffect)
1361
KVSO_CLASS_FUNCTION(painter,drawPixmapWithColorEffect)
1286
1363
CHECK_INTERNAL_POINTER(m_pPainter)
1287
1364
QString szEffect;
1288
kvs_real_t iX,iY,factor;
1366
kvs_int_t r,g,b,iX,iY,iW,iH;
1290
1367
KviKvsObject *obj;
1291
1368
kvs_hobject_t hObject;
1292
1369
KVSO_PARAMETERS_BEGIN(c)
1293
1370
KVSO_PARAMETER("string_effect",KVS_PT_STRING,0,szEffect)
1294
KVSO_PARAMETER("x",KVS_PT_REAL,0,iX)
1295
KVSO_PARAMETER("y",KVS_PT_REAL,0,iY)
1371
KVSO_PARAMETER("x",KVS_PT_REAL,0,rX)
1372
KVSO_PARAMETER("y",KVS_PT_REAL,0,rY)
1296
1373
KVSO_PARAMETER("pixmap",KVS_PT_HOBJECT,0,hObject)
1297
KVSO_PARAMETER("red",KVS_PT_INTEGER,0,r)
1298
KVSO_PARAMETER("green",KVS_PT_INTEGER,0,g)
1299
KVSO_PARAMETER("blue",KVS_PT_INTEGER,0,b)
1374
KVSO_PARAMETER("red",KVS_PT_INT,KVS_PF_OPTIONAL,r)
1375
KVSO_PARAMETER("green",KVS_PT_INT,KVS_PF_OPTIONAL,g)
1376
KVSO_PARAMETER("blue",KVS_PT_INT,KVS_PF_OPTIONAL,b)
1377
KVSO_PARAMETER("start_x",KVS_PT_INT,KVS_PF_OPTIONAL,iX)
1378
KVSO_PARAMETER("start_y",KVS_PT_INT,KVS_PF_OPTIONAL,iY)
1379
KVSO_PARAMETER("width",KVS_PT_INT,KVS_PF_OPTIONAL,iW)
1380
KVSO_PARAMETER("height",KVS_PT_INT,KVS_PF_OPTIONAL,iH)
1300
1381
KVSO_PARAMETERS_END(c)
1301
1382
obj=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
1312
1393
QImage *pImage=((KvsObject_pixmap *)obj)->getImage();
1313
QImage pDest(pImage->width(),pImage->height(),QImage::Format_ARGB32);
1394
//QImage pDest(pImage->width(),pImage->height(),QImage::Format_ARGB32);
1315
1396
QRgb *dataSource;
1316
1397
QRgb *dataDest;
1317
1398
int w=pImage->width();
1318
1399
int h=pImage->height();
1320
if(KviQString::equalCI(szEffect,"add"))
1402
QImage pDest(iW,iH,QImage::Format_ARGB32);
1407
if(KviQString::equalCI(szEffect,"addrgb"))
1322
int sumR, sumG, sumB;
1323
for(int y=0; y<h; y++)
1409
int sumR, sumG, sumB,idx=0;
1410
for(int y=iY; y<iYend; y++)
1325
dataSource = (QRgb *) pImage->scanLine(y);
1326
dataDest = (QRgb *) pDest.scanLine(y);
1327
for (int x=0; x<w; x++)
1412
dataSource = (QRgb *) pImage->scanLine(y)+iX;
1413
dataDest = (QRgb *) pDest.scanLine(idx);
1415
for (int x=iX; x<iXend; x++)
1329
1417
col = *dataSource;
1330
1418
sumR=qRed(col)+r;
1362
m_pPainter->drawImage(QPointF(iX,iY),pDest);
1451
else if(KviQString::equalCI(szEffect,"grayscale"))
1455
for(int y=iY; y<iYend; y++)
1457
dataSource = (QRgb *) pImage->scanLine(y)+iX;
1458
dataDest = (QRgb *) pDest.scanLine(idx);
1459
for (int x=iX; x<iXend; x++)
1462
res = (qRed(col)+qGreen(col)+qBlue(col))/3;
1463
*dataDest++ = qRgba(res, res, res,qAlpha(col));
1469
m_pPainter->drawImage(QPointF(rX,rY),pDest);
1472
KVSO_CLASS_FUNCTION(painter,drawPixmapMirrored)
1474
CHECK_INTERNAL_POINTER(m_pPainter)
1475
bool bHorizontal,bVertical;
1476
kvs_int_t iX,iY,iW,iH;
1478
kvs_hobject_t hObject;
1480
KVSO_PARAMETERS_BEGIN(c)
1481
KVSO_PARAMETER("x",KVS_PT_REAL,0,rX)
1482
KVSO_PARAMETER("y",KVS_PT_REAL,0,rY)
1483
KVSO_PARAMETER("pixmap",KVS_PT_HOBJECT,0,hObject)
1484
KVSO_PARAMETER("bHorizontal",KVS_PT_BOOLEAN,0,bHorizontal)
1485
KVSO_PARAMETER("bvertical",KVS_PT_BOOLEAN,0,bVertical)
1486
KVSO_PARAMETER("start_x",KVS_PT_INT,KVS_PF_OPTIONAL,iX)
1487
KVSO_PARAMETER("start_y",KVS_PT_INT,KVS_PF_OPTIONAL,iY)
1488
KVSO_PARAMETER("width",KVS_PT_INT,KVS_PF_OPTIONAL,iW)
1489
KVSO_PARAMETER("height",KVS_PT_INT,KVS_PF_OPTIONAL,iH)
1490
KVSO_PARAMETERS_END(c)
1491
obj=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
1494
c->warning(__tr2qs_ctx("Pixmap parameter is not an object","objects"));
1497
if (!obj->inheritsClass("pixmap"))
1499
c->warning(__tr2qs_ctx("Pixmap object required","objects"));
1502
QImage *pImage=((KvsObject_pixmap *)obj)->getImage();
1503
QPoint sourceXY(0,0);
1504
if(c->parameterCount()>=5)
1509
QSize sourceWH(pImage->width(),pImage->height());
1510
if(c->parameterCount()>=5)
1512
sourceWH.setWidth(iW);
1513
sourceWH.setHeight(iH);
1515
QImage mirrored = pImage->mirrored(bHorizontal,bVertical);
1516
m_pPainter->drawImage(rX,rY,mirrored, sourceXY.x(), sourceXY.y(),sourceWH.width(),sourceWH.height());
1365
1519
KVSO_CLASS_FUNCTION(painter,rotate)
1367
1521
CHECK_INTERNAL_POINTER(m_pPainter)
1370
1524
KVSO_PARAMETERS_BEGIN(c)
1371
1525
KVSO_PARAMETER("angle",KVS_PT_DOUBLE,0,dAngle)
1372
KVSO_PARAMETER("axis",KVS_PT_STRING,KVS_PF_OPTIONAL,szAxis)
1526
KVSO_PARAMETER("axis",KVS_PT_STRING,KVS_PF_OPTIONAL,szAxis)
1373
1527
KVSO_PARAMETERS_END(c)
1374
Qt::Axis axis = Qt::ZAxis;
1375
if(!szAxis.isEmpty())
1377
if (KviQString::equalCI(szAxis,"XAxis"))axis=Qt::XAxis;
1378
else if (KviQString::equalCI(szAxis,"YAxis")) axis=Qt::YAxis;
1379
else if (KviQString::equalCI(szAxis,"ZAxis")) axis=Qt::ZAxis;
1380
else c->warning(__tr2qs_ctx("Unknown axis '%Q' switching to default ZAxis","objects"),&szAxis);
1382
PAINTER_ROTATE(dAngle,axis)
1528
Qt::Axis axis = Qt::ZAxis;
1529
if(!szAxis.isEmpty())
1531
if (KviQString::equalCI(szAxis,"XAxis"))axis=Qt::XAxis;
1532
else if (KviQString::equalCI(szAxis,"YAxis")) axis=Qt::YAxis;
1533
else if (KviQString::equalCI(szAxis,"ZAxis")) axis=Qt::ZAxis;
1534
else c->warning(__tr2qs_ctx("Unknown axis '%Q' switching to default ZAxis","objects"),&szAxis);
1536
PAINTER_ROTATE(dAngle,axis)
1436
1590
KVSO_PARAMETER("x",KVS_PT_INT,0,iX)
1437
1591
KVSO_PARAMETER("y",KVS_PT_INT,0,iY)
1438
1592
KVSO_PARAMETER("text",KVS_PT_STRING,0,szText)
1439
KVSO_PARAMETER("w",KVS_PT_INT,0,iW)
1440
KVSO_PARAMETER("h",KVS_PT_INT,0,iH)
1593
KVSO_PARAMETER("w",KVS_PT_INT,0,iW)
1594
KVSO_PARAMETER("h",KVS_PT_INT,0,iH)
1442
1596
KVSO_PARAMETERS_END(c)
1444
1598
doc.setHtml(szText);
1445
1599
doc.setDefaultFont(m_pPainter->font());
1446
1600
m_pPainter->save();
1447
1601
m_pPainter->translate(iX,iY);
1448
doc.setPageSize(QSize(iW,iH));
1602
doc.setPageSize(QSize(iW,iH));
1449
1603
doc.drawContents(m_pPainter);
1450
1604
m_pPainter->restore();
1717
1871
c->error(__tr2qs_ctx("One of the triplette parameters didn't evaluate to an integer","objects"));\
1720
if (c->paramCount()<5) iOpacity=255;
1874
if (c->paramCount()<5)
1722
1877
if(KviQString::equalCI(szColorMode, "HSV"))
1723
col.setHsv(iCol1,iCol2,iCol3,iOpacity);
1878
col.setHsv(iCol1,iCol2,iCol3,iOpacity);
1725
col.setRgb(iCol1,iCol2,iCol3,iOpacity);
1726
if (!m_pGradient) m_pGradient=new(QLinearGradient);
1880
col.setRgb(iCol1,iCol2,iCol3,iOpacity);
1882
m_pGradient=new(QLinearGradient);
1727
1883
m_pGradient->setColorAt(dAt,col);
1805
1959
c->error(__tr2qs_ctx("One of the triplette parameters didn't evaluate to an integer","objects"));\
1808
if (c->paramCount()<5) iOpacity=255;
1962
if (c->paramCount()<5)
1810
1965
if(KviQString::equalCI(szColorMode, "HSV"))
1811
col.setHsv(iCol1,iCol2,iCol3,iOpacity);
1966
col.setHsv(iCol1,iCol2,iCol3,iOpacity);
1813
col.setRgb(iCol1,iCol2,iCol3,iOpacity);
1968
col.setRgb(iCol1,iCol2,iCol3,iOpacity);
1815
m_pPainter->fillRect(iX,iY,iW,iH,col);
1970
m_pPainter->fillRect(iX,iY,iW,iH,QBrush(col));