Be explicit about type of angles: either Radians or Degrees.

Angles are always doubles.
Internally use radians as much as possible.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1605 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2011-01-09 14:49:59 +00:00
parent a59248ae95
commit 53bbcfe9a9
38 changed files with 248 additions and 195 deletions
+2 -2
View File
@@ -30,7 +30,7 @@ wxSize CardViewer::DoGetBestSize() const {
if (!stylesheet) stylesheet = set->stylesheet;
StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet);
wxSize size(int(stylesheet->card_width * ss.card_zoom()), int(stylesheet->card_height * ss.card_zoom()));
if (sideways(ss.card_angle())) swap(size.x, size.y);
if (is_sideways(deg_to_rad(ss.card_angle()))) swap(size.x, size.y);
return size + ws - cs;
}
return cs;
@@ -143,7 +143,7 @@ Rotation CardViewer::getRotation() const {
if (!stylesheet) stylesheet = set->stylesheet;
StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet);
int dx = GetScrollPos(wxHORIZONTAL), dy = GetScrollPos(wxVERTICAL);
return Rotation(ss.card_angle(), stylesheet->getCardRect().move(-dx,-dy,0,0), ss.card_zoom(), 1.0, ROTATION_ATTACH_TOP_LEFT);
return Rotation(deg_to_rad(ss.card_angle()), stylesheet->getCardRect().move(-dx,-dy,0,0), ss.card_zoom(), 1.0, ROTATION_ATTACH_TOP_LEFT);
}
// ----------------------------------------------------------------------------- : Event table
+6 -6
View File
@@ -493,7 +493,7 @@ void PieGraph::draw(RotatedDC& dc, int current, DrawLayer layer) const {
Color fg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
dc.SetPen(fg);
// draw pies
double angle = M_PI/2;
Radians angle = M_PI/2;
int i = 0;
FOR_EACH_CONST(g, axis.groups) {
// draw pie
@@ -501,7 +501,7 @@ void PieGraph::draw(RotatedDC& dc, int current, DrawLayer layer) const {
if (g.size > 0) {
bool active = i == current;
dc.SetPen(active ? fg : lerp(fg,g.color,0.5));
double end_angle = angle - 2 * M_PI * (double)g.size / axis.total;
Radians end_angle = angle - 2 * M_PI * (double)g.size / axis.total;
dc.DrawEllipticArc(pie_pos, active ? pie_size_large : pie_size, end_angle, angle);
angle = end_angle;
}
@@ -510,7 +510,7 @@ void PieGraph::draw(RotatedDC& dc, int current, DrawLayer layer) const {
// draw spokes
if (axis.groups.size() > 1) {
int i = 0;
double angle = M_PI/2;
Radians angle = M_PI/2;
FOR_EACH_CONST(g, axis.groups) {
if (true) {
int i2 = (i - 1 + (int)axis.groups.size()) % (int)axis.groups.size();
@@ -539,7 +539,7 @@ int PieGraph::findItem(const RealPoint& pos, const RealRect& screen_rect, bool t
double pos_angle = atan2(-delta.y, delta.x) - M_PI/2; // in range [-pi..pi]
if (pos_angle < 0) pos_angle += 2 * M_PI;
// find angle
double angle = 2 * M_PI;
Radians angle = 2 * M_PI;
int i = 0;
FOR_EACH_CONST(g, axis.groups) {
angle -= 2 * M_PI * (double)g.size / axis.total;
@@ -705,14 +705,14 @@ void ScatterPieGraph::draw(RotatedDC& dc, const vector<int>& current, DrawLayer
RealSize radius_s(radius,radius);
RealPoint center(screen_rect.left() + (x+0.5) * size.width + 0.5, screen_rect.bottom() - (y+0.5) * size.height + 0.5);
// draw pie slices
double angle = 0;
Radians angle = 0;
size_t j = 0;
FOR_EACH(g, axis3.groups) {
UInt val = values3D[i * axis3.groups.size() + j++];
if (val > 0) {
dc.SetBrush(g.color);
dc.SetPen(active ? fg : lerp(fg,g.color,0.5));
double end_angle = angle + 2 * M_PI * (double)val / value;
Radians end_angle = angle + 2 * M_PI * (double)val / value;
dc.DrawEllipticArc(center, radius_s, angle, end_angle);
angle = end_angle;
}
+1 -1
View File
@@ -38,7 +38,7 @@ void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
if (!e || e->drawLabel()) {
// draw control border and box
Style& s = *v.getStyle();
draw_control_box(this, dc.getDC(), dc.trRectStraight(s.getInternalRect().grow(1)), current_editor == e, e != nullptr);
draw_control_box(this, dc.getDC(), dc.trRectToBB(s.getInternalRect().grow(1)), current_editor == e, e != nullptr);
// draw label
dc.SetFont(*wxNORMAL_FONT);
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));