Beispiel #1
0
/*
int RapidXMLInterface::rapidReadFile(const std::string &fileName)
{
	GEOLIB::GEOObjects* geoObjects = _project->getGEOObjects();

	std::ifstream in(fileName.c_str());
	if (in.fail())
	{
		std::cout << "XmlStnInterface::rapidReadFile() - Can't open xml-file." << std::endl;
		return 0;
	}

	// buffer file
	in.seekg(0, std::ios::end);
	size_t length = in.tellg();
	in.seekg(0, std::ios::beg);
	char* buffer = new char[length+1];
	in.read(buffer, length);
	buffer[in.gcount()] = '\0';
	in.close();

	// build DOM tree
	rapidxml::xml_document<> doc;
	doc.parse<0>(buffer);

	// parse content
	if (std::string(doc.first_node()->name()).compare("OpenGeoSysSTN"))
	{
		std::cout << "XmlStnInterface::readFile() - Unexpected XML root." << std::endl;
		return 0;
	}

	// iterate over all station lists
	for (rapidxml::xml_node<>* station_list = doc.first_node()->first_node(); station_list; station_list = station_list->next_sibling())
	{
		std::vector<GEOLIB::Point*>* stations = new std::vector<GEOLIB::Point*>;
		std::string stnName("[NN]");

		stnName = station_list->first_node("name")->value();
		for (rapidxml::xml_node<>* list_item = station_list->first_node(); list_item; list_item = list_item->next_sibling())
		{
			std::string b(list_item->name());
			if (std::string(list_item->name()).compare("stations") == 0)
				XmlStnInterface::rapidReadStations(list_item, stations, fileName);
			if (std::string(list_item->name()).compare("boreholes") == 0)
				XmlStnInterface::rapidReadStations(list_item, stations, fileName);
		}

		if (!stations->empty())
			geoObjects->addStationVec(stations, stnName);
		else
			delete stations;
	}

	doc.clear();
	delete [] buffer;

	return 1;
}
*/
void RapidXMLInterface::readStations(const rapidxml::xml_node<>* station_root, std::vector<GeoLib::Point*> *stations, const std::string &file_name)
{
    for (rapidxml::xml_node<>* station_node = station_root->first_node(); station_node; station_node = station_node->next_sibling())
    {
        if (station_node->first_attribute("id") && station_node->first_attribute("x") && station_node->first_attribute("y"))
        {
            double zVal(0.0);
            if (station_node->first_attribute("z"))
                zVal = strtod(station_node->first_attribute("z")->value(), 0);

            std::string station_name(""), sensor_data_file_name(""), bdate_str("0000-00-00");
            double station_value(0.0), borehole_depth(0.0);
            if (station_node->first_node("name"))
                station_name = station_node->first_node("name")->value();
            if (station_node->first_node("sensordata"))
                sensor_data_file_name = station_node->first_node("sensordata")->value();
            if (station_node->first_node("value"))
                station_value = strtod(station_node->first_node("value")->value(), 0);
            /* add other station features here */

            if (std::string(station_node->name()).compare("station") == 0)
            {
                GeoLib::Station* s = new GeoLib::Station(
                    strtod(station_node->first_attribute("x")->value(), 0),
                    strtod(station_node->first_attribute("y")->value(), 0),
                    zVal,
                    station_name);
                s->setStationValue(station_value);
                if (!sensor_data_file_name.empty())
                    s->addSensorDataFromCSV(BaseLib::copyPathToFileName(sensor_data_file_name, file_name));
                stations->push_back(s);
            }
            else if (std::string(station_node->name()).compare("borehole") == 0)
            {
                if (station_node->first_node("bdepth"))
                    borehole_depth = strtod(station_node->first_node("bdepth")->value(), 0);
                if (station_node->first_node("bdate"))
                    bdate_str = station_node->first_node("bdate")->value();
                /* add other borehole features here */

                GeoLib::StationBorehole* s = GeoLib::StationBorehole::createStation(
                                                 station_name,
                                                 strtod(station_node->first_attribute("x")->value(), 0),
                                                 strtod(station_node->first_attribute("y")->value(), 0),
                                                 zVal,
                                                 borehole_depth,
                                                 bdate_str);
                s->setStationValue(station_value);

                if (station_node->first_node("strat"))
                    RapidXMLInterface::readStratigraphy(station_node->first_node("strat"), s);

                stations->push_back(s);

            }
        }
        else
            std::cout << "XmlStnInterface::rapidReadStations() - Attribute missing in <station> tag ..." << std::endl;
    }
}
Beispiel #2
0
static void
create_plugin(GtkWidget *vbox, gint first_create) {
  GkrellmStyle     *style;
  GkrellmTextstyle *ts, *ts_alt;
  GkrellmMargin    *margin;
  GdkPixmap       *pixmap;
  GdkBitmap       *mask;
  gint            y;
  gint            x;
  gchar *text_utf8 = NULL, *text_locale = NULL;

  if (first_create) {
    panel = gkrellm_panel_new0();
    gkrellm_disable_plugin_connect(plugin_monitor,close_radio);
    /* create the frequency menu */
    create_freq_menu();
  } else
    gkrellm_destroy_decal_list(panel);

  style = gkrellm_meter_style(style_id);

  /* Each GkrellmStyle has two text styles.  The theme designer has picked the
     |  colors and font sizes, presumably based on knowledge of what you draw
     |  on your panel.  You just do the drawing.  You probably could assume
     |  the ts font is larger than the ts_alt font, but again you can be
     |  overridden by the theme designer.
  */
  ts = gkrellm_meter_textstyle(style_id);
  ts_alt = gkrellm_meter_alt_textstyle(style_id);
  panel->textstyle = ts;      /* would be used for a panel label */

  y = 2;			/* some border */
  station_text = gkrellm_create_decal_text(panel, _("Hello World"), ts_alt, style, 2, y, 40);

  /* Create a pixmap decal and place it to the right of station_text.  Use
     |  decals from the builtin decal_misc.xpm.
  */
  pixmap = gkrellm_decal_misc_pixmap();
  mask = gkrellm_decal_misc_mask();

  x = station_text->x + station_text->w + 4;
  decal_onoff_pix = gkrellm_create_decal_pixmap(panel, pixmap, mask,
						N_MISC_DECALS, NULL, x, y);

  /* Configure the panel to hold the above created decals, add in a little
     |  bottom margin for looks, and create the panel.
  */
  gkrellm_panel_configure(panel, NULL, style);
  gkrellm_panel_create(vbox, plugin_monitor,panel);

  /* After the panel is created, the decals can be converted into buttons.
     |  First draw the initial text into the text decal button and then
     |  put the text decal into a meter button.  But for the decal_onoff_pix,
     |  we can directly convert it into a decal button since it is a pixmap
     |  decal.  Just pass the frame we want to be the out image and the
     |  frame for the in or pressed image.
  */
  gkrellm_locale_dup_string(&text_utf8, station_name(radio_getfreq()), &text_locale);
  gkrellm_draw_decal_text(panel, station_text, text_locale,
			  button_state);

  margin = gkrellm_get_style_margins(style);
  gkrellm_put_decal_in_meter_button(panel, station_text, cb_button,
				    GINT_TO_POINTER(1),margin);
  onoff_button = 
    gkrellm_make_decal_button(panel, decal_onoff_pix, cb_button,
			      GINT_TO_POINTER(2),
			      onoff_state ? D_MISC_BUTTON_ON : D_MISC_BUTTON_OUT,
			      D_MISC_BUTTON_IN);

  /* Note: all of the above gkrellm_draw_decal_XXX() calls will not
     |  appear on the panel until a  gkrellm_draw_layers(panel); call is
     |  made.  This will be done in update_plugin(), otherwise we would
     |  make the call here and anytime the decals are changed.
  */

  if (first_create) {
    g_signal_connect(GTK_OBJECT (panel->drawing_area), "expose_event",
		       (GtkSignalFunc) panel_expose_event, NULL);
    g_signal_connect(GTK_OBJECT (panel->drawing_area), "button_release_event",
		       GTK_SIGNAL_FUNC(button_release_event), NULL);
    g_signal_connect(GTK_OBJECT (panel->drawing_area), "scroll_event",
		       GTK_SIGNAL_FUNC(scroll_event), NULL);
    reopen_radio();
  }
  
  gkrellm_draw_panel_layers(panel);
}
Beispiel #3
0
static void set_text_freq(float freq) {
  gchar *text_utf8 = NULL, *text_locale = NULL;
  gkrellm_locale_dup_string(&text_utf8, station_name(freq), &text_locale);
  gkrellm_draw_decal_text(panel, station_text, text_locale, -1);
  gkrellm_draw_panel_layers(panel);
}