📄 drawingconfiguration.cpp
字号:
/* GHelm - Nautical Navigation Software * Copyright (C) 2004 Jon Michaelchuck * * This application is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */#include "drawingconfiguration.h"#include "glchartrenderer.h"DrawingConfiguration::DrawingConfiguration(){ set_title("Drawing Configuration"); set_border_width(10); show_all_children();}DrawingConfiguration::~DrawingConfiguration(){}int DrawingConfiguration::Init(Configuration &configuration){ Gtk::Notebook *notebook = manage(new Gtk::Notebook()); Gtk::VBox *vbox = NULL; // avoid compiler warning int i = 0; std::map<int, CVG *>::iterator pit; std::map<int, CVG *>::iterator pend = configuration.point_cvgs.end(); for (pit = configuration.point_cvgs.begin(); pit != pend; ++pit) { if (i == 0) vbox = manage(new Gtk::VBox()); Gtk::CheckButton *button = manage(new Gtk::CheckButton()); button->set_label(configuration.object_num_fullname_map[pit->first]); button->set_active(configuration.points_drawn[pit->first]); button->signal_clicked().connect(sigc::bind<int, Gtk::CheckButton *> (sigc::mem_fun(*this, &DrawingConfiguration::OnPointButtonClicked), pit->first, button)); button->set_sensitive(false); vbox->add(*button); point_check_buttons[pit->first] = button; i++; if (i == 25) { point_hbox.add(*vbox); i = 0; } } notebook->append_page(point_hbox, "Point Features"); i = 0; std::map<int, line_drawprop_t>::iterator it; std::map<int, line_drawprop_t>::iterator end = configuration.line_drawprops.end(); for (it = configuration.line_drawprops.begin(); it != end; ++it) { if (i == 0) vbox = manage(new Gtk::VBox()); Gtk::CheckButton *button = manage(new Gtk::CheckButton()); button->set_label(configuration.object_num_fullname_map[it->first]); button->set_active(configuration.lines_drawn[it->first]); button->signal_clicked().connect(sigc::bind<int, Gtk::CheckButton *> (sigc::mem_fun(*this, &DrawingConfiguration::OnLineButtonClicked), it->first, button)); button->set_sensitive(false); vbox->add(*button); line_check_buttons[it->first] = button; i++; if (i > 25) { line_hbox.pack_start(*vbox); i = 0; } } notebook->append_page(line_hbox, "Line Features"); i = 0; std::map<int, area_drawprop_t>::iterator ait; std::map<int, area_drawprop_t>::iterator aend = configuration.area_drawprops.end(); for (ait = configuration.area_drawprops.begin(); ait != aend; ++ait) { if (i == 0) vbox = manage(new Gtk::VBox()); Gtk::CheckButton *button = manage(new Gtk::CheckButton()); button->set_label(configuration.object_num_fullname_map[ait->first]); button->set_active(configuration.areas_drawn[ait->first]); button->signal_clicked().connect(sigc::bind<int, Gtk::CheckButton *> (sigc::mem_fun(*this, &DrawingConfiguration::OnAreaButtonClicked), ait->first, button)); button->set_sensitive(false); vbox->add(*button); area_check_buttons[ait->first] = button; i++; if (i > 25) { area_hbox.pack_start(*vbox); i = 0; } } notebook->append_page(area_hbox, "Area Features"); add(*notebook); return 0;}void DrawingConfiguration::SetSensitive(Chart *chart){ std::map<int, Gtk::CheckButton *>::iterator it, end; //FIXME why do we need these if clauses for US4NY1GM.000 end = point_check_buttons.end(); for (it = point_check_buttons.begin(); it != end; ++it) { if (it->second) it->second->set_sensitive(false); } end = line_check_buttons.end(); for (it = line_check_buttons.begin(); it != end; ++it) { if (it->second) it->second->set_sensitive(false); } end = area_check_buttons.end(); for (it = area_check_buttons.begin(); it != end; ++it) { if (it->second) it->second->set_sensitive(false); } // FIXME investigate what features are sometimes not accounted for.. // (ie why we need the if clause) if (chart) { std::map<int, std::vector<PointFeature> >::iterator pit, pend; pend = chart->point_features_map.end(); for (pit = chart->point_features_map.begin(); pit != pend; ++pit) { if (point_check_buttons[pit->first]) point_check_buttons[pit->first]->set_sensitive(true); } std::map<int, std::vector<LineFeature> >::iterator lit, lend; lend = chart->line_features_map.end(); for (lit = chart->line_features_map.begin(); lit != lend; ++lit) { if (line_check_buttons[lit->first]) line_check_buttons[lit->first]->set_sensitive(true); } std::map<int, std::vector<AreaFeature> >::iterator ait, aend; aend = chart->area_features_map.end(); for (ait = chart->area_features_map.begin(); ait != aend; ++ait) { if (area_check_buttons[ait->first]) area_check_buttons[ait->first]->set_sensitive(true); } }}void DrawingConfiguration::OnLineButtonClicked(int n, Gtk::CheckButton *cb){ signal_changed.emit(LINE, n, cb->get_active());}void DrawingConfiguration::OnPointButtonClicked(int n, Gtk::CheckButton *cb){ signal_changed.emit(POINT, n, cb->get_active());}void DrawingConfiguration::OnAreaButtonClicked(int n, Gtk::CheckButton *cb){ signal_changed.emit(AREA, n, cb->get_active());}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -