Commit 3c7e9ccb authored by Victor Yacovlev's avatar Victor Yacovlev

New Actor Painter

parent dc274a76
......@@ -38,7 +38,11 @@ actor = json.load(f)
f.close()
def name_to_cpp(name, firstUpper = False):
ascii = name["ascii"]
assert type(name)==dict or type(name)==str or type(name)==unicode
if type(name)==dict:
ascii = name["ascii"]
else:
ascii = name
newName = ""
nextIsCap = firstUpper
for c in ascii:
......@@ -50,6 +54,7 @@ def name_to_cpp(name, firstUpper = False):
elif c.upper() in "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_":
newName += c
nextIsCap = False
newName = newName.replace("#","").replace("?","").replace("!","")
return newName
def basetype_to_qtype(baseType):
......@@ -62,7 +67,7 @@ def basetype_to_qtype(baseType):
else:
return baseType
def vector_type(baseType): "QVector< "+baseType+" >"
def vector_type(baseType): return "QVector< "+baseType+" >"
def arg_to_qarg(arg):
try:
......@@ -79,7 +84,7 @@ def arg_to_qarg(arg):
qtype = "const "+qtype
if "out" in access or "Q" in qtype:
qtype += "&"
return qtype+name_to_cpp(arg["name"])
return qtype+" "+name_to_cpp(arg["name"])
# --------------------------- base class to be subclassed and implemented
......@@ -383,6 +388,48 @@ protected:
private slots:
void handleSettingsChanged();
private:
template <typename T> inline static QVector<T> toVector1(const QVariant & v)
{
const QVariantList l = v.toList();
QVector<T> result;
result.resize(l.size());
for (int i=0; i<l.size(); i++) {
result[i] = qvariant_cast<T>(l[i]);
}
return result;
}
template <typename T> inline static QVector< QVector<T> > toVector2(const QVariant & v)
{
const QVariantList l = v.toList();
QVector< QVector<T> > result;
result.resize(l.size());
for (int i=0; i<l.size(); i++) {
const QVariantList ll = l[i].toList();
result[i].resize(ll.size());
for (int j=0; j<ll.size(); j++) {
result[i][j] = qvariant_cast<T>(ll[j]);
}
}
return result;
}
template <typename T> inline static QVector< QVector< QVector<T> > > toVector3(const QVariant & v)
{
const QVariantList l = v.toList();
QVector< QVector< QVector<T> > > result;
result.resize(l.size());
for (int i=0; i<l.size(); i++) {
const QVariantList ll = l[i].toList();
result[i].resize(ll.size());
for (int j=0; j<ll.size(); j++) {
const QVariantList lll = ll[j].toList();
result[i][j].resize(lll.size());
for (int k=0; k<lll.size(); k++) {
result[i][j][k] = qvariant_cast<T>(lll[k]);
}
}
}
return result;
}
void updateSettings();
class %s* m_module;
%s
......@@ -422,7 +469,14 @@ def kumir_signature(method, locale="ascii"):
if method["returnType"]=="bool": res += u"лог "
if method["returnType"]=="char": res += u"сим "
if method["returnType"]=="string": res += u"лит "
res += method["name"]["ru_RU"]
if type(method["name"])==dict:
if "ru_RU" in method["name"]:
res += method["name"]["ru_RU"]
else:
res += method["name"]["ascii"]
else:
assert type(method["name"])==str or type(method["name"])==unicode
res += method["name"]
if method.has_key("arguments"):
args = list()
for arg in method["arguments"]:
......@@ -442,11 +496,20 @@ def kumir_signature(method, locale="ascii"):
if arg["access"]=="in/out": acc=u"аргрез "
except:
pass
a = acc+baseType+" "+arg["name"]
assert "name" in arg
assert type(arg["name"])==unicode or type(arg["name"])==str or type(arg["name"])==dict
if type(arg["name"])==unicode or type(arg["name"])==str:
argname = arg["name"]
elif type(arg["name"])==dict:
if "ru_RU" in arg["name"]:
argname = arg["name"]["ru_RU"]
else:
argname = arg["name"]["ascii"]
a = acc+baseType+" "+argname
if dim:
dummyBounds = ["0:0"] * dim
a += "["+string.join(dummyBounds, ",")+"]"
arg += [a]
args += [a]
res += "("+string.join(args, ", ")+")"
return res
......@@ -465,7 +528,7 @@ def make_method_call(method, fromThread=False):
else:
call = "m_module->run"+name_to_cpp(method["name"], True)+"("
arglines = []
optresults = []
optresults = ""
if method.has_key("arguments"):
for index, arg in enumerate(method["arguments"]):
try:
......@@ -478,20 +541,22 @@ def make_method_call(method, fromThread=False):
if not arg.has_key("access") or "in" in arg["access"]:
argline += " = "
if fromThread: argline += "l_"
argline +"args[%i]." % index
argvar = "args[%i]" % index
bt = basetype_to_qtype(arg["baseType"])
if dim:
argline += "toVector()"
argline += "toVector%i<%s>(%s)" % (dim, bt, argvar)
else:
bt = arg["baseType"]
bt = bt[0].upper() + bt[1:]
argline += "to"+bt+"()"
argline += "qvariant_cast<%s>(%s)" % (bt, argvar)
if arg.has_key("access") and "out" in arg["access"]:
optresults += ["x"+str(index+1)]
optresults += " l_optResults << x"+str(index+1)+";\n"
argline += ";"
arglines += [argline]
if index: call += ", "
call += "x"+str(index+1)
call += ")"
if optresults:
optresults = " l_optResults.clear();\n"+optresults
if method.has_key("returnType") and method["returnType"]!="void":
call = "v_result = QVariant(%s)" % call
if fromThread:
......@@ -509,6 +574,7 @@ def make_method_call(method, fromThread=False):
return """ {
$vardecl
$call
$optresults
if (s_errorText.length()>0)
return Shared::ES_Error;
return $ret;
......@@ -516,7 +582,8 @@ def make_method_call(method, fromThread=False):
""". \
replace("$vardecl", string.join(arglines, "\n ")). \
replace("$call", call+";"). \
replace("$ret", ret)
replace("$ret", ret). \
replace("$optresults", optresults)
else:
return """ {
$vardecl
......
......@@ -2,10 +2,9 @@
TS_MODULES = {
"ExtensionSystem": "src/shared/extensionsystem",
"ErrorMessages": "src/shared/errormessages",
"KumirStdLib": "src/shared/stdlib",
"ActorPainterC": "src/actors/painter/lib",
"ActorPainter": "src/actors/painter/module",
"ActorPainter": "src/actors/painter",
"ActorRobot": "src/actors/robot",
"Browser": "src/plugins/browser",
"CoreGUI": "src/plugins/coregui",
"Editor": "src/plugins/editor",
......
[Names]
default.png=Белый 640x480
linear_gray_320x480.png=В линейку 320x480
squares_gray_320x480.png=В клетку 320x480
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="ru_RU">
<context>
<name>ActorPainter::PainterNewImageDialog</name>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="14"/>
<source>Новый лист...</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="31"/>
<source>С параметрами</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="41"/>
<source>Из шаблона</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="94"/>
<source>Ширина:</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="114"/>
<source>Высота:</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="134"/>
<source>Цвет фона:</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="142"/>
<source>белый</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="147"/>
<source>черный</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="152"/>
<source>серый</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="157"/>
<source>фиолетовый</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="162"/>
<source>синий</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="167"/>
<source>голубой</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="172"/>
<source>зеленый</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="177"/>
<source>желтый</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="182"/>
<source>оранжевый</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="187"/>
<source>красный</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="192"/>
<source>другой...</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painternewimagedialog.ui" line="220"/>
<source>Предварительный просмотр шаблона:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ActorPainter::PainterWindow</name>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="14"/>
<source>MainWindow</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="91"/>
<source>100%</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="100"/>
<source>Новый лист...</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="105"/>
<source>Загрузить...</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="110"/>
<source>Сохранить копию</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="115"/>
<source>Сохранить копию как...</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="120"/>
<source>Вернуть к исходному</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="125"/>
<source>Масштаб 100%</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="130"/>
<source>Масштаб 50%</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="135"/>
<source>Масштаб по ширине</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="140"/>
<source>Масштаб по высоте</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="145"/>
<source>Масштаб по окну</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="153"/>
<source>#RRGGBB</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="161"/>
<source>R, G, B</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="169"/>
<source>C, M, Y, K</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="177"/>
<source>H, S, L</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.ui" line="185"/>
<source>H, S, V</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.cpp" line="140"/>
<source>Coordinates: X = %1, Y = %2; Colour: %3</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.cpp" line="179"/>
<location filename="../../../src/actors/painter/lib/painterwindow.cpp" line="200"/>
<source>Painter [%1]</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.cpp" line="182"/>
<source>Painter [новый лист]</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.cpp" line="193"/>
<source>Load image...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.cpp" line="195"/>
<location filename="../../../src/actors/painter/lib/painterwindow.cpp" line="224"/>
<source>Images (*.png)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.cpp" line="222"/>
<source>Save image...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.cpp" line="229"/>
<source>%1 - Painter</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterwindow.cpp" line="232"/>
<source>%2 - Painter [%1]</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ActorPainter::PainterWorker</name>
<message>
<location filename="../../../src/actors/painter/lib/painterworker.cpp" line="233"/>
<location filename="../../../src/actors/painter/lib/painterworker.cpp" line="278"/>
<location filename="../../../src/actors/painter/lib/painterworker.cpp" line="296"/>
<source>Invalid color</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterworker.cpp" line="345"/>
<source>Invalid points number</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterworker.cpp" line="384"/>
<source>Page size is too small</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterworker.cpp" line="387"/>
<source>Page size is too large (max. 3000 px)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterworker.cpp" line="397"/>
<source>File not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/painter/lib/painterworker.cpp" line="412"/>
<source>Can&apos;t open file for writing</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="ru_RU">
<context>
<name>ActorPainter::PainterModule</name>
<message>
<source>File not exists: %s</source>
<translation>Файл не найден: %s</translation>
</message>
<message>
<source>Invalid color</source>
<translation>Неверный цвет</translation>
</message>
<message>
<source>Invalid points number</source>
<translation>Неверное число точек</translation>
</message>
<message>
<source>Can&apos;t open file for writing: %s</source>
<translation>Не могу открыть файл на запись: %1</translation>
</message>
<message>
<source>Coordinate is less than 0</source>
<translation>Координата меньше 0</translation>
</message>
<message>
<source>Coordinate is out of page</source>
<translation>Координата за пределами листа</translation>
</message>
</context>
<context>
<name>ActorPainter::PainterNewImageDialog</name>
<message utf8="true">
<source>Новый лист...</source>
<translation>Новый лист...</translation>
</message>
<message utf8="true">
<source>С параметрами</source>
<translation>С параметрами</translation>
</message>
<message utf8="true">
<source>Из шаблона</source>
<translation>Из шаблона</translation>
</message>
<message utf8="true">
<source>Ширина:</source>
<translation>Ширина:</translation>
</message>
<message utf8="true">
<source>Высота:</source>
<translation>Высота:</translation>
</message>
<message utf8="true">
<source>Цвет фона:</source>
<translation>Цвет фона:</translation>
</message>
<message utf8="true">
<source>белый</source>
<translation>белый</translation>
</message>
<message utf8="true">
<source>черный</source>
<translation>черный</translation>
</message>
<message utf8="true">
<source>серый</source>
<translation>серый</translation>
</message>
<message utf8="true">
<source>фиолетовый</source>
<translation>фиолетовый</translation>
</message>
<message utf8="true">
<source>синий</source>
<translation>синий</translation>
</message>
<message utf8="true">
<source>голубой</source>
<translation>голубой</translation>
</message>
<message utf8="true">
<source>зеленый</source>
<translation>зеленый</translation>
</message>
<message utf8="true">
<source>желтый</source>
<translation>желтый</translation>
</message>
<message utf8="true">
<source>оранжевый</source>
<translation>оранжевый</translation>
</message>
<message utf8="true">
<source>красный</source>
<translation>красный</translation>
</message>
<message utf8="true"