mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 21:27:01 -04:00
default smart pointer type switched to intrusive_ptr
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@337 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -178,7 +178,7 @@ void SymbolBasicShapeEditor::makeShape(const Vector2D& a, const Vector2D& b, boo
|
||||
|
||||
// TODO : Move out of this class
|
||||
void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bool constrained) {
|
||||
shape = new_shared<SymbolPart>();
|
||||
shape = new_intrusive<SymbolPart>();
|
||||
// What shape to make?
|
||||
switch (mode) {
|
||||
case ID_SHAPE_CIRCLE: {
|
||||
@@ -191,10 +191,10 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo
|
||||
// a circle has 4 control points, the first is: (x+r, y) db(0, kr) da(0, -kr)
|
||||
// kr is a magic constant
|
||||
const double kr = 0.5522847498f; // = 4/3 * (sqrt(2) - 1)
|
||||
shape->points.push_back(new_shared7<ControlPoint>(c.x + r.x, c.y, 0, kr * r.y, 0, -kr * r.y, LOCK_SIZE));
|
||||
shape->points.push_back(new_shared7<ControlPoint>(c.x, c.y - r.y, kr * r.x, 0, -kr * r.x, 0, LOCK_SIZE));
|
||||
shape->points.push_back(new_shared7<ControlPoint>(c.x - r.x, c.y, 0, -kr * r.y, 0, kr * r.y, LOCK_SIZE));
|
||||
shape->points.push_back(new_shared7<ControlPoint>(c.x, c.y + r.y, -kr * r.x, 0, kr * r.x, 0, LOCK_SIZE));
|
||||
shape->points.push_back(new_intrusive7<ControlPoint>(c.x + r.x, c.y, 0, kr * r.y, 0, -kr * r.y, LOCK_SIZE));
|
||||
shape->points.push_back(new_intrusive7<ControlPoint>(c.x, c.y - r.y, kr * r.x, 0, -kr * r.x, 0, LOCK_SIZE));
|
||||
shape->points.push_back(new_intrusive7<ControlPoint>(c.x - r.x, c.y, 0, -kr * r.y, 0, kr * r.y, LOCK_SIZE));
|
||||
shape->points.push_back(new_intrusive7<ControlPoint>(c.x, c.y + r.y, -kr * r.x, 0, kr * r.x, 0, LOCK_SIZE));
|
||||
break;
|
||||
} case ID_SHAPE_RECTANGLE: {
|
||||
// A rectangle / square
|
||||
@@ -204,10 +204,10 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo
|
||||
shape->name = capitalize(_TYPE_("rectangle"));
|
||||
}
|
||||
// a rectangle just has four corners
|
||||
shape->points.push_back(new_shared2<ControlPoint>(c.x - r.x, c.y - r.y));
|
||||
shape->points.push_back(new_shared2<ControlPoint>(c.x + r.x, c.y - r.y));
|
||||
shape->points.push_back(new_shared2<ControlPoint>(c.x + r.x, c.y + r.y));
|
||||
shape->points.push_back(new_shared2<ControlPoint>(c.x - r.x, c.y + r.y));
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(c.x - r.x, c.y - r.y));
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(c.x + r.x, c.y - r.y));
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(c.x + r.x, c.y + r.y));
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(c.x - r.x, c.y + r.y));
|
||||
break;
|
||||
} default: {
|
||||
// A polygon or star
|
||||
@@ -250,7 +250,7 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo
|
||||
// we can generate points
|
||||
for(int i = 0 ; i < n ; ++i) {
|
||||
double theta = alpha * i;
|
||||
shape->points.push_back(new_shared2<ControlPoint>(
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(
|
||||
c.x + ra * r.x * sin(theta),
|
||||
y - ra * r.y * cos(theta)
|
||||
));
|
||||
@@ -272,13 +272,13 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo
|
||||
for(int i = 0 ; i < n ; ++i) {
|
||||
double theta = alpha * i;
|
||||
// from a
|
||||
shape->points.push_back(new_shared2<ControlPoint>(
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(
|
||||
c.x + ra * r.x * sin(theta),
|
||||
y - ra * r.y * cos(theta)
|
||||
));
|
||||
// from b
|
||||
theta = alpha * (i + 0.5);
|
||||
shape->points.push_back(new_shared2<ControlPoint>(
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(
|
||||
c.x + rb * r.x * sin(theta),
|
||||
y - rb * r.y * cos(theta)
|
||||
));
|
||||
|
||||
@@ -37,22 +37,22 @@ void SymbolControl::switchEditor(const SymbolEditorBaseP& e) {
|
||||
|
||||
void SymbolControl::onChangeSymbol() {
|
||||
selected_parts.clear();
|
||||
switchEditor(new_shared2<SymbolSelectEditor>(this, false));
|
||||
switchEditor(new_intrusive2<SymbolSelectEditor>(this, false));
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
void SymbolControl::onModeChange(wxCommandEvent& ev) {
|
||||
switch (ev.GetId()) {
|
||||
case ID_MODE_SELECT:
|
||||
switchEditor(new_shared2<SymbolSelectEditor>(this, false));
|
||||
switchEditor(new_intrusive2<SymbolSelectEditor>(this, false));
|
||||
break;
|
||||
case ID_MODE_ROTATE:
|
||||
switchEditor(new_shared2<SymbolSelectEditor>(this, true));
|
||||
switchEditor(new_intrusive2<SymbolSelectEditor>(this, true));
|
||||
break;
|
||||
case ID_MODE_POINTS:
|
||||
if (selected_parts.size() == 1) {
|
||||
single_selection = *selected_parts.begin();
|
||||
switchEditor(new_shared2<SymbolPointEditor>(this, single_selection));
|
||||
switchEditor(new_intrusive2<SymbolPointEditor>(this, single_selection));
|
||||
}
|
||||
break;
|
||||
case ID_MODE_SHAPES:
|
||||
@@ -60,7 +60,7 @@ void SymbolControl::onModeChange(wxCommandEvent& ev) {
|
||||
selected_parts.clear();
|
||||
signalSelectionChange();
|
||||
}
|
||||
switchEditor(new_shared1<SymbolBasicShapeEditor>(this));
|
||||
switchEditor(new_intrusive1<SymbolBasicShapeEditor>(this));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ void SymbolControl::onUpdateSelection() {
|
||||
if (single_selection != *selected_parts.begin()) {
|
||||
// begin editing another part
|
||||
single_selection = *selected_parts.begin();
|
||||
editor = new_shared2<SymbolPointEditor>(this, single_selection);
|
||||
editor = new_intrusive2<SymbolPointEditor>(this, single_selection);
|
||||
Refresh(false);
|
||||
}
|
||||
break;
|
||||
@@ -122,14 +122,14 @@ void SymbolControl::onUpdateSelection() {
|
||||
void SymbolControl::selectPart(const SymbolPartP& part) {
|
||||
selected_parts.clear();
|
||||
selected_parts.insert(part);
|
||||
switchEditor(new_shared2<SymbolSelectEditor>(this, false));
|
||||
switchEditor(new_intrusive2<SymbolSelectEditor>(this, false));
|
||||
signalSelectionChange();
|
||||
}
|
||||
|
||||
void SymbolControl::activatePart(const SymbolPartP& part) {
|
||||
selected_parts.clear();
|
||||
selected_parts.insert(part);
|
||||
switchEditor(new_shared2<SymbolPointEditor>(this, part));
|
||||
switchEditor(new_intrusive2<SymbolPointEditor>(this, part));
|
||||
}
|
||||
|
||||
void SymbolControl::signalSelectionChange() {
|
||||
|
||||
@@ -22,7 +22,7 @@ class SymbolControl;
|
||||
* Differrent SymbolEditors represent different tools.
|
||||
* NOTE : Do not confuse with SymbolEditor (a FieldEditor)
|
||||
*/
|
||||
class SymbolEditorBase {
|
||||
class SymbolEditorBase : public IntrusivePtrVirtualBase {
|
||||
protected:
|
||||
/// The control for which we are editing
|
||||
SymbolControl& control;
|
||||
|
||||
Reference in New Issue
Block a user