mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
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:
@@ -116,7 +116,7 @@ Context& DataViewer::getContext() const {
|
||||
Rotation DataViewer::getRotation() const {
|
||||
if (!stylesheet) stylesheet = set->stylesheet;
|
||||
StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet);
|
||||
return Rotation(ss.card_angle(), stylesheet->getCardRect(), ss.card_zoom(), 1.0, ROTATION_ATTACH_TOP_LEFT);
|
||||
return Rotation(deg_to_rad(ss.card_angle()), stylesheet->getCardRect(), ss.card_zoom(), 1.0, ROTATION_ATTACH_TOP_LEFT);
|
||||
}
|
||||
|
||||
Package& DataViewer::getStylePackage() const {
|
||||
|
||||
@@ -151,7 +151,7 @@ void SymbolViewer::combineSymbolPart(DC& dc, const SymbolPart& part, bool& paint
|
||||
}
|
||||
} else if (const SymbolSymmetry* s = part.isSymbolSymmetry()) {
|
||||
// Draw all parts, in reverse order (bottom to top), also draw rotated copies
|
||||
double b = 2 * s->handle.angle();
|
||||
Radians b = 2 * s->handle.angle();
|
||||
Matrix2D old_m = multiply;
|
||||
Vector2D old_o = origin;
|
||||
int copies = s->kind == SYMMETRY_REFLECTION ? s->copies / 2 * 2 : s->copies;
|
||||
@@ -345,11 +345,11 @@ void SymbolViewer::highlightPart(DC& dc, const SymbolSymmetry& sym, HighlightSty
|
||||
// center
|
||||
RealPoint center = rotation.tr(sym.center);
|
||||
// draw 'spokes'
|
||||
double angle = atan2(sym.handle.y, sym.handle.x);
|
||||
Radians angle = atan2(sym.handle.y, sym.handle.x);
|
||||
dc.SetPen(wxPen(color, sym.kind == SYMMETRY_ROTATION ? 1 : 3));
|
||||
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;
|
||||
Radians 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(int(center.x), int(center.y), int(dir2.x), int(dir2.y));
|
||||
|
||||
@@ -19,7 +19,7 @@ void ImageValueViewer::draw(RotatedDC& dc) {
|
||||
DrawWhat what = viewer.drawWhat(this);
|
||||
// reset?
|
||||
int w = max(0,(int)dc.trX(style().width)), h = max(0,(int)dc.trY(style().height));
|
||||
int a = dc.trAngle(0); //% TODO : Add getAngle()?
|
||||
Radians a = dc.getAngle();
|
||||
const AlphaMask& alpha_mask = getMask(w,h);
|
||||
if (bitmap.Ok() && (a != angle || size.width != w || size.height != h)) {
|
||||
bitmap = Bitmap();
|
||||
@@ -46,7 +46,7 @@ void ImageValueViewer::draw(RotatedDC& dc) {
|
||||
is_default = true;
|
||||
if (what & DRAW_EDITING) {
|
||||
bitmap = imagePlaceholder(dc, w, h, image, what & DRAW_EDITING);
|
||||
if (alpha_mask.isLoaded() || a) {
|
||||
if (alpha_mask.isLoaded() || !is_rad0(a)) {
|
||||
image = bitmap.ConvertToImage(); // we need to convert back to an image
|
||||
} else {
|
||||
image = Image();
|
||||
@@ -57,7 +57,7 @@ void ImageValueViewer::draw(RotatedDC& dc) {
|
||||
if (!image.Ok() && !bitmap.Ok() && style().width > 40) {
|
||||
// placeholder bitmap
|
||||
bitmap = imagePlaceholder(dc, w, h, wxNullImage, what & DRAW_EDITING);
|
||||
if (alpha_mask.isLoaded() || a) {
|
||||
if (alpha_mask.isLoaded() || !is_rad0(a)) {
|
||||
// we need to convert back to an image
|
||||
image = bitmap.ConvertToImage();
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ class ImageValueViewer : public ValueViewer {
|
||||
private:
|
||||
Bitmap bitmap; ///< Cached bitmap
|
||||
RealSize size; ///< Size of cached bitmap
|
||||
int angle; ///< Angle of cached bitmap
|
||||
int is_default; ///< Is the default placeholder image used?
|
||||
Radians angle; ///< Angle of cached bitmap
|
||||
bool is_default; ///< Is the default placeholder image used?
|
||||
|
||||
/// Generate a placeholder image
|
||||
static Bitmap imagePlaceholder(const Rotation& rot, UInt w, UInt h, const Image& background, bool editing);
|
||||
|
||||
@@ -36,7 +36,7 @@ RealRect ValueViewer::boundingBox() const {
|
||||
}
|
||||
|
||||
Rotation ValueViewer::getRotation() const {
|
||||
return Rotation(getStyle()->angle, getStyle()->getExternalRect(), 1.0, getStretch());
|
||||
return Rotation(deg_to_rad(getStyle()->angle), getStyle()->getExternalRect(), 1.0, getStretch());
|
||||
}
|
||||
|
||||
bool ValueViewer::setFieldBorderPen(RotatedDC& dc) {
|
||||
|
||||
Reference in New Issue
Block a user