Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kumir2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kumir
kumir2
Commits
ade55ad6
Commit
ade55ad6
authored
Nov 10, 2020
by
Alexander A. Maly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Astyled actors
parent
6b0ddf4c
Pipeline
#2581
failed with stages
in 1 minute and 38 seconds
Changes
28
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
1306 additions
and
1258 deletions
+1306
-1258
scripts/gen_actor_source.py
scripts/gen_actor_source.py
+13
-22
src/actors/_colorer/_colorer.json
src/actors/_colorer/_colorer.json
+44
-44
src/actors/_colorer/_colorermodule.cpp
src/actors/_colorer/_colorermodule.cpp
+192
-212
src/actors/_colorer/_colorermodule.h
src/actors/_colorer/_colorermodule.h
+18
-31
src/actors/complexnumbers/complexnumbers.json
src/actors/complexnumbers/complexnumbers.json
+54
-54
src/actors/complexnumbers/complexnumbersmodule.cpp
src/actors/complexnumbers/complexnumbersmodule.cpp
+116
-108
src/actors/complexnumbers/complexnumbersmodule.h
src/actors/complexnumbers/complexnumbersmodule.h
+35
-34
src/actors/draw/drawmodule.cpp
src/actors/draw/drawmodule.cpp
+9
-1
src/actors/draw/drawmodule.h
src/actors/draw/drawmodule.h
+5
-0
src/actors/grasshopper/grasshoppermodule.cpp
src/actors/grasshopper/grasshoppermodule.cpp
+2
-0
src/actors/grasshopper/kuznec.cpp
src/actors/grasshopper/kuznec.cpp
+9
-0
src/actors/isometricrobot/isometricrobotmodule.cpp
src/actors/isometricrobot/isometricrobotmodule.cpp
+2
-0
src/actors/isometricrobot/remotecontrol.cpp
src/actors/isometricrobot/remotecontrol.cpp
+283
-299
src/actors/keyboard/keyboardmodule.cpp
src/actors/keyboard/keyboardmodule.cpp
+300
-294
src/actors/keyboard/keyboardmodule.h
src/actors/keyboard/keyboardmodule.h
+72
-73
src/actors/robot/pult.cpp
src/actors/robot/pult.cpp
+2
-0
src/actors/robot/rfield.cpp
src/actors/robot/rfield.cpp
+8
-0
src/actors/robot/robotmodule.cpp
src/actors/robot/robotmodule.cpp
+12
-0
src/actors/robot/robotmodule.h
src/actors/robot/robotmodule.h
+5
-0
src/actors/robot/robotview.cpp
src/actors/robot/robotview.cpp
+4
-0
src/actors/turtle/pult.cpp
src/actors/turtle/pult.cpp
+1
-0
src/actors/turtle/turtlemodule.cpp
src/actors/turtle/turtlemodule.cpp
+9
-0
src/actors/turtle/turtlemodule.h
src/actors/turtle/turtlemodule.h
+9
-0
src/actors/vodoley/pult.cpp
src/actors/vodoley/pult.cpp
+4
-0
src/actors/vodoley/vodoleymodule.cpp
src/actors/vodoley/vodoleymodule.cpp
+6
-0
src/actors/vodoley/vodoleymodule.h
src/actors/vodoley/vodoleymodule.h
+1
-0
src/kumir2-libs/extensionsystem/settings.h
src/kumir2-libs/extensionsystem/settings.h
+0
-2
src/kumir2-libs/utils/lockedqueue.hpp
src/kumir2-libs/utils/lockedqueue.hpp
+91
-84
No files found.
scripts/gen_actor_source.py
View file @
ade55ad6
...
...
@@ -3254,12 +3254,7 @@ every build time
#define $headerGuard
// Qt includes
#include <QtCore>
#if QT_VERSION >= 0x050000
# include <QtWidgets>
#else
# include <QtGui>
#endif
#include <QtGlobal>
namespace $namespace {
...
...
@@ -3304,18 +3299,17 @@ every build time
// Kumir includes
#include <kumir2-libs/extensionsystem/kplugin.h>
#include <kumir2-libs/widgets/declarativesettingspage.h>
#include <kumir2/actorinterface.h>
namespace Widgets {
class DeclarativeSettingsPage;
}
// Qt includes
#include <QObject>
#include <QtPlugin>
#include <QtCore>
#if QT_VERSION >= 0x050000
# include <QtWidgets>
#else
# include <QtGui>
#endif
#include <QThread>
class QWidget;
namespace $namespace {
...
...
@@ -3371,6 +3365,7 @@ every build time
#include "$headerFileName"
#include "$moduleBaseHeaderFileName"
#include "$moduleHeaderFileName"
#include <kumir2-libs/widgets/declarativesettingspage.h>
namespace $namespace {
...
...
@@ -3437,12 +3432,8 @@ $customTypeDeclarations
#include <kumir2-libs/extensionsystem/kplugin.h>
// Qt includes
#include <QtCore>
#if QT_VERSION >= 0x050000
# include <QtWidgets>
#else
# include <QtGui>
#endif
class QMenu;
class QAction;
namespace $namespace {
...
...
@@ -3491,8 +3482,8 @@ every build time
#include <kumir2-libs/extensionsystem/kplugin.h>
// Qt includes
#include <Q
tCore
>
#include <Q
tGui
>
#include <Q
Menu
>
#include <Q
Action
>
namespace $namespace {
...
...
src/actors/_colorer/_colorer.json
View file @
ade55ad6
{
"name"
:
{
"ascii"
:
"_Colorer"
,
"ru_RU"
:
"_Цветник"
},
"types"
:
[
{
"name"
:
{
"ascii"
:
"color"
,
"ru_RU"
:
"цвет"
},
"fields"
:
[
{
"name"
:
"r"
,
"baseType"
:
"int"
},
{
"name"
:
"g"
,
"baseType"
:
"int"
},
{
"name"
:
"b"
,
"baseType"
:
"int"
},
{
"name"
:
"a"
,
"baseType"
:
"int"
}
]
}],
"methods"
:
[
{
"name"
:
{
"ascii"
:
"input"
,
"ru_RU"
:
"ввод"
},
"returnType"
:
"color"
,
"arguments"
:
[
{
"name"
:
"x"
,
"baseType"
:
"string"
},
{
"name"
:
"ok"
,
"baseType"
:
"bool"
,
"access"
:
"out"
}
]
},
{
"name"
:
{
"ascii"
:
"output"
,
"ru_RU"
:
"вывод"
},
"returnType"
:
"string"
,
"arguments"
:
[
{
"name"
:
"x"
,
"baseType"
:
"color"
}
]
},
{
"name"
:
{
"ascii"
:
"="
},
"returnType"
:
"bool"
,
"arguments"
:
[
{
"name"
:
"x"
,
"baseType"
:
"color"
},
{
"name"
:
"y"
,
"baseType"
:
"color"
}
]
},
{
"name"
:
{
"ascii"
:
"<>"
},
"returnType"
:
"bool"
,
"arguments"
:
[
{
"name"
:
"x"
,
"baseType"
:
"color"
},
{
"name"
:
"y"
,
"baseType"
:
"color"
}
]
}
]
"name"
:
{
"ascii"
:
"_Colorer"
,
"ru_RU"
:
"_Цветник"
},
"types"
:
[
{
"name"
:
{
"ascii"
:
"color"
,
"ru_RU"
:
"цвет"
},
"fields"
:
[
{
"name"
:
"r"
,
"baseType"
:
"int"
},
{
"name"
:
"g"
,
"baseType"
:
"int"
},
{
"name"
:
"b"
,
"baseType"
:
"int"
},
{
"name"
:
"a"
,
"baseType"
:
"int"
}
]
}],
"methods"
:
[
{
"name"
:
{
"ascii"
:
"input"
,
"ru_RU"
:
"ввод"
},
"returnType"
:
"color"
,
"arguments"
:
[
{
"name"
:
"x"
,
"baseType"
:
"string"
},
{
"name"
:
"ok"
,
"baseType"
:
"bool"
,
"access"
:
"out"
}
]
},
{
"name"
:
{
"ascii"
:
"output"
,
"ru_RU"
:
"вывод"
},
"returnType"
:
"string"
,
"arguments"
:
[
{
"name"
:
"x"
,
"baseType"
:
"color"
}
]
},
{
"name"
:
{
"ascii"
:
"="
},
"returnType"
:
"bool"
,
"arguments"
:
[
{
"name"
:
"x"
,
"baseType"
:
"color"
},
{
"name"
:
"y"
,
"baseType"
:
"color"
}
]
},
{
"name"
:
{
"ascii"
:
"<>"
},
"returnType"
:
"bool"
,
"arguments"
:
[
{
"name"
:
"x"
,
"baseType"
:
"color"
},
{
"name"
:
"y"
,
"baseType"
:
"color"
}
]
}
]
}
src/actors/_colorer/_colorermodule.cpp
View file @
ade55ad6
...
...
@@ -6,267 +6,247 @@ Generated file is just a skeleton for module contents.
You should change it corresponding to functionality.
*/
// Self include
#include "_colorermodule.h"
#include <QColor>
// Kumir includes
#include <kumir2-libs/extensionsystem/kplugin.h>
// Qt includes
#include <QtCore>
#include <QtGui>
namespace
Actor_Colorer
{
namespace
Actor_Colorer
{
_ColorerModule
::
_ColorerModule
(
ExtensionSystem
::
KPlugin
*
parent
)
:
_ColorerModuleBase
(
parent
)
_ColorerModule
::
_ColorerModule
(
ExtensionSystem
::
KPlugin
*
parent
)
:
_ColorerModuleBase
(
parent
)
{
// Module constructor, called once on plugin load
// TODO implement me
// Module constructor, called once on plugin load
// TODO implement me
}
/* public static */
QList
<
ExtensionSystem
::
CommandLineParameter
>
_ColorerModule
::
acceptableCommandLineParameters
()
QList
<
ExtensionSystem
::
CommandLineParameter
>
_ColorerModule
::
acceptableCommandLineParameters
()
{
// See "src/shared/extensionsystem/commandlineparameter.h" for constructor details
return
QList
<
ExtensionSystem
::
CommandLineParameter
>
();
// See "src/shared/extensionsystem/commandlineparameter.h" for constructor details
return
QList
<
ExtensionSystem
::
CommandLineParameter
>
();
}
const
QStringList
&
_ColorerModule
::
standardRussianColorNames
()
const
QStringList
&
_ColorerModule
::
standardRussianColorNames
()
{
static
QStringList
validValues
;
if
(
validValues
.
isEmpty
())
{
validValues
<<
QString
::
fromUtf8
(
"прозрачный"
);
validValues
<<
QString
::
fromUtf8
(
"белый"
);
validValues
<<
QString
::
fromUtf8
(
"черный"
);
validValues
<<
QString
::
fromUtf8
(
"чёрный"
);
validValues
<<
QString
::
fromUtf8
(
"серый"
);
validValues
<<
QString
::
fromUtf8
(
"фиолетовый"
);
validValues
<<
QString
::
fromUtf8
(
"синий"
);
validValues
<<
QString
::
fromUtf8
(
"голубой"
);
validValues
<<
QString
::
fromUtf8
(
"зелёный"
);
validValues
<<
QString
::
fromUtf8
(
"зеленый"
);
validValues
<<
QString
::
fromUtf8
(
"жёлтый"
);
validValues
<<
QString
::
fromUtf8
(
"желтый"
);
validValues
<<
QString
::
fromUtf8
(
"оранжевый"
);
validValues
<<
QString
::
fromUtf8
(
"красный"
);
}
return
validValues
;
static
QStringList
validValues
;
if
(
validValues
.
isEmpty
())
{
validValues
<<
QString
::
fromUtf8
(
"прозрачный"
);
validValues
<<
QString
::
fromUtf8
(
"белый"
);
validValues
<<
QString
::
fromUtf8
(
"черный"
);
validValues
<<
QString
::
fromUtf8
(
"чёрный"
);
validValues
<<
QString
::
fromUtf8
(
"серый"
);
validValues
<<
QString
::
fromUtf8
(
"фиолетовый"
);
validValues
<<
QString
::
fromUtf8
(
"синий"
);
validValues
<<
QString
::
fromUtf8
(
"голубой"
);
validValues
<<
QString
::
fromUtf8
(
"зелёный"
);
validValues
<<
QString
::
fromUtf8
(
"зеленый"
);
validValues
<<
QString
::
fromUtf8
(
"жёлтый"
);
validValues
<<
QString
::
fromUtf8
(
"желтый"
);
validValues
<<
QString
::
fromUtf8
(
"оранжевый"
);
validValues
<<
QString
::
fromUtf8
(
"красный"
);
}
return
validValues
;
}
/* public slot */
void
_ColorerModule
::
changeGlobalState
(
ExtensionSystem
::
GlobalState
old
,
ExtensionSystem
::
GlobalState
current
)
{
// Called when changed kumir state. The states are defined as enum ExtensionSystem::GlobalState:
/*
namespace ExtensionSystem {
enum GlobalState {
GS_Unlocked, // Edit mode
GS_Observe, // Observe mode
GS_Running, // Running
mode
GS_Input, // User input required
GS_Pause // Running paused
};
}
*/
// TODO implement me
using
namespace
ExtensionSystem
;
// not to write "ExtensionSystem::" each time in this method scope
Q_UNUSED
(
old
);
// Remove this line on implementation
Q_UNUSED
(
current
);
// Remove this line on implementation
void
_ColorerModule
::
changeGlobalState
(
ExtensionSystem
::
GlobalState
old
,
ExtensionSystem
::
GlobalState
current
)
{
// Called when changed kumir state. The states are defined as enum ExtensionSystem::GlobalState:
/*
namespace ExtensionSystem {
enum GlobalState {
GS_Unlocked, // Edit
mode
GS_Observe, // Observe mode
GS_Running, // Running mode
GS_Input, // User input required
GS_Pause // Running paused
};
}
*/
Q_UNUSED
(
old
);
// Remove this line on implementation
Q_UNUSED
(
current
);
// Remove this line on implementation
}
/* public slot */
void
_ColorerModule
::
loadActorData
(
QIODevice
*
source
)
void
_ColorerModule
::
loadActorData
(
QIODevice
*
source
)
{
// Set actor specific data (like environment)
// The source should be ready-to-read QIODevice like QBuffer or QFile
Q_UNUSED
(
source
);
// By default do nothing
// Set actor specific data (like environment)
// The source should be ready-to-read QIODevice like QBuffer or QFile
Q_UNUSED
(
source
);
// By default do nothing
}
/* public slot */
void
_ColorerModule
::
reloadSettings
(
ExtensionSystem
::
SettingsPtr
settings
,
const
QStringList
&
keys
)
{
// Updates setting on module load, workspace change or appliyng settings dialog.
// If @param keys is empty -- should reload all settings, otherwise load only setting specified by @param keys
// TODO implement me
Q_UNUSED
(
settings
);
// Remove this line on implementation
Q_UNUSED
(
keys
);
// Remove this line on implementation
void
_ColorerModule
::
reloadSettings
(
ExtensionSystem
::
SettingsPtr
settings
,
const
QStringList
&
keys
)
{
// Updates setting on module load, workspace change or appliyng settings dialog.
// If @param keys is empty -- should reload all settings, otherwise load only setting specified by @param keys
// TODO implement me
Q_UNUSED
(
settings
);
// Remove this line on implementation
Q_UNUSED
(
keys
);
// Remove this line on implementation
}
/* public slot */
void
_ColorerModule
::
reset
()
void
_ColorerModule
::
reset
()
{
// Resets module to initial state before program execution
// TODO implement me
// Resets module to initial state before program execution
// TODO implement me
}
static
QColor
parseColor
(
const
QString
&
css
)
{
QColor
result
=
QColor
::
Invalid
;
QString
normCSS
=
css
.
toLower
().
remove
(
QRegExp
(
"
\\
s"
));
QRegExp
rxCSS
(
"(rgb|rgba|cmyk|cmyka|hsl|hsla|hsv|hsva)
\\
((.*)
\\
)"
);
QMap
<
QString
,
QString
>
ruNames
;
ruNames
[
QString
::
fromUtf8
(
"белый"
)]
=
"white"
;
ruNames
[
QString
::
fromUtf8
(
"черный"
)]
=
"black"
;
ruNames
[
QString
::
fromUtf8
(
"чёрный"
)]
=
"black"
;
ruNames
[
QString
::
fromUtf8
(
"серый"
)]
=
"gray"
;
ruNames
[
QString
::
fromUtf8
(
"фиолетовый"
)]
=
"magenta"
;
ruNames
[
QString
::
fromUtf8
(
"синий"
)]
=
"blue"
;
ruNames
[
QString
::
fromUtf8
(
"голубой"
)]
=
"lightblue"
;
ruNames
[
QString
::
fromUtf8
(
"зелёный"
)]
=
"lime"
;
ruNames
[
QString
::
fromUtf8
(
"зеленый"
)]
=
"lime"
;
ruNames
[
QString
::
fromUtf8
(
"жёлтый"
)]
=
"yellow"
;
ruNames
[
QString
::
fromUtf8
(
"желтый"
)]
=
"yellow"
;
ruNames
[
QString
::
fromUtf8
(
"оранжевый"
)]
=
"orange"
;
ruNames
[
QString
::
fromUtf8
(
"красный"
)]
=
"red"
;
if
(
normCSS
.
startsWith
(
"#"
))
{
result
=
QColor
(
css
);
// Qt supports HTML-colors
}
else
if
(
normCSS
.
isEmpty
()
||
normCSS
==
QString
::
fromUtf8
(
"прозрачный"
)
||
normCSS
==
QString
::
fromUtf8
(
"transparent"
)
)
{
result
=
QColor
(
0
,
0
,
0
,
0
);
}
else
if
(
rxCSS
.
exactMatch
(
normCSS
))
{
const
QString
model
=
rxCSS
.
cap
(
1
);
const
QStringList
components
=
rxCSS
.
cap
(
2
).
split
(
","
);
bool
ok
=
true
;
foreach
(
const
QString
&
comp
,
components
)
{
if
(
ok
)
{
comp
.
toInt
(
&
ok
);
}
}
if
(
ok
)
{
if
(
model
.
length
()
!=
components
.
size
())
{
result
=
QColor
::
Invalid
;
}
else
if
(
model
==
"rgb"
)
{
result
.
setRgb
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
());
}
else
if
(
model
==
"rgba"
)
{
result
.
setRgb
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
(),
components
[
3
].
toInt
());
}
else
if
(
model
==
"hsl"
)
{
result
.
setHsl
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
());
}
else
if
(
model
==
"hsla"
)
{
result
.
setHsl
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
(),
components
[
3
].
toInt
());
}
else
if
(
model
==
"hsv"
)
{
result
.
setHsv
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
());
}
else
if
(
model
==
"hsva"
)
{
result
.
setHsv
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
(),
components
[
3
].
toInt
());
}
else
if
(
model
==
"cmyk"
)
{
result
.
setCmyk
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
(),
components
[
3
].
toInt
());
}
else
if
(
model
==
"cmyka"
)
{
result
.
setCmyk
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
(),
components
[
3
].
toInt
(),
components
[
4
].
toInt
());
}
}
else
{
result
=
QColor
::
Invalid
;
}
}
else
if
(
ruNames
.
contains
(
normCSS
))
{
result
=
QColor
(
ruNames
[
normCSS
]);
}
else
{
result
=
QColor
(
normCSS
);
}
return
result
;
QColor
result
=
QColor
::
Invalid
;
QString
normCSS
=
css
.
toLower
().
remove
(
QRegExp
(
"
\\
s"
));
QRegExp
rxCSS
(
"(rgb|rgba|cmyk|cmyka|hsl|hsla|hsv|hsva)
\\
((.*)
\\
)"
);
QMap
<
QString
,
QString
>
ruNames
;
ruNames
[
QString
::
fromUtf8
(
"белый"
)]
=
"white"
;
ruNames
[
QString
::
fromUtf8
(
"черный"
)]
=
"black"
;
ruNames
[
QString
::
fromUtf8
(
"чёрный"
)]
=
"black"
;
ruNames
[
QString
::
fromUtf8
(
"серый"
)]
=
"gray"
;
ruNames
[
QString
::
fromUtf8
(
"фиолетовый"
)]
=
"magenta"
;
ruNames
[
QString
::
fromUtf8
(
"синий"
)]
=
"blue"
;
ruNames
[
QString
::
fromUtf8
(
"голубой"
)]
=
"lightblue"
;
ruNames
[
QString
::
fromUtf8
(
"зелёный"
)]
=
"lime"
;
ruNames
[
QString
::
fromUtf8
(
"зеленый"
)]
=
"lime"
;
ruNames
[
QString
::
fromUtf8
(
"жёлтый"
)]
=
"yellow"
;
ruNames
[
QString
::
fromUtf8
(
"желтый"
)]
=
"yellow"
;
ruNames
[
QString
::
fromUtf8
(
"оранжевый"
)]
=
"orange"
;
ruNames
[
QString
::
fromUtf8
(
"красный"
)]
=
"red"
;
if
(
normCSS
.
startsWith
(
"#"
))
{
result
=
QColor
(
css
);
// Qt supports HTML-colors
}
else
if
(
normCSS
.
isEmpty
()
||
normCSS
==
QString
::
fromUtf8
(
"прозрачный"
)
||
normCSS
==
QString
::
fromUtf8
(
"transparent"
)
)
{
result
=
QColor
(
0
,
0
,
0
,
0
);
}
else
if
(
rxCSS
.
exactMatch
(
normCSS
))
{
const
QString
model
=
rxCSS
.
cap
(
1
);
const
QStringList
components
=
rxCSS
.
cap
(
2
).
split
(
","
);
bool
ok
=
true
;
foreach
(
const
QString
&
comp
,
components
)
{
if
(
ok
)
{
comp
.
toInt
(
&
ok
);
}
}
if
(
ok
)
{
if
(
model
.
length
()
!=
components
.
size
())
{
result
=
QColor
::
Invalid
;
}
else
if
(
model
==
"rgb"
)
{
result
.
setRgb
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
());
}
else
if
(
model
==
"rgba"
)
{
result
.
setRgb
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
(),
components
[
3
].
toInt
());
}
else
if
(
model
==
"hsl"
)
{
result
.
setHsl
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
());
}
else
if
(
model
==
"hsla"
)
{
result
.
setHsl
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
(),
components
[
3
].
toInt
());
}
else
if
(
model
==
"hsv"
)
{
result
.
setHsv
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
());
}
else
if
(
model
==
"hsva"
)
{
result
.
setHsv
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
(),
components
[
3
].
toInt
());
}
else
if
(
model
==
"cmyk"
)
{
result
.
setCmyk
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
(),
components
[
3
].
toInt
());
}
else
if
(
model
==
"cmyka"
)
{
result
.
setCmyk
(
components
[
0
].
toInt
(),
components
[
1
].
toInt
(),
components
[
2
].
toInt
(),
components
[
3
].
toInt
(),
components
[
4
].
toInt
());
}
}
else
{
result
=
QColor
::
Invalid
;
}
}
else
if
(
ruNames
.
contains
(
normCSS
))
{
result
=
QColor
(
ruNames
[
normCSS
]);
}
else
{
result
=
QColor
(
normCSS
);
}
return
result
;
}
/* public slot */
Color
_ColorerModule
::
runOperatorINPUT
(
const
QString
&
x
,
bool
&
ok
)
Color
_ColorerModule
::
runOperatorINPUT
(
const
QString
&
x
,
bool
&
ok
)
{
/* алг цвет ввод(лит x, рез лог ok) */
const
QStringList
&
validValues
=
standardRussianColorNames
();
/* алг цвет ввод(лит x, рез лог ok) */
const
QStringList
&
validValues
=
standardRussianColorNames
();
ok
=
validValues
.
contains
(
x
.
trimmed
());
Color
result
;
result
.
r
=
result
.
g
=
result
.
b
=
result
.
a
=
0
;
if
(
ok
)
{
QColor
c
=
parseColor
(
x
.
trimmed
()).
toRgb
();
result
.
r
=
c
.
red
();
result
.
g
=
c
.
green
();
result
.
b
=
c
.
blue
();
result
.
a
=
c
.
alpha
();
}
return
result
;
ok
=
validValues
.
contains
(
x
.
trimmed
());
Color
result
;
result
.
r
=
result
.
g
=
result
.
b
=
result
.
a
=
0
;
if
(
ok
)
{
QColor
c
=
parseColor
(
x
.
trimmed
()).
toRgb
();
result
.
r
=
c
.
red
();
result
.
g
=
c
.
green
();
result
.
b
=
c
.
blue
();
result
.
a
=
c
.
alpha
();
}
return
result
;
}
static
Color
colorFromCss
(
const
QString
&
css
)
static
Color
colorFromCss
(
const
QString
&
css
)
{
QColor
qColor
=
parseColor
(
css
);
QColor
qRgbColor
=
qColor
.
toRgb
();
Color
result
;
result
.
r
=
qRgbColor
.
red
();
result
.
g
=
qRgbColor
.
green
();
result
.
b
=
qRgbColor
.
blue
();
result
.
a
=
qRgbColor
.
alpha
();
return
result
;
QColor
qColor
=
parseColor
(
css
);
QColor
qRgbColor
=
qColor
.
toRgb
();
Color
result
;
result
.
r
=
qRgbColor
.
red
();
result
.
g
=
qRgbColor
.
green
();
result
.
b
=
qRgbColor
.
blue
();
result
.
a
=
qRgbColor
.
alpha
();
return
result
;
}
static
quint32
colorToUintValue
(
const
Color
&
x
)
{
quint32
result
=
0u
;
quint8
r
=
quint8
(
x
.
r
);
quint8
g
=
quint8
(
x
.
g
);
quint8
b
=
quint8
(
x
.
b
);
quint8
a
=
quint8
(
x
.
a
);
result
=
(
r
<<
24
)
|
(
g
<<
16
)
|
(
b
<<
8
)
|
(
a
)
;
return
result
;
quint32
result
=
0u
;
quint8
r
=
quint8
(
x
.
r
);
quint8
g
=
quint8
(
x
.
g
);
quint8
b
=
quint8
(
x
.
b
);
quint8
a
=
quint8
(
x
.
a
);
result
=
(
r
<<
24
)
|
(
g
<<
16
)
|
(
b
<<
8
)
|
(
a
)
;
return
result
;
}
/* public slot */
QString
_ColorerModule
::
runOperatorOUTPUT
(
const
Color
&
x
)
QString
_ColorerModule
::
runOperatorOUTPUT
(
const
Color
&
x
)
{
/* алг лит вывод(цвет x) */
QString
result
;
QMap
<
quint32
,
QString
>
standardColorNames
;
standardColorNames
[
colorToUintValue
(
colorFromCss
(
QString
::
fromUtf8
(
"прозрачный"
)))]
=
(
QString
::
fromUtf8
(
"прозрачный"
));
standardColorNames
[
colorToUintValue
(
colorFromCss
(
QString
::
fromUtf8
(
"белый"
)))]
=
(
QString
::
fromUtf8
(
"белый"
));
standardColorNames
[
colorToUintValue
(
colorFromCss
(
QString
::
fromUtf8
(
"чёрный"
)))]
=
(
QString
::
fromUtf8
(
"чёрный"
));
standardColorNames
[
colorToUintValue
(
colorFromCss
(
QString
::
fromUtf8
(
"серый"
)))]
=
(
QString
::
fromUtf8
(
"серый"
));
standardColorNames
[
colorToUintValue
(
colorFromCss
(
QString
::
fromUtf8
(
"фиолетовый"
)))]
=
(
QString
::
fromUtf8
(
"фиолетовый"
));
standardColorNames
[
colorToUintValue
(
colorFromCss
(
QString
::
fromUtf8
(
"синий"
)))]
=
(
QString
::
fromUtf8
(
"синий"
));
standardColorNames
[
colorToUintValue
(
colorFromCss
(
QString
::
fromUtf8
(
"голубой"
)))]
=
(
QString
::
fromUtf8
(
"голубой"
));
standardColorNames
[
colorToUintValue
(
colorFromCss
(
QString
::
fromUtf8
(
"жёлтый"
)))]
=
(
QString
::
fromUtf8
(
"жёлтый"
));
standardColorNames
[
colorToUintValue
(
colorFromCss
(
QString
::
fromUtf8
(
"зелёный"
)))]
=
(
QString
::
fromUtf8
(
"зелёный"
));
standardColorNames
[
colorToUintValue
(
colorFromCss
(
QString
::
fromUtf8
(
"оранжевый"
)))]
=
(
QString
::
fromUtf8
(
"оранжевый"
));
standardColorNames
[
colorToUintValue
(
colorFromCss
(
QString
::
fromUtf8
(
"красный"
)))]
=
(
QString
::
fromUtf8
(
"красный"
));
quint32
hash
=
colorToUintValue
(
x
);
if
(
standardColorNames
.
contains
(
hash
))
{
result
=
standardColorNames
[
hash
];
}
else
{
QColor
qc
(
x
.
r
,
x
.
g
,
x
.
b
,
x
.
a
);
result
=
qc
.
name
();