void Designer::extend_track()
{
- use_tool<ExtendTool>();
+ use_tool_with_selected_objects<ExtendTool>();
}
void Designer::connect_tracks()
{
- use_tool<ExtendTool>()->connect();
+ use_tool_with_selected_objects<ExtendTool>()->connect();
}
void Designer::flatten_tracks()
{
- use_tool<SlopeTool>()->flatten();
+ use_tool_with_selected_objects<SlopeTool>()->flatten();
}
void Designer::svg_export()
bool shift = keyboard.get_button_state(Input::KEY_SHIFT_L) || keyboard.get_button_state(Input::KEY_SHIFT_R);
if(key==Msp::Input::KEY_N && shift)
- use_tool<ExtendTool>();
+ use_tool_with_selected_objects<ExtendTool>();
else if(key==Msp::Input::KEY_N)
new_track();
else if(key==Msp::Input::KEY_G)
- use_tool<MoveTool>();
+ use_tool_with_selected_objects<MoveTool>();
else if(key==Msp::Input::KEY_R)
- use_tool<RotateTool>();
+ use_tool_with_selected_objects<RotateTool>();
else if(key==Msp::Input::KEY_D)
{
const set<Object *> &sel_objs = selection.get_objects();
selection.replace(new_objs.begin(), new_objs.end());
- cur_tool = new MoveTool(*this, mouse, selection.get_objects());
+ use_tool_with_selected_objects<MoveTool>();
}
else if(key==Msp::Input::KEY_W)
save();
else if(key==Msp::Input::KEY_M)
use_tool<Measure>();
else if(key==Msp::Input::KEY_Z)
- use_tool<ElevateTool>();
+ use_tool_with_selected_objects<ElevateTool>();
else if(key==Msp::Input::KEY_ESC)
{
if(cur_tool)
}
}
else if(key==Msp::Input::KEY_F)
- use_tool<SlopeTool>()->flatten();
+ use_tool_with_selected_objects<SlopeTool>()->flatten();
else if(key==Msp::Input::KEY_E && shift)
- use_tool<SlopeTool>()->even_slope(true);
+ use_tool_with_selected_objects<SlopeTool>()->even_slope(true);
else if(key==Msp::Input::KEY_E)
- use_tool<SlopeTool>()->even_slope();
+ use_tool_with_selected_objects<SlopeTool>()->even_slope();
else if(key==Msp::Input::KEY_A)
{
if(cur_route)
add_selection_to_zone();
}
else if(key==Msp::Input::KEY_C)
- use_tool<ExtendTool>()->connect();
+ use_tool_with_selected_objects<ExtendTool>()->connect();
else if(key==Msp::Input::KEY_V)
svg_export();
else if(key==Msp::Input::KEY_P)
track_properties();
}
+template<typename T>
+T *Designer::use_tool_with_selected_objects()
+{
+ T *tool = new T(*this, mouse, selection.get_objects());
+ use_tool(tool);
+ return tool;
+}
+
template<typename T>
T *Designer::use_tool()
+{
+ T *tool = new T(*this, mouse);
+ use_tool(tool);
+ return tool;
+}
+
+void Designer::use_tool(Tool *tool)
{
if(cur_tool)
{
cur_tool = 0;
}
- T *tool = new T(*this, mouse, selection.get_objects());
cur_tool = tool;
cur_tool->signal_status.connect(sigc::mem_fun(this, &Designer::manipulation_status));
manipulation_status(cur_tool->get_status());
mode = TOOL;
-
- return tool;
}
void Designer::button_press(unsigned btn)