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
80454fce
Commit
80454fce
authored
Jul 10, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Symmetry actions now work; reflection symmetry is forced to use a multiple of two copies
parent
53ee9924
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
6 deletions
+40
-6
src/data/action/symbol_part.cpp
src/data/action/symbol_part.cpp
+13
-2
src/data/action/symbol_part.hpp
src/data/action/symbol_part.hpp
+1
-0
src/gui/symbol/part_list.cpp
src/gui/symbol/part_list.cpp
+11
-0
src/gui/symbol/symmetry_editor.cpp
src/gui/symbol/symmetry_editor.cpp
+9
-1
src/render/symbol/viewer.cpp
src/render/symbol/viewer.cpp
+4
-3
src/resource/msw/mse.rc
src/resource/msw/mse.rc
+1
-0
src/resource/msw/tool/symmetry_remove.png
src/resource/msw/tool/symmetry_remove.png
+0
-0
src/util/window_id.hpp
src/util/window_id.hpp
+1
-0
No files found.
src/data/action/symbol_part.cpp
View file @
80454fce
...
...
@@ -474,7 +474,12 @@ void SymmetryMoveAction::move(const Vector2D& deltaDelta) {
SymmetryTypeAction
::
SymmetryTypeAction
(
SymbolSymmetry
&
symmetry
,
SymbolSymmetryType
type
)
:
symmetry
(
symmetry
),
type
(
type
)
,
old_name
(
symmetry
.
name
)
,
copies
(
symmetry
.
copies
)
{
if
(
type
==
SYMMETRY_REFLECTION
&&
symmetry
.
copies
%
2
==
1
)
{
// make sure it is a multiple of two
copies
=
copies
/
2
*
2
;
}
// update name?
if
(
old_name
==
symmetry
.
expectedName
())
{
swap
(
symmetry
.
kind
,
type
);
...
...
@@ -489,15 +494,21 @@ String SymmetryTypeAction::getName(bool to_undo) const {
void
SymmetryTypeAction
::
perform
(
bool
to_undo
)
{
swap
(
symmetry
.
kind
,
type
);
swap
(
symmetry
.
copies
,
copies
);
swap
(
symmetry
.
name
,
old_name
);
}
// ----------------------------------------------------------------------------- : Change symmetry copies
SymmetryCopiesAction
::
SymmetryCopiesAction
(
SymbolSymmetry
&
symmetry
,
int
copies
)
:
symmetry
(
symmetry
),
copies
(
copies
)
SymmetryCopiesAction
::
SymmetryCopiesAction
(
SymbolSymmetry
&
symmetry
,
int
copies
_
)
:
symmetry
(
symmetry
),
copies
(
copies
_
)
,
old_name
(
symmetry
.
name
)
{
if
(
symmetry
.
kind
==
SYMMETRY_REFLECTION
&&
copies
%
2
==
1
)
{
// make sure it is a multiple of two
if
(
copies
>
symmetry
.
copies
)
copies
++
;
else
copies
--
;
}
// update name?
if
(
old_name
==
symmetry
.
expectedName
())
{
swap
(
symmetry
.
copies
,
copies
);
...
...
src/data/action/symbol_part.hpp
View file @
80454fce
...
...
@@ -210,6 +210,7 @@ class SymmetryTypeAction : public Action {
SymbolSymmetry
&
symmetry
;
SymbolSymmetryType
type
;
String
old_name
;
int
copies
;
/// may be changed to make it a multiple of two
};
// ----------------------------------------------------------------------------- : Change symmetry copies
...
...
src/gui/symbol/part_list.cpp
View file @
80454fce
...
...
@@ -10,6 +10,7 @@
#include <gui/symbol/selection.hpp>
#include <gui/util.hpp>
#include <data/action/symbol.hpp>
#include <data/action/symbol_part.hpp>
#include <gfx/gfx.hpp>
#include <render/symbol/filter.hpp>
#include <util/error.hpp>
...
...
@@ -75,6 +76,16 @@ void SymbolPartList::onAction(const Action& action, bool undone) {
updateParts
(
selection
.
get
());
return
;
}
TYPE_CASE_
(
action
,
SymmetryTypeAction
)
{
if
(
typing_in
)
cursor
=
typing_in
->
name
.
size
();
// can change the name
Refresh
(
false
);
return
;
}
TYPE_CASE_
(
action
,
SymmetryCopiesAction
)
{
if
(
typing_in
)
cursor
=
typing_in
->
name
.
size
();
Refresh
(
false
);
return
;
}
}
wxSize
SymbolPartList
::
DoGetBestSize
()
const
{
...
...
src/gui/symbol/symmetry_editor.cpp
View file @
80454fce
...
...
@@ -57,7 +57,8 @@ void SymbolSymmetryEditor::initUI(wxToolBar* tb, wxMenuBar* mb) {
copies
->
SetHelpText
(
_HELP_
(
"copies"
));
copies
->
SetSize
(
50
,
-
1
);
tb
->
AddSeparator
();
tb
->
AddTool
(
ID_ADD_SYMMETRY
,
_TOOL_
(
"add symmetry"
),
load_resource_tool_image
(
_
(
"symmetry_add"
)),
wxNullBitmap
,
wxITEM_CHECK
,
_TOOLTIP_
(
"add symmetry"
),
_HELP_
(
"add symmetry"
));
tb
->
AddTool
(
ID_ADD_SYMMETRY
,
_TOOL_
(
"add symmetry"
),
load_resource_tool_image
(
_
(
"symmetry_add"
)),
wxNullBitmap
,
wxITEM_CHECK
,
_TOOLTIP_
(
"add symmetry"
),
_HELP_
(
"add symmetry"
));
tb
->
AddTool
(
ID_REMOVE_SYMMETRY
,
_TOOL_
(
"remove symmetry"
),
load_resource_tool_image
(
_
(
"symmetry_remove"
)),
wxNullBitmap
,
wxITEM_CHECK
,
_TOOLTIP_
(
"remove symmetry"
),
_HELP_
(
"remove symmetry"
));
tb
->
AddSeparator
();
tb
->
AddTool
(
ID_SYMMETRY_ROTATION
,
_TOOL_
(
"rotation"
),
load_resource_image
(
_
(
"symmetry_rotation"
)),
wxNullBitmap
,
wxITEM_CHECK
,
_TOOLTIP_
(
"rotation"
),
_HELP_
(
"rotation"
));
tb
->
AddTool
(
ID_SYMMETRY_REFLECTION
,
_TOOL_
(
"reflection"
),
load_resource_image
(
_
(
"symmetry_reflection"
)),
wxNullBitmap
,
wxITEM_CHECK
,
_TOOLTIP_
(
"reflection"
),
_HELP_
(
"reflection"
));
...
...
@@ -72,6 +73,7 @@ void SymbolSymmetryEditor::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
tb
->
DeleteTool
(
ID_SYMMETRY_REFLECTION
);
tb
->
DeleteTool
(
ID_SYMMETRY_ROTATION
);
tb
->
DeleteTool
(
ID_ADD_SYMMETRY
);
tb
->
DeleteTool
(
ID_REMOVE_SYMMETRY
);
// HACK: hardcoded size of rest of toolbar
tb
->
DeleteToolByPos
(
7
);
// delete separator
tb
->
DeleteToolByPos
(
7
);
// delete separator
...
...
@@ -93,6 +95,8 @@ void SymbolSymmetryEditor::onUpdateUI(wxUpdateUIEvent& ev) {
}
}
else
if
(
ev
.
GetId
()
==
ID_ADD_SYMMETRY
)
{
ev
.
Enable
(
true
);
}
else
if
(
ev
.
GetId
()
==
ID_REMOVE_SYMMETRY
)
{
ev
.
Enable
(
symmetry
);
}
else
{
ev
.
Enable
(
false
);
// we don't know about this item
}
...
...
@@ -122,6 +126,10 @@ void SymbolSymmetryEditor::onCommand(int id) {
getSymbol
()
->
actions
.
add
(
new
GroupSymbolPartsAction
(
*
getSymbol
(),
control
.
selected_parts
.
get
(),
symmetry
));
control
.
selected_parts
.
select
(
symmetry
);
control
.
Refresh
(
false
);
}
else
if
(
id
==
ID_REMOVE_SYMMETRY
)
{
getSymbol
()
->
actions
.
add
(
new
UngroupSymbolPartsAction
(
*
getSymbol
(),
control
.
selected_parts
.
get
()));
symmetry
=
SymbolSymmetryP
();
control
.
Refresh
(
false
);
}
}
...
...
src/render/symbol/viewer.cpp
View file @
80454fce
...
...
@@ -129,8 +129,8 @@ void SymbolViewer::combineSymbolPart(DC& dc, const SymbolPart& part, bool& paint
Matrix2D
old_m
=
multiply
;
Vector2D
old_o
=
origin
;
int
copies
=
s
->
kind
==
SYMMETRY_REFLECTION
?
s
->
copies
/
2
*
2
:
s
->
copies
;
if
(
copies
>
1
)
++
in_symmetry
;
FOR_EACH_CONST_REVERSE
(
p
,
s
->
parts
)
{
if
(
copies
>
1
)
++
in_symmetry
;
for
(
int
i
=
copies
-
1
;
i
>=
0
;
--
i
)
{
if
(
i
==
0
)
--
in_symmetry
;
if
(
s
->
clip
)
{
...
...
@@ -323,8 +323,9 @@ void SymbolViewer::highlightPart(DC& dc, const SymbolSymmetry& sym, HighlightSty
// draw 'spokes'
double
angle
=
atan2
(
sym
.
handle
.
y
,
sym
.
handle
.
x
);
dc
.
SetPen
(
wxPen
(
color
,
sym
.
kind
==
SYMMETRY_ROTATION
?
1
:
3
));
for
(
int
i
=
0
;
i
<
sym
.
copies
;
++
i
)
{
double
a
=
angle
+
(
i
+
0.5
)
*
2
*
M_PI
/
sym
.
copies
;
int
copies
=
sym
.
kind
==
SYMMETRY_REFLECTION
?
sym
.
copies
/
2
*
2
:
sym
.
copies
;
for
(
int
i
=
0
;
i
<
copies
;
++
i
)
{
double
a
=
angle
+
(
i
+
0.5
)
*
2
*
M_PI
/
copies
;
Vector2D
dir
(
cos
(
a
),
sin
(
a
));
Vector2D
dir2
=
rotation
.
tr
(
sym
.
center
+
2
*
dir
);
dc
.
DrawLine
(
center
.
x
,
center
.
y
,
dir2
.
x
,
dir2
.
y
);
...
...
src/resource/msw/mse.rc
View file @
80454fce
...
...
@@ -96,6 +96,7 @@ tool/group IMAGE "tool/group.png"
tool/ungroup IMAGE "tool/ungroup.png"
tool/symmetry_add IMAGE "tool/symmetry_add.png"
tool/symmetry_remove IMAGE "tool/symmetry_remove.png"
combine_or IMAGE "../common/combine_or.png"
combine_sub IMAGE "../common/combine_sub.png"
...
...
src/resource/msw/tool/symmetry_remove.png
0 → 100644
View file @
80454fce
316 Bytes
src/util/window_id.hpp
View file @
80454fce
...
...
@@ -158,6 +158,7 @@ enum ChildMenuID {
,
ID_SYMMETRY_REFLECTION
,
ID_SYMMETRY_MAX
,
ID_ADD_SYMMETRY
,
ID_REMOVE_SYMMETRY
,
ID_COPIES
// On cards panel
...
...
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