Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
MyCard
magicseteditor
Commits
61126b1f
Commit
61126b1f
authored
Nov 23, 2006
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished symbol rendering
parent
be3b5391
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
92 additions
and
13 deletions
+92
-13
src/render/symbol/filter.cpp
src/render/symbol/filter.cpp
+7
-0
src/render/symbol/filter.hpp
src/render/symbol/filter.hpp
+4
-0
src/render/symbol/viewer.cpp
src/render/symbol/viewer.cpp
+13
-0
src/render/symbol/viewer.hpp
src/render/symbol/viewer.hpp
+5
-4
src/render/value/symbol.cpp
src/render/value/symbol.cpp
+43
-1
src/render/value/symbol.hpp
src/render/value/symbol.hpp
+4
-0
src/util/io/package.hpp
src/util/io/package.hpp
+16
-8
No files found.
src/render/symbol/filter.cpp
View file @
61126b1f
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
// ----------------------------------------------------------------------------- : Includes
// ----------------------------------------------------------------------------- : Includes
#include <render/symbol/filter.hpp>
#include <render/symbol/filter.hpp>
#include <render/symbol/viewer.hpp>
#include <gfx/gfx.hpp>
#include <gfx/gfx.hpp>
#include <util/error.hpp>
#include <util/error.hpp>
...
@@ -37,6 +38,12 @@ void filter_symbol(Image& symbol, const SymbolFilter& filter) {
...
@@ -37,6 +38,12 @@ void filter_symbol(Image& symbol, const SymbolFilter& filter) {
}
}
}
}
Image
render_symbol
(
const
SymbolP
&
symbol
,
const
SymbolFilter
&
filter
,
double
border_radius
,
int
size
)
{
Image
i
=
render_symbol
(
symbol
,
border_radius
,
size
);
filter_symbol
(
i
,
filter
);
return
i
;
}
// ----------------------------------------------------------------------------- : SymbolFilter
// ----------------------------------------------------------------------------- : SymbolFilter
IMPLEMENT_REFLECTION
(
SymbolFilter
)
{
IMPLEMENT_REFLECTION
(
SymbolFilter
)
{
...
...
src/render/symbol/filter.hpp
View file @
61126b1f
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
#include <util/prec.hpp>
#include <util/prec.hpp>
#include <util/reflect.hpp>
#include <util/reflect.hpp>
DECLARE_POINTER_TYPE
(
Symbol
);
class
SymbolFilter
;
class
SymbolFilter
;
// ----------------------------------------------------------------------------- : Color
// ----------------------------------------------------------------------------- : Color
...
@@ -32,6 +33,9 @@ class AColor : public Color {
...
@@ -32,6 +33,9 @@ class AColor : public Color {
*/
*/
void
filter_symbol
(
Image
&
symbol
,
const
SymbolFilter
&
filter
);
void
filter_symbol
(
Image
&
symbol
,
const
SymbolFilter
&
filter
);
/// Render a Symbol to an Image and filter it
Image
render_symbol
(
const
SymbolP
&
symbol
,
const
SymbolFilter
&
filter
,
double
border_radius
=
0.05
,
int
size
=
100
);
/// Is a point inside a symbol?
/// Is a point inside a symbol?
enum
SymbolSet
enum
SymbolSet
{
SYMBOL_INSIDE
{
SYMBOL_INSIDE
...
...
src/render/symbol/viewer.cpp
View file @
61126b1f
...
@@ -11,6 +11,19 @@
...
@@ -11,6 +11,19 @@
DECLARE_TYPEOF_COLLECTION
(
SymbolPartP
);
DECLARE_TYPEOF_COLLECTION
(
SymbolPartP
);
// ----------------------------------------------------------------------------- : Simple rendering
Image
render_symbol
(
const
SymbolP
&
symbol
,
double
border_radius
,
int
size
)
{
SymbolViewer
viewer
(
symbol
,
border_radius
);
Bitmap
bmp
(
size
,
size
);
wxMemoryDC
dc
;
dc
.
SelectObject
(
bmp
);
clearDC_black
(
dc
);
viewer
.
draw
(
dc
);
dc
.
SelectObject
(
wxNullBitmap
);
return
bmp
.
ConvertToImage
();
}
// ----------------------------------------------------------------------------- : Constructor
// ----------------------------------------------------------------------------- : Constructor
SymbolViewer
::
SymbolViewer
(
const
SymbolP
&
symbol
,
double
border_radius
)
SymbolViewer
::
SymbolViewer
(
const
SymbolP
&
symbol
,
double
border_radius
)
...
...
src/render/symbol/viewer.hpp
View file @
61126b1f
...
@@ -41,12 +41,13 @@ class SymbolViewer : public SymbolView {
...
@@ -41,12 +41,13 @@ class SymbolViewer : public SymbolView {
// --------------------------------------------------- : Drawing
// --------------------------------------------------- : Drawing
public:
/// Draw the symbol to a dc
/// Draw the symbol to a dc
void
draw
(
DC
&
dc
);
void
draw
(
DC
&
dc
);
void
highlightPart
(
DC
&
dc
,
const
SymbolPart
&
part
,
HighlightStyle
style
);
void
highlightPart
(
DC
&
dc
,
const
SymbolPart
&
part
,
HighlightStyle
style
);
void
onAction
(
const
Action
&
,
bool
)
{}
private:
private:
/// Combines a symbol part with what is currently drawn, the border and interior are drawn separatly
/// Combines a symbol part with what is currently drawn, the border and interior are drawn separatly
/** directB/directI are true if the border/interior is the screen dc, false if it
/** directB/directI are true if the border/interior is the screen dc, false if it
...
...
src/render/value/symbol.cpp
View file @
61126b1f
...
@@ -7,9 +7,51 @@
...
@@ -7,9 +7,51 @@
// ----------------------------------------------------------------------------- : Includes
// ----------------------------------------------------------------------------- : Includes
#include <render/value/symbol.hpp>
#include <render/value/symbol.hpp>
#include <render/symbol/filter.hpp>
#include <data/set.hpp>
#include <data/symbol.hpp>
#include <gui/util.hpp> // draw_checker
#include <util/error.hpp>
DECLARE_TYPEOF_COLLECTION
(
SymbolStyle
::
VariationP
);
// ----------------------------------------------------------------------------- : SymbolValueViewer
// ----------------------------------------------------------------------------- : SymbolValueViewer
void
SymbolValueViewer
::
draw
(
RotatedDC
&
dc
)
{
void
SymbolValueViewer
::
draw
(
RotatedDC
&
dc
)
{
// TODO
drawFieldBorder
(
dc
);
// draw checker background
draw_checker
(
dc
,
style
().
getRect
());
double
wh
=
min
(
style
().
width
,
style
().
height
);
// try to load symbol
if
(
symbols
.
empty
()
&&
!
value
().
filename
.
empty
())
{
try
{
// load symbol
SymbolP
symbol
=
getSet
().
readFile
<
SymbolP
>
(
value
().
filename
);
// render and filter variations
FOR_EACH
(
variation
,
style
().
variations
)
{
Image
img
=
render_symbol
(
symbol
,
*
variation
->
filter
,
variation
->
border_radius
);
Image
resampled
(
wh
,
wh
,
false
);
resample
(
img
,
resampled
);
symbols
.
push_back
(
Bitmap
(
resampled
));
}
}
catch
(
const
Error
&
e
)
{
handle_error
(
e
);
}
}
// draw image, if any
for
(
size_t
i
=
0
;
i
<
symbols
.
size
()
;
++
i
)
{
// todo : labels?
dc
.
DrawBitmap
(
symbols
[
i
],
style
().
getPos
()
+
RealSize
(
i
*
(
wh
+
2
),
0
));
}
// draw helper text if there are no symbols
if
(
symbols
.
empty
())
{
dc
.
SetFont
(
wxFont
(
10
,
wxSWISS
,
wxNORMAL
,
wxNORMAL
));
dc
.
SetTextForeground
(
*
wxBLACK
);
RealSize
text_size
=
dc
.
GetTextExtent
(
_
(
"double click to edit symbol"
));
dc
.
DrawText
(
_
(
"double click to edit symbol"
),
align_in_rect
(
ALIGN_MIDDLE_CENTER
,
text_size
,
style
().
getRect
()));
}
}
void
SymbolValueViewer
::
onValueChange
()
{
symbols
.
clear
();
}
}
src/render/value/symbol.hpp
View file @
61126b1f
...
@@ -21,6 +21,10 @@ class SymbolValueViewer : public ValueViewer {
...
@@ -21,6 +21,10 @@ class SymbolValueViewer : public ValueViewer {
DECLARE_VALUE_VIEWER
(
Symbol
)
:
ValueViewer
(
parent
,
style
)
{}
DECLARE_VALUE_VIEWER
(
Symbol
)
:
ValueViewer
(
parent
,
style
)
{}
virtual
void
draw
(
RotatedDC
&
dc
);
virtual
void
draw
(
RotatedDC
&
dc
);
void
onValueChange
();
private:
vector
<
Bitmap
>
symbols
;
///< Cached images
};
};
// ----------------------------------------------------------------------------- : EOF
// ----------------------------------------------------------------------------- : EOF
...
...
src/util/io/package.hpp
View file @
61126b1f
...
@@ -112,22 +112,30 @@ class Package {
...
@@ -112,22 +112,30 @@ class Package {
/// Open a file given an absolute filename
/// Open a file given an absolute filename
static
InputStreamP
openAbsoluteFile
(
const
String
&
name
);
static
InputStreamP
openAbsoluteFile
(
const
String
&
name
);
/* // --------------------------------------------------- : Managing the inside of the package : IO files
// --------------------------------------------------- : Managing the inside of the package : Reader/writer
template
<
typename
T
>
template
<
typename
T
>
void readFile
<T> (String n
, T& obj) {
void
readFile
(
const
String
&
file
,
T
&
obj
)
{
In i(openFileIn(n), filename + _("/") + n
);
Reader
reader
(
openIn
(
file
),
absoluteFilename
()
+
_
(
"/"
)
+
file
);
try
{
try
{
i
(obj);
reader
.
handle
(
obj
);
} catch (
ParseError e
) {
}
catch
(
const
ParseError
&
err
)
{
throw FileParseError(e
.what(), filename+_("/")+n
); // more detailed message
throw
FileParseError
(
e
rr
.
what
(),
absoluteFilename
()
+
_
(
"/"
)
+
file
);
// more detailed message
}
}
}
}
template
<
typename
T
>
T
readFile
(
const
String
&
file
)
{
T
obj
;
readFile
(
file
,
obj
);
return
obj
;
}
template
<
typename
T
>
template
<
typename
T
>
void writeFile(const String& file, T obj) {
void
writeFile
(
const
String
&
file
,
const
T
&
obj
)
{
Writer
writer
(
openOut
(
file
));
writer
.
handle
(
obj
);
}
}
*/
// --------------------------------------------------- : Private stuff
// --------------------------------------------------- : Private stuff
private:
private:
...
...
Write
Preview
Markdown
is supported
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