Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenFlipper-Free
Plugin-PropertyVis
Commits
0b4f9600
Commit
0b4f9600
authored
Mar 21, 2017
by
Martin Heistermann
Browse files
propvis scripting: add vector prop support + refactor
parent
1e6769d4
Changes
3
Hide whitespace changes
Inline
Side-by-side
ScriptObjects/ScriptSettings.cc
View file @
0b4f9600
...
...
@@ -15,21 +15,33 @@
ScriptSettings
::
ScriptSettings
(
QWidget
*
widget
)
{
if
(
widget
==
nullptr
)
return
;
connect
(
widget
,
&
QWidget
::
destroyed
,
this
,
&
QObject
::
deleteLater
);
if
(
widget
)
{
connect
(
widget
,
&
QWidget
::
destroyed
,
this
,
&
QObject
::
deleteLater
);
}
}
QScriptValue
createSettingsScriptObject
(
QScriptContext
*
ctx
,
QWidget
*
widget
)
{
QScriptEngine
*
engine
=
ctx
->
engine
();
auto
bw
=
dynamic_cast
<
BooleanWidget
*>
(
widget
);
if
(
bw
)
{
return
engine
->
newQObject
(
new
ScriptSettingsBoolean
(
bw
));
}
auto
dw
=
dynamic_cast
<
DoubleWidget
*>
(
widget
);
if
(
dw
)
{
return
engine
->
newQObject
(
new
ScriptSettingsDouble
(
dw
));
}
auto
dv
=
dynamic_cast
<
VectorWidget
*>
(
widget
);
if
(
dv
)
{
return
engine
->
newQObject
(
new
ScriptSettingsVector
(
dv
));
}
// not implemented:
return
QScriptValue
::
SpecialValue
::
NullValue
;
ScriptSettings
*
obj
=
nullptr
;
if
(
auto
w
=
dynamic_cast
<
BooleanWidget
*>
(
widget
))
{
obj
=
new
ScriptSettingsBoolean
(
w
);
}
else
if
(
auto
w
=
dynamic_cast
<
DoubleWidget
*>
(
widget
))
{
obj
=
new
ScriptSettingsDouble
(
w
);
}
else
if
(
auto
w
=
dynamic_cast
<
VectorWidget
*>
(
widget
))
{
obj
=
new
ScriptSettingsVector
(
w
);
}
if
(
!
obj
)
{
// no ScriptSettings class implemented for this widget
return
QScriptValue
::
SpecialValue
::
NullValue
;
}
return
engine
->
newQObject
(
obj
,
QScriptEngine
::
QtOwnership
,
QScriptEngine
::
ExcludeSuperClassMethods
|
QScriptEngine
::
ExcludeSuperClassProperties
|
QScriptEngine
::
ExcludeChildObjects
);
}
ScriptObjects/ScriptSettingsVector.cc
View file @
0b4f9600
#include
"ScriptSettingsVector.hh"
#include
"ACG/Utils/ColorConversion.hh"
ScriptSettingsVector
::
ScriptSettingsVector
()
:
ScriptSettings
(
nullptr
),
...
...
@@ -20,3 +21,79 @@ ScriptSettingsVector::ScriptSettingsVector(
ScriptSettingsVector
::~
ScriptSettingsVector
()
{}
ScriptSettingsVector
::
Type
ScriptSettingsVector
::
type
()
const
{
if
(
widget_
->
vectors_edges_rb
->
isChecked
())
{
return
Type
::
Edges
;
}
if
(
widget_
->
vectors_strokes_rb
->
isChecked
())
{
return
Type
::
Strokes
;
}
if
(
widget_
->
vectors_length_color_rb
->
isChecked
())
{
return
Type
::
LengthColor
;
}
if
(
widget_
->
vectors_colors_rb
->
isChecked
())
{
return
Type
::
Rgb
;
}
throw
std
::
logic_error
(
"No radiobutton selected?!"
);
}
void
ScriptSettingsVector
::
setType
(
ScriptSettingsVector
::
Type
type
)
{
switch
(
type
)
{
case
Type
::
Edges
:
widget_
->
vectors_edges_rb
->
setChecked
(
true
);
break
;
case
Type
::
Strokes
:
widget_
->
vectors_strokes_rb
->
setChecked
(
true
);
break
;
case
Type
::
LengthColor
:
widget_
->
vectors_length_color_rb
->
setChecked
(
true
);
break
;
case
Type
::
Rgb
:
widget_
->
vectors_colors_rb
->
setChecked
(
true
);
break
;
}
}
bool
ScriptSettingsVector
::
normalize
()
const
{
return
widget_
->
normalize
->
isChecked
();
}
void
ScriptSettingsVector
::
setNormalize
(
bool
normalize
)
{
widget_
->
normalize
->
setChecked
(
normalize
);
}
bool
ScriptSettingsVector
::
doScale
()
const
{
return
widget_
->
scale
->
isChecked
();
}
void
ScriptSettingsVector
::
setDoScale
(
bool
doScale
)
{
widget_
->
scale
->
setChecked
(
doScale
);
}
double
ScriptSettingsVector
::
scaleFactor
()
const
{
return
widget_
->
scaleBox
->
value
();
}
void
ScriptSettingsVector
::
setScaleFactor
(
double
scaleFactor
)
{
widget_
->
scaleBox
->
setValue
(
scaleFactor
);
}
Vector4
ScriptSettingsVector
::
lineColor
()
const
{
return
ACG
::
to_Vec4d
(
widget_
->
lineColor
->
color
());
}
void
ScriptSettingsVector
::
setLineColor
(
Vector4
lineColor
)
{
widget_
->
lineColor
->
setColor
(
ACG
::
to_QColor
(
lineColor
));
}
ScriptObjects/ScriptSettingsVector.hh
View file @
0b4f9600
...
...
@@ -12,16 +12,34 @@ class ScriptSettingsVector : public ScriptSettings
{
Q_OBJECT
//Q_PROPERTY(Vector4 colorTrue READ colorTrue WRITE setColorTrue )
Q_PROPERTY
(
Type
type
READ
type
WRITE
setType
)
Q_PROPERTY
(
bool
normalize
READ
normalize
WRITE
setNormalize
)
Q_PROPERTY
(
bool
doScale
READ
doScale
WRITE
setDoScale
)
Q_PROPERTY
(
double
scaleFactor
READ
scaleFactor
WRITE
setScaleFactor
)
Q_PROPERTY
(
Vector4
lineColor
READ
lineColor
WRITE
setLineColor
)
public:
enum
class
Type
{
Strokes
,
Rgb
,
Edges
,
LengthColor
};
Q_ENUM
(
Type
)
explicit
ScriptSettingsVector
();
explicit
ScriptSettingsVector
(
VectorWidget
*
widget
);
explicit
ScriptSettingsVector
(
const
ScriptSettingsVector
&
other
);
virtual
~
ScriptSettingsVector
();
signals:
Type
type
()
const
;
bool
normalize
()
const
;
bool
doScale
()
const
;
double
scaleFactor
()
const
;
Vector4
lineColor
()
const
;
public
slots
:
void
setType
(
Type
type
);
void
setNormalize
(
bool
normalize
);
void
setDoScale
(
bool
doScale
);
void
setScaleFactor
(
double
scaleFactor
);
void
setLineColor
(
Vector4
lineColor
);
private:
VectorWidget
*
widget_
;
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment