189 changes: 0 additions & 189 deletions src/libkstapp/kstScript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -598,183 +598,6 @@ checkDoNotPlaceInAnyPlot()
endEdit()
endMacro()

newMacro_(newBox,fixAspect,posX,posY,sizeX,sizeY,rot,fillColor,fillStyle,strokeStyle,strokeWidth,strokeBrushColor,strokeBrushStyle,strokeJoinStyle,strokeCapStyle,hmargin,vmargin,hspace,vspace)
newBox()
if($fixAspect==true)
checkFixAspectRatio()
fi()
if($fixAspect==false)
uncheckFixAspectRatio()
fi()
setPosX($posX)
setPosY($posY)
setGeoX($sizeX)
if(fixAspectRatioIsChecked()==false)
setGeoY($sizeY)
fi()
setRotation($rot)
setFillColor($fillColor)
setIndexOfFillStyle($fillStyle)
setIndexOfStrokeStyle($strokeStyle)
setStrokeWidth($strokeWidth)
setStrokeBrushColor($strokeBrushColor)
setIndexOfStrokeBrushStyle($strokeBrushStyle)
setIndexOfStrokeJoinStyle($strokeJoinStyle)
setIndexOfStrokeCapStyle($strokeCapStyle)
setLayoutHorizontalMargin($hmargin)
setLayoutVerticalMargin($vmargin)
setLayoutHorizontalSpacing($hspace)
setLayoutVerticalSpacing($vspace)
endEdit()
endMacro()

newMacro_(newCircle,posX,posY,size,rot,fillColor,fillStyle,strokeStyle,strokeWidth,strokeBrushColor,strokeBrushStyle,strokeJoinStyle,strokeCapStyle,hmargin,vmargin,hspace,vspace)
newCircle()
setPosX($posX)
setPosY($posY)
setGeoX($size)
setRotation($rot)
setFillColor($fillColor)
setIndexOfFillStyle($fillStyle)
setIndexOfStrokeStyle($strokeStyle)
setStrokeWidth($strokeWidth)
setStrokeBrushColor($strokeBrushColor)
setIndexOfStrokeBrushStyle($strokeBrushStyle)
setIndexOfStrokeJoinStyle($strokeJoinStyle)
setIndexOfStrokeCapStyle($strokeCapStyle)
setLayoutHorizontalMargin($hmargin)
setLayoutVerticalMargin($vmargin)
setLayoutHorizontalSpacing($hspace)
setLayoutVerticalSpacing($vspace)
endEdit()
endMacro()

newMacro_(newEllipse,fixAspect,posX,posY,sizeX,sizeY,rot,fillColor,fillStyle,strokeStyle,strokeWidth,strokeBrushColor,strokeBrushStyle,strokeJoinStyle,strokeCapStyle,hmargin,vmargin,hspace,vspace)
newEllipse()
if($fixAspect==true)
checkFixAspectRatio()
fi()
if($fixAspect==false)
uncheckFixAspectRatio()
fi()
setPosX($posX)
setPosY($posY)
setGeoX($sizeX)
if(fixAspectRatioIsChecked()==false)
setGeoY($sizeY)
fi()
setRotation($rot)
setFillColor($fillColor)
setIndexOfFillStyle($fillStyle)
setIndexOfStrokeStyle($strokeStyle)
setStrokeWidth($strokeWidth)
setStrokeBrushColor($strokeBrushColor)
setIndexOfStrokeBrushStyle($strokeBrushStyle)
setIndexOfStrokeJoinStyle($strokeJoinStyle)
setIndexOfStrokeCapStyle($strokeCapStyle)
setLayoutHorizontalMargin($hmargin)
setLayoutVerticalMargin($vmargin)
setLayoutHorizontalSpacing($hspace)
setLayoutVerticalSpacing($vspace)
endEdit()
endMacro()

newMacro_(newLine,fixAspect,posX,posY,sizeX,sizeY,rot,strokeStyle,strokeWidth,strokeBrushColor,strokeBrushStyle,strokeJoinStyle,strokeCapStyle,hmargin,vmargin,hspace,vspace)
newLine()
if($fixAspect==true)
checkFixAspectRatio()
fi()
if($fixAspect==false)
uncheckFixAspectRatio()
fi()
setPosX($posX)
setPosY($posY)
setGeoX($sizeX)
if(fixAspectRatioIsChecked()==false)
setGeoY($sizeY)
fi()
setRotation($rot)
setIndexOfStrokeStyle($strokeStyle)
setStrokeWidth($strokeWidth)
setStrokeBrushColor($strokeBrushColor)
setIndexOfStrokeBrushStyle($strokeBrushStyle)
setIndexOfStrokeJoinStyle($strokeJoinStyle)
setIndexOfStrokeCapStyle($strokeCapStyle)
setLayoutHorizontalMargin($hmargin)
setLayoutVerticalMargin($vmargin)
setLayoutHorizontalSpacing($hspace)
setLayoutVerticalSpacing($vspace)
endEdit()
endMacro()

newMacro_(newArrow,arrowAtStart,startScale,arrowAtEnd,endScale,fixAspect,posX,posY,sizeX,sizeY,rot,strokeStyle,strokeWidth,strokeBrushColor,strokeBrushStyle,strokeJoinStyle,strokeCapStyle,hmargin,vmargin,hspace,vspace)
newArrow()
if($arrowAtStart==true)
checkArrowAtStart()
setStartArrowScale($startScale)
fi()
if($arrowAtStart==false)
uncheckArrowAtStart()
fi()
if($arrowAtEnd==true)
checkArrowAtEnd()
setStartArrowScale($startEnd)
fi()
if($arrowAtEnd==false)
uncheckArrowAtEnd()
fi()
if($fixAspect==true)
checkFixAspectRatio()
fi()
if($fixAspect==false)
uncheckFixAspectRatio()
fi()
setPosX($posX)
setPosY($posY)
setGeoX($sizeX)
if(fixAspectRatioIsChecked()==false)
setGeoY($sizeY)
fi()
setRotation($rot)
setIndexOfStrokeStyle($strokeStyle)
setStrokeWidth($strokeWidth)
setStrokeBrushColor($strokeBrushColor)
setIndexOfStrokeBrushStyle($strokeBrushStyle)
setIndexOfStrokeJoinStyle($strokeJoinStyle)
setIndexOfStrokeCapStyle($strokeCapStyle)
setLayoutHorizontalMargin($hmargin)
setLayoutVerticalMargin($vmargin)
setLayoutHorizontalSpacing($hspace)
setLayoutVerticalSpacing($vspace)
endEdit()
endMacro()

newMacro_(newPicture,filename,posX,posY,size,rot,hmargin,vmargin,hspace,vspace)
newPicture($filename)
setPosX($posX)
setPosY($posY)
setGeoX($size)
setRotation($rot)
setLayoutHorizontalMargin($hmargin)
setLayoutVerticalMargin($vmargin)
setLayoutHorizontalSpacing($hspace)
setLayoutVerticalSpacing($vspace)
endEdit()
endMacro()

newMacro_(newSVG,filename,posX,posY,size,rot,hmargin,vmargin,hspace,vspace)
newSvgItem($filename)
setPosX($posX)
setPosY($posY)
setGeoX($size)
setRotation($rot)
setLayoutHorizontalMargin($hmargin)
setLayoutVerticalMargin($vmargin)
setLayoutHorizontalSpacing($hspace)
setLayoutVerticalSpacing($vspace)
endEdit()
endMacro()

newMacro_(newHistogram,vector,rtAutoBin,binsFrom,binsTo,nbins,yaxisNormNumInBin,yaxisNormFracInBin,yaxisNorm%InBin,yaxisNormPeakAt1)
newHistogram()
setDataVector($vector)
Expand Down Expand Up @@ -876,18 +699,6 @@ fi()
endEdit()
endMacro()

newMacro_(setPicture,name,pic)
beginEdit($name)
setPicture($pic)
endEdit()
endMacro()

newMacro_(setNameOfPlot,plot,name)
beginEdit($plot)
setName($name)
endEdit()
endMacro()

newMacro_(setName,obj,name)
beginEdit($obj)
if($name!=)
Expand Down
12 changes: 9 additions & 3 deletions src/libkstapp/labelscriptinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
***************************************************************************/

#include "labelscriptinterface.h"
#include "labelitem.h"

#include <QStringBuilder>

Expand All @@ -34,12 +33,12 @@ struct LabelTabSI {
item->setLabelColor(QColor(x.remove("setLabelColor(").remove(')')));
} else if(x.contains("Italic")) {
QFont f=item->labelFont();
f.setItalic(x.contains("un"));
f.setItalic(!x.contains("un"));
item->setLabelFont(f);
return "Done";
} else if(x.contains("Bold")) {
QFont f=item->labelFont();
f.setBold(x.contains("un"));
f.setBold(!x.contains("un"));
item->setLabelFont(f);
return "Done";
} else if(x.contains("setFont")) {
Expand Down Expand Up @@ -87,4 +86,11 @@ QByteArray LabelSI::getHandle() {
return ("Finished editing "%dim->item->Name()).toLatin1();
}

ScriptInterface* LabelSI::newLabel() {
LabelItem* bi=new LabelItem(kstApp->mainWindow()->tabWidget()->currentView(),"");
kstApp->mainWindow()->tabWidget()->currentView()->scene()->addItem(bi);
return new LabelSI(bi);
}


}
2 changes: 2 additions & 0 deletions src/libkstapp/labelscriptinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class LabelSI : public ScriptInterface
bool isValid();
QByteArray getHandle();
void endEditUpdate() {if (dim->item) dim->item->update();}
static ScriptInterface* newLabel();

private:
LayoutTabSI* layout;
DimensionTabSI* dim;
Expand Down
7 changes: 7 additions & 0 deletions src/libkstapp/plotscriptinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ PlotSI::PlotSI(PlotItem *it) : _layout(new LayoutTabSI), _dim(new DimensionTabSI

}

ScriptInterface* PlotSI::newPlot() {
PlotItem* bi=new PlotItem(kstApp->mainWindow()->tabWidget()->currentView());
kstApp->mainWindow()->tabWidget()->currentView()->scene()->addItem(bi);
return new PlotSI(bi);
}


QByteArrayList PlotSI::commands() {
return _layout->commands()<<_dim->commands()<<_stroke->commands()<<_fill->commands();
}
Expand Down
3 changes: 3 additions & 0 deletions src/libkstapp/plotscriptinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class PlotSI : public ScriptInterface
bool isValid();
QByteArray getHandle();
void endEditUpdate() {if (_item) _item->update();}

static ScriptInterface* newPlot();

protected:
QString noSuchFn(QString&) {return ""; }

Expand Down
56 changes: 34 additions & 22 deletions src/libkstapp/scriptserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "labelscriptinterface.h"
#include "stringscriptinterface.h"
#include "viewitemscriptinterface.h"
#include "arrowscriptinterface.h"
#include "plotscriptinterface.h"

#include "sessionmodel.h"
#include "updateserver.h"
Expand All @@ -29,17 +31,11 @@
#include "ellipseitem.h"
#include "labelitem.h"
#include "layoutboxitem.h"
#include "legenditem.h"
#include "lineitem.h"
#include "pictureitem.h"
#include "plotitem.h"
#include "sharedaxisboxitem.h"
#include "svgitem.h"
#include "viewitemdialog.h"
#include "plotitemdialog.h"
#include "arrowitemdialog.h"
#include "labelitemdialog.h"
#include "legenditemdialog.h"
#include "document.h"

#include "curve.h"
Expand Down Expand Up @@ -166,8 +162,8 @@ ScriptServer::ScriptServer(ObjectStore *obj) : _server(new QLocalServer(this)),
_fnMap.insert("getPlotList()",&ScriptServer::getPlotList);
_fnMap.insert("newPlot()",&ScriptServer::newPlot);

_fnMap.insert("getSharedAxisBoxList()",&ScriptServer::getSharedAxisBoxList);
_fnMap.insert("newSharedAxisBox()",&ScriptServer::newSharedAxisBox);
//_fnMap.insert("getSharedAxisBoxList()",&ScriptServer::getSharedAxisBoxList);
//_fnMap.insert("newSharedAxisBox()",&ScriptServer::newSharedAxisBox);

#ifndef KST_NO_SVG
_fnMap.insert("getSvgItemList()",&ScriptServer::getSvgItemList);
Expand Down Expand Up @@ -505,6 +501,7 @@ QByteArray ScriptServer::exec(QByteArray command, QLocalSocket *s,int ifMode,QBy
}

if(_interface) {
_interface->commands();
return handleResponse(_interface->doCommand(command).toLatin1(),s,ifMode,ifEqual,_if,var); //magic
} else {
return handleResponse("Unknown command!",s,ifMode,ifEqual,_if,var);
Expand Down Expand Up @@ -853,7 +850,7 @@ QByteArray ScriptServer::getArrowList(QByteArray&, QLocalSocket* s,ObjectStore*_
QByteArray ScriptServer::newArrow(QByteArray&, QLocalSocket* s,ObjectStore*,const int&ifMode,
const QByteArray&ifEqual,IfSI*& _if,VarSI*var) {
if(_interface) { return handleResponse("To access this function, first call endEdit()",s,ifMode,ifEqual,_if,var); }
else { _interface = DialogLauncherSI::self->newArrow(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
else { _interface = ArrowSI::newArrow(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
}


Expand All @@ -866,7 +863,7 @@ QByteArray ScriptServer::getBoxList(QByteArray&, QLocalSocket* s,ObjectStore*_st
QByteArray ScriptServer::newBox(QByteArray&, QLocalSocket* s,ObjectStore*,const int&ifMode,
const QByteArray&ifEqual,IfSI*& _if,VarSI*var) {
if(_interface) { return handleResponse("To access this function, first call endEdit()",s,ifMode,ifEqual,_if,var); }
else { _interface = DialogLauncherSI::self->newBox(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
else { _interface = ViewItemSI::newBox(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
}


Expand All @@ -879,7 +876,7 @@ QByteArray ScriptServer::getButtonList(QByteArray&, QLocalSocket* s,ObjectStore*
QByteArray ScriptServer::newButton(QByteArray&, QLocalSocket* s,ObjectStore*,const int&ifMode,
const QByteArray&ifEqual,IfSI*& _if,VarSI*var) {
if(_interface) { return handleResponse("To access this function, first call endEdit()",s,ifMode,ifEqual,_if,var); }
else { _interface = DialogLauncherSI::self->newButton(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
else { _interface = ViewItemSI::newButton(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
}


Expand All @@ -892,7 +889,7 @@ QByteArray ScriptServer::getLineEditList(QByteArray&, QLocalSocket* s,ObjectStor
QByteArray ScriptServer::newLineEdit(QByteArray&, QLocalSocket* s,ObjectStore*,const int&ifMode,
const QByteArray&ifEqual,IfSI*& _if,VarSI*var) {
if(_interface) { return handleResponse("To access this function, first call endEdit()",s,ifMode,ifEqual,_if,var); }
else { _interface = DialogLauncherSI::self->newLineEdit(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
else { _interface = ViewItemSI::newLineEdit(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
}


Expand All @@ -905,7 +902,7 @@ QByteArray ScriptServer::getCircleList(QByteArray&, QLocalSocket* s,ObjectStore*
QByteArray ScriptServer::newCircle(QByteArray&, QLocalSocket* s,ObjectStore*,const int&ifMode,
const QByteArray&ifEqual,IfSI*& _if,VarSI*var) {
if(_interface) { return handleResponse("To access this function, first call endEdit()",s,ifMode,ifEqual,_if,var); }
else { _interface = DialogLauncherSI::self->newCircle(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
else { _interface = ViewItemSI::newCircle(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
}


Expand All @@ -918,7 +915,7 @@ QByteArray ScriptServer::getEllipseList(QByteArray&, QLocalSocket* s,ObjectStore
QByteArray ScriptServer::newEllipse(QByteArray&, QLocalSocket* s,ObjectStore*,const int&ifMode,
const QByteArray&ifEqual,IfSI*& _if,VarSI*var) {
if(_interface) { return handleResponse("To access this function, first call endEdit()",s,ifMode,ifEqual,_if,var); }
else { _interface = DialogLauncherSI::self->newEllipse(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
else { _interface = ViewItemSI::newEllipse(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
}


Expand All @@ -931,7 +928,7 @@ QByteArray ScriptServer::getLabelList(QByteArray&, QLocalSocket* s,ObjectStore*_
QByteArray ScriptServer::newLabel(QByteArray&, QLocalSocket* s,ObjectStore*,const int&ifMode,
const QByteArray&ifEqual,IfSI*& _if,VarSI*var) {
if(_interface) { return handleResponse("To access this function, first call endEdit()",s,ifMode,ifEqual,_if,var); }
else { _interface = DialogLauncherSI::self->newLabel(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
else { _interface = LabelSI::newLabel(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
}


Expand All @@ -944,7 +941,7 @@ QByteArray ScriptServer::getLineList(QByteArray&, QLocalSocket* s,ObjectStore*_s
QByteArray ScriptServer::newLine(QByteArray&, QLocalSocket* s,ObjectStore*,const int&ifMode,
const QByteArray&ifEqual,IfSI*& _if,VarSI*var) {
if(_interface) { return handleResponse("To access this function, first call endEdit()",s,ifMode,ifEqual,_if,var); }
else { _interface = DialogLauncherSI::self->newLine(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
else { _interface = ViewItemSI::newLine(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
}


Expand All @@ -960,7 +957,7 @@ QByteArray ScriptServer::newPicture(QByteArray&command, QLocalSocket* s,ObjectSt
command.replace("newPicture(","");
command.remove(command.lastIndexOf(")"),1);
if(_interface) { return handleResponse("To access this function, first call endEdit()",s,ifMode,ifEqual,_if,var); }
else { _interface = DialogLauncherSI::self->newPicture(command); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
else { _interface = ViewItemSI::newPicture(command); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
}


Expand All @@ -976,13 +973,13 @@ QByteArray ScriptServer::getPlotList(QByteArray&, QLocalSocket* s,ObjectStore*_s
QByteArray ScriptServer::newPlot(QByteArray&, QLocalSocket* s,ObjectStore*,const int&ifMode,
const QByteArray&ifEqual,IfSI*& _if,VarSI*var) {
if(_interface) { return handleResponse("To access this function, first call endEdit()",s,ifMode,ifEqual,_if,var); }
else { _interface = DialogLauncherSI::self->newPlot(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
else { _interface = PlotSI::newPlot(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
}



/***********************************/

#if 0
QByteArray ScriptServer::getSharedAxisBoxList(QByteArray&, QLocalSocket* s,ObjectStore*,const int&ifMode,
const QByteArray&ifEqual,IfSI*& _if,VarSI*var) {
return outputViewItemList<SharedAxisBoxItem>(s,ifMode,ifEqual,_if,var);
Expand All @@ -992,7 +989,7 @@ QByteArray ScriptServer::newSharedAxisBox(QByteArray&, QLocalSocket* s,ObjectSto
if(_interface) { return handleResponse("To access this function, first call endEdit()",s,ifMode,ifEqual,_if,var); }
else { _interface = DialogLauncherSI::self->newSharedAxisBox(); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
}

#endif

#ifndef KST_NO_SVG
QByteArray ScriptServer::getSvgItemList(QByteArray&, QLocalSocket* s,ObjectStore*_store,const int&ifMode,
Expand All @@ -1005,11 +1002,26 @@ QByteArray ScriptServer::newSvgItem(QByteArray&command, QLocalSocket* s,ObjectSt
command.replace("newSvgItem(","");
command.remove(command.lastIndexOf(")"),1);
if(_interface) { return handleResponse("To access this function, first call endEdit()",s,ifMode,ifEqual,_if,var); }
else { _interface = DialogLauncherSI::self->newSvgItem(command); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }
else { _interface = ViewItemSI::newSvgItem(command); return handleResponse("Ok",s,ifMode,ifEqual,_if,var); }

}
#endif


ScriptInterface* ScriptServer::getViewItemSI(ViewItem* x) {

if(qobject_cast<PlotItem*>(x)) {
return new PlotSI(qobject_cast<PlotItem*>(x));
} else if(qobject_cast<ArrowItem*>(x)) {
return new ArrowSI(qobject_cast<ArrowItem*>(x));
} else if(qobject_cast<LabelItem*>(x)) {
return new LabelSI(qobject_cast<LabelItem*>(x));
} else {
return new ViewItemSI(qobject_cast<ViewItem*>(x));
}
}


QByteArray ScriptServer::beginEdit(QByteArray&command, QLocalSocket* s,ObjectStore*_store,const int&ifMode,
const QByteArray&ifEqual,IfSI*& _if,VarSI*var) {
if(_interface) {
Expand All @@ -1024,7 +1036,7 @@ QByteArray ScriptServer::beginEdit(QByteArray&command, QLocalSocket* s,ObjectSto
for(int h=0;h<2;h++) {
for(int i=0;i<vi.size();i++) {
if(command.endsWith('('+vi[i]->shortName().toLatin1()+')')) {
_interface=DialogLauncherSI::self->showViewItemDialog(vi[i]);
_interface=getViewItemSI(vi[i]);
return handleResponse("Ok",s,ifMode,ifEqual,_if,var);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/libkstapp/scriptserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ScriptServer : public QObject
~ScriptServer();
QByteArray checkPrimatives(QByteArray&command,QLocalSocket* s);
void setStore(ObjectStore *obj) { _store = obj; vi.clear();}
static ScriptInterface* getViewItemSI(ViewItem* x);
public slots:
void procConnection();
void readSomething();
Expand Down Expand Up @@ -137,8 +138,8 @@ public slots:
QByteArray getPlotList(QByteArray& command, QLocalSocket* s,ObjectStore*_store,const int&ifMode, const QByteArray&ifString,IfSI*& ifStat,VarSI*var);
QByteArray newPlot(QByteArray& command, QLocalSocket* s,ObjectStore*_store,const int&ifMode, const QByteArray&ifString,IfSI*& ifStat,VarSI*var);

QByteArray getSharedAxisBoxList(QByteArray& command, QLocalSocket* s,ObjectStore*_store,const int&ifMode, const QByteArray&ifString,IfSI*& ifStat,VarSI*var);
QByteArray newSharedAxisBox(QByteArray& command, QLocalSocket* s,ObjectStore*_store,const int&ifMode, const QByteArray&ifString,IfSI*& ifStat,VarSI*var);
//QByteArray getSharedAxisBoxList(QByteArray& command, QLocalSocket* s,ObjectStore*_store,const int&ifMode, const QByteArray&ifString,IfSI*& ifStat,VarSI*var);
//QByteArray newSharedAxisBox(QByteArray& command, QLocalSocket* s,ObjectStore*_store,const int&ifMode, const QByteArray&ifString,IfSI*& ifStat,VarSI*var);

#ifndef KST_NO_SVG
QByteArray getSvgItemList(QByteArray& command, QLocalSocket* s,ObjectStore*_store,const int&ifMode, const QByteArray&ifString,IfSI*& ifStat,VarSI*var);
Expand Down
1 change: 1 addition & 0 deletions src/libkstapp/viewitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ViewItem : public QObject, public NamedObject, public QGraphicsRectItem
Q_OBJECT
public:
friend class DialogLauncherSI;
friend class ViewItemSI;
enum GripMode {
Move = 1,
Resize = 2,
Expand Down
68 changes: 67 additions & 1 deletion src/libkstapp/viewitemscriptinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,14 @@ QString DimensionTabSI::doCommand(QString x) {

qreal relativeWidth = (command == "setGeoX") ? parameter :item->relativeWidth();
qreal relativeHeight = (command == "setGeoY") ? parameter :item->relativeHeight();
bool fixedAspect = (command == "uncheckFixAspectRatio") ? false :item->lockAspectRatio();

bool fixedAspect = item->lockAspectRatio();
if (command == "uncheckFixAspectRatio") {
fixedAspect = false;
} else if (command == "checkFixAspectRatio") {
fixedAspect = true;
}


qreal width = relativeWidth * parentWidth;
qreal height;
Expand Down Expand Up @@ -272,4 +279,63 @@ QByteArray ViewItemSI::getHandle() {
return ("Finished editing "%dim->item->Name()).toLatin1();
}

ScriptInterface* ViewItemSI::newBox() {
BoxItem* bi=new BoxItem(kstApp->mainWindow()->tabWidget()->currentView());
kstApp->mainWindow()->tabWidget()->currentView()->scene()->addItem(bi);
return new ViewItemSI(bi);
}

ScriptInterface* ViewItemSI::newButton() {
ButtonItem* bi=new ButtonItem(kstApp->mainWindow()->tabWidget()->currentView());
kstApp->mainWindow()->tabWidget()->currentView()->scene()->addItem(bi);
return new ViewItemSI(bi);
}

ScriptInterface* ViewItemSI::newLineEdit() {
LineEditItem* bi=new LineEditItem(kstApp->mainWindow()->tabWidget()->currentView());
kstApp->mainWindow()->tabWidget()->currentView()->scene()->addItem(bi);
return new ViewItemSI(bi);
}

ScriptInterface* ViewItemSI::newCircle() {
CircleItem* bi=new CircleItem(kstApp->mainWindow()->tabWidget()->currentView());
bi->setViewRect(-0.1/2.0, -0.1/2.0, 0.1/2.0, 0.1/2.0);
kstApp->mainWindow()->tabWidget()->currentView()->scene()->addItem(bi);
return new ViewItemSI(bi);
}

ScriptInterface* ViewItemSI::newEllipse() {
EllipseItem* bi=new EllipseItem(kstApp->mainWindow()->tabWidget()->currentView());
kstApp->mainWindow()->tabWidget()->currentView()->scene()->addItem(bi);
return new ViewItemSI(bi);
}

ScriptInterface* ViewItemSI::newLine() {
LineItem* bi=new LineItem(kstApp->mainWindow()->tabWidget()->currentView());
kstApp->mainWindow()->tabWidget()->currentView()->scene()->addItem(bi);
return new ViewItemSI(bi);
}

ScriptInterface* ViewItemSI::newPicture(QByteArray picf) {
PictureItem* bi=new PictureItem(kstApp->mainWindow()->tabWidget()->currentView(),QImage(QString::fromLocal8Bit(picf)));
kstApp->mainWindow()->tabWidget()->currentView()->scene()->addItem(bi);
bi->setViewRect(0.9,0.9,1.0,1.0,true);
bi->setVisible(1);
bi->updateViewItemParent();
return new ViewItemSI(bi);
}

#ifndef KST_NO_SVG
ScriptInterface* ViewItemSI::newSvgItem(QByteArray path) {
SvgItem* bi=new SvgItem(kstApp->mainWindow()->tabWidget()->currentView(),path);
kstApp->mainWindow()->tabWidget()->currentView()->scene()->addItem(bi);
bi->setViewRect(0.9,0.9,1.0,1.0,true);
bi->setVisible(1);
bi->updateViewItemParent();
return new ViewItemSI(bi);
}
#endif



}
16 changes: 16 additions & 0 deletions src/libkstapp/viewitemscriptinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
#include <QList>
#include "scriptinterface.h"
#include "viewitem.h"
#include "boxitem.h"
#include "circleitem.h"
#include "lineitem.h"
#include "ellipseitem.h"
#include "labelitem.h"
#include "pictureitem.h"
#include "svgitem.h"

#ifndef VIEWITEMSCRIPTINTERFACE_H
#define VIEWITEMSCRIPTINTERFACE_H
Expand Down Expand Up @@ -60,6 +67,15 @@ class ViewItemSI : public ScriptInterface
bool isValid();
QByteArray getHandle();
void endEditUpdate() {if (dim->item) dim->item->update();}

static ScriptInterface* newBox();
static ScriptInterface* newButton();
static ScriptInterface* newLineEdit();
static ScriptInterface* newCircle();
static ScriptInterface* newEllipse();
static ScriptInterface* newLine();
static ScriptInterface* newPicture(QByteArray file);
static ScriptInterface* newSvgItem(QByteArray path);
private:
LayoutTabSI* layout;
DimensionTabSI* dim;
Expand Down