void Designer::new_track()
{
+ if(mode!=SELECT)
+ return;
+
mode = CATALOGUE;
+ lbl_status->set_text("Select new track or press Esc to cancel");
+}
+
+void Designer::erase_tracks()
+{
+ if(mode!=SELECT)
+ return;
+
+ set<Track *> tracks = selection.get_tracks();
+ selection.clear();
+ for(set<Track *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
+ {
+ overlay->clear(layout_3d->get_track(**i));
+ delete *i;
+ }
}
void Designer::track_properties()
{
- if(selection.empty())
+ if(mode!=SELECT || selection.empty())
return;
TrackProperties *track_prop = new TrackProperties(selection);
track_prop->signal_response.connect(sigc::mem_fun(this, &Designer::track_properties_response));
}
+void Designer::extend_track()
+{
+ if(mode!=SELECT)
+ return;
+
+ if(manipulator.start_extend())
+ mode = MANIPULATE;
+}
+
+void Designer::connect_tracks()
+{
+ if(mode!=SELECT)
+ return;
+
+ manipulator.connect();
+}
+
+void Designer::flatten_tracks()
+{
+ if(mode!=SELECT)
+ return;
+
+ manipulator.flatten();
+}
+
void Designer::rename_route()
{
- if(!cur_route)
+ if(mode!=SELECT || !cur_route)
return;
InputDialog *input = new InputDialog(*this, "Route name", cur_route->get_name());
mod = Input::mod_from_sys(mod);
if(key==Msp::Input::KEY_N && (mod&Input::MOD_SHIFT))
- {
- manipulator.start_extend();
- mode = MANIPULATE;
- }
+ extend_track();
else if(key==Msp::Input::KEY_N)
new_track();
else if(key==Msp::Input::KEY_G)
selection.clear();
}
else if(key==Msp::Input::KEY_X)
- {
- set<Track *> tracks = selection.get_tracks();
- selection.clear();
- for(set<Track *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
- {
- overlay->clear(layout_3d->get_track(**i));
- layout->remove_track(**i);
- delete *i;
- }
- }
+ erase_tracks();
else if(key==Msp::Input::KEY_F && (mod&Input::MOD_SHIFT))
{
const set<Track *> &tracks = selection.get_tracks();
}
}
else if(key==Msp::Input::KEY_F)
- manipulator.flatten();
+ flatten_tracks();
else if(key==Msp::Input::KEY_E && (mod&Input::MOD_SHIFT))
manipulator.even_slope(true);
else if(key==Msp::Input::KEY_E)
else if(key==Msp::Input::KEY_A)
add_selection_to_route();
else if(key==Msp::Input::KEY_C)
- manipulator.connect();
+ connect_tracks();
else if(key==Msp::Input::KEY_V)
svg_export();
else if(key==Msp::Input::KEY_P)
Msp::GLtk::Root &get_root() { return root; }
void new_track();
+ void erase_tracks();
void track_properties();
+ void extend_track();
+ void connect_tracks();
+ void flatten_tracks();
void rename_route();
void svg_export();
using namespace Msp;
Layoutbar::Layoutbar(Designer &designer):
- Toolbar("Layout", 120)
+ Toolbar("Layout", 160)
{
GLtk::Button *btn;
pnl_content->add(*(btn = new GLtk::Button("Save")));
btn->set_geometry(GLtk::Geometry(40, 10, 40, 24));
- btn->set_tooltip("Save current layout");
+ btn->set_tooltip("Save current layout (W)");
btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::save));
- pnl_content->add(*(btn = new GLtk::Button("Quit")));
+ pnl_content->add(*(btn = new GLtk::Button("SVG")));
btn->set_geometry(GLtk::Geometry(80, 10, 40, 24));
+ btn->set_tooltip("Export layout as SVG (V)");
+ btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::svg_export));
+
+ pnl_content->add(*(btn = new GLtk::Button("Quit")));
+ btn->set_geometry(GLtk::Geometry(120, 10, 40, 24));
btn->set_style("red");
btn->set_tooltip("Exit Designer");
btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::quit));
mode = ELEVATE;
}
-void Manipulator::start_extend()
+bool Manipulator::start_extend()
{
if(mode)
cancel();
- mode = EXTEND;
+ bool ok = false;
+ const set<Track *> &stracks = selection.get_tracks();
+ for(set<Track *>::const_iterator i=stracks.begin(); (!ok && i!=stracks.end()); ++i)
+ {
+ const vector<Track *> &links = (*i)->get_links();
+ for(vector<Track *>::const_iterator j=links.begin(); (!ok && j!=links.end()); ++j)
+ ok = !*j;
+ }
+
+ if(ok)
+ mode = EXTEND;
+ else
+ signal_status.emit("No free endpoints");
+
+ return ok;
}
void Manipulator::duplicate()
void start_move();
void start_rotate();
void start_elevate();
- void start_extend();
+ bool start_extend();
void duplicate();
void flatten();
void even_slope(bool =false);
pnl_content->add(*(btn = new GLtk::Button("Del")));
btn->set_geometry(GLtk::Geometry(250, 10, 40, 24));
+ btn->set_style("red");
btn->set_tooltip("Delete the current route");
btn->signal_clicked.connect(sigc::mem_fun(this, &Routebar::delete_route_clicked));
pnl_content->add(*(btn = new GLtk::Button("Add")));
btn->set_geometry(GLtk::Geometry(330, 10, 40, 24));
- btn->set_tooltip("Add selected tracks to current route");
+ btn->set_tooltip("Add selected tracks to current route (A)");
btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::add_selection_to_route));
designer.get_layout().signal_route_added.connect(sigc::mem_fun(this, &Routebar::route_added));
using namespace Msp;
Trackbar::Trackbar(Designer &designer):
- Toolbar("Track", 80)
+ Toolbar("Track", 240)
{
GLtk::Button *btn;
- pnl_content->add(*(btn = new GLtk::Button("+Trk")));
+ pnl_content->add(*(btn = new GLtk::Button("New")));
btn->set_geometry(GLtk::Geometry(0, 10, 40, 24));
- btn->set_tooltip("Add a track piece");
+ btn->set_style("green");
+ btn->set_tooltip("Add a track piece (N)");
btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::new_track));
- pnl_content->add(*(btn = new GLtk::Button("Prop")));
+ pnl_content->add(*(btn = new GLtk::Button("Del")));
btn->set_geometry(GLtk::Geometry(40, 10, 40, 24));
- btn->set_tooltip("Change properties of selected tracks");
+ btn->set_style("red");
+ btn->set_tooltip("Delete selected tracks (X)");
+ btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::erase_tracks));
+
+ pnl_content->add(*(btn = new GLtk::Button("Prop")));
+ btn->set_geometry(GLtk::Geometry(80, 10, 40, 24));
+ btn->set_tooltip("Change properties of selected tracks (P)");
btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::track_properties));
+
+ pnl_content->add(*(btn = new GLtk::Button("Xtnd")));
+ btn->set_geometry(GLtk::Geometry(120, 10, 40, 24));
+ btn->set_tooltip("Extend straight track out of free endpoint (Shift+N)");
+ btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::extend_track));
+
+ pnl_content->add(*(btn = new GLtk::Button("Conn")));
+ btn->set_geometry(GLtk::Geometry(160, 10, 40, 24));
+ btn->set_tooltip("Connect free endpoints of selected tracks (C)");
+ btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::connect_tracks));
+
+ pnl_content->add(*(btn = new GLtk::Button("Flat")));
+ btn->set_geometry(GLtk::Geometry(200, 10, 40, 24));
+ btn->set_tooltip("Make selected tracks flat (F)");
+ btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::flatten_tracks));
}