Exemplo n.º 1
0
void SelectInstance::on_avahi_changed() {
    std::vector<Glib::ustring> r;
    av.get_service_names(r);
    if (!win->is_visible()) {
	if (r.size() == 1) {
	    av.invoke_resolver(*r.begin());
	} else {
	    if (splash) {
		splash->hide();
	    }
	    win->show();
	}
    }
    Glib::RefPtr<Gtk::ListStore> ls = Glib::RefPtr<Gtk::ListStore>::cast_dynamic(view->get_model());
    Gtk::TreeIter s = view->get_selection()->get_selected();
    Glib::ustring old;
    if (s) {
	old = s->get_value(cols.name);
    }
    ls->clear();
    for (std::vector<Glib::ustring>::iterator i = r.begin(); i != r.end(); ++i) {
	Gtk::TreeIter j = ls->append();
	j->set_value(cols.name, *i);
	if (old.empty()) {
	    old = *i;
	}
	if (old == *i) {
	    view->get_selection()->select(j);
	}
    }
}
Exemplo n.º 2
0
void VRGuiNav::on_preset_changed() {
    auto scene = VRSceneManager::getCurrent();
    if (scene == 0) return;
    VRNavPreset* preset = scene->getNavigation(getComboboxText("combobox5"));
    if (preset == 0) return;

    //get binding type liststore
    Glib::RefPtr<Gtk::ListStore> store = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object("binding_types"));

    //TODO: get all bindings from preset && update nav_bindings
    navBindings_store->clear();
    for (auto& b : *preset) {
        string cb_name;
        if (b.cb) cb_name = b.cb->getName();

        string type = "Event";
        if (b.doRepeat) type = "State";

        Gtk::ListStore::Row row = *navBindings_store->append();
        gtk_list_store_set (navBindings_store->gobj(), row.gobj(), 0, b.key, -1);
        gtk_list_store_set (navBindings_store->gobj(), row.gobj(), 1, b.state, -1);
        gtk_list_store_set (navBindings_store->gobj(), row.gobj(), 2, type.c_str(), -1);
        gtk_list_store_set (navBindings_store->gobj(), row.gobj(), 3, cb_name.c_str(), -1);
        gtk_list_store_set (navBindings_store->gobj(), row.gobj(), 4, NULL, -1);
    }
}
void ModelFctDetailAdapterModelImpl::updateTreeModel(Glib::RefPtr<
    ModelFctDetailTreeStore> TreeModel)
{
  TreeModel->clear();
  TreeModel->createTitleRows();
  TreeModel->extractItems(mp_Signature->Signature);
}
Exemplo n.º 4
0
void fillStringListstore(string ls, vector<string> list) {
    Glib::RefPtr<Gtk::ListStore> store = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object(ls.c_str()));
    store->clear();
    for (unsigned int i=0; i<list.size(); i++) {
        Gtk::ListStore::Row row = *store->append();
        gtk_list_store_set (store->gobj(), row.gobj(), 0, list[i].c_str(), -1);
    }
}
Exemplo n.º 5
0
void Dialog_Preview::set_preview(etl::handle<Preview> prev)
{
	//!Check if the window we want draw is ready
	Glib::RefPtr<Gdk::Window> window = get_window();
	if(window) window.clear();

	preview.set_preview(prev);
	//preview.update();
}
Exemplo n.º 6
0
void ClassificationCell::on_realize()
{
  Gtk::DrawingArea::on_realize();

  Glib::RefPtr<Gdk::Window> window = get_window();
  gc = Gdk::GC::create(window);
  window->set_background(white);
  window->clear();
  gc->set_foreground(black);
}
Exemplo n.º 7
0
void RegionChooser::on_realize()
{
    // We need to call the base on_realize()
    Gtk::DrawingArea::on_realize();

    // Now we can allocate any additional resources we need
    Glib::RefPtr<Gdk::Window> window = get_window();
    gc = Gdk::GC::create(window);
    window->clear();
}
Exemplo n.º 8
0
void on_refresh_threads_clicked(Glib::RefPtr<Gtk::ListStore> m_threads_tree_model) {
	///To be executed when the refresh button is clicked while viewing the thread list
	
	m_threads_tree_model->clear();
	getThreadData(m_threads_tree_model);
	webkit_web_view_load_uri(pWebKitView, "about:blank");
	
	Gtk::ScrolledWindow *scroll = 0;
	builder->get_widget("scrolledwindow2", scroll);
	scroll->get_vadjustment()->set_value(0);
}
Exemplo n.º 9
0
void VRConceptWidget::update() {
    Glib::RefPtr<Gtk::TreeStore> treestore = Glib::RefPtr<Gtk::TreeStore>::cast_dynamic( treeview->get_model() );

    treestore->clear();
    for (auto p : concept->properties) {
        Gtk::TreeModel::iterator i = treestore->append();
        if (selected_property && p.second->getName() == selected_property->getName())
            setPropRow(i, p.second->getName(), p.second->type, "green", 1);
        else setPropRow(i, p.second->getName(), p.second->type, "black", 0);
    }
}
Exemplo n.º 10
0
// scene updated, get cameras and nav presets
void VRGuiBits::update() {
    // update camera liststore
    VRScene* scene = VRSceneManager::get()->getActiveScene();
    setLabel("label24", "Project: None");
    if (scene == 0) return;

    vector<VRCamera*> cams = scene->getCameraMap();
    Glib::RefPtr<Gtk::ListStore> store = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object("cameras"));
    store->clear();
    int active;
    for (uint i=0; i<cams.size(); i++) {
        if (cams[i] == scene->getActiveCamera()) active = i;
        Gtk::ListStore::Row row = *store->append();
        gtk_list_store_set (store->gobj(), row.gobj(), 0, cams[i]->getName().c_str(), -1);
    }

    // set active cam active
    Gtk::ComboBox* cb;
    VRGuiBuilder()->get_widget("combobox4", cb);
    cb->set_active(active);

    // update nav_presets liststore
    map<string, VRNavPreset*>::iterator itr;
    map<string, VRNavPreset*> presets = scene->getPresets();
    store = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object("nav_presets"));
    store->clear();
    for (itr = presets.begin(); itr != presets.end(); itr++) {
        Gtk::ListStore::Row row = *store->append();
        gtk_list_store_set (store->gobj(), row.gobj(), 0, itr->first.c_str(), -1);
        //if (itr->second) itr->second->setScene(scene);
    }

    // set first element active
    VRGuiBuilder()->get_widget("combobox9", cb);
    cb->set_active(0);

    // update setup and project label
    cout << " now running: " << scene->getName() << endl;
    setLabel("label24", "Project: " + scene->getName());
}
Exemplo n.º 11
0
void VRGuiBits_on_internal_update(int i) {
    VRInternalMonitor* mnr = VRInternalMonitor::get();
    Glib::RefPtr<Gtk::ListStore> store = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object("liststore4"));
    store->clear();

    map<string, string> vars = mnr->getVariables();
    map<string, string>::iterator itr;
    for (itr = vars.begin(); itr != vars.end(); itr++) {
        Gtk::ListStore::Row row = *store->append();
        gtk_list_store_set (store->gobj(), row.gobj(), 0, itr->first.c_str(), -1);
        gtk_list_store_set (store->gobj(), row.gobj(), 1, itr->second.c_str(), -1);
    }
}
Exemplo n.º 12
0
void ApplicationModel::releaseApplication(void)
{
    //First, delteing all arrows
    for(int k=0; k<this->get_n_children(); k++)
        for(int j=0; j<this->get_n_children(); j++)
        {
            Glib::RefPtr<ArrowModel> arw = Glib::RefPtr<ArrowModel>::cast_dynamic(this->get_child(j));
            if(arw)
            {
                int id = this->find_child(arw);
                if(id != -1)
                    this->remove_child(id);
                 arw.clear();
            }
        }
}
Exemplo n.º 13
0
void getPostData(Glib::RefPtr<Gtk::ListStore> m_threads_tree_model) {
	///Get the post data as JSON, and then push it onto the ListStore given in m_threads_tree_model
	
	Json::Value json = getPosts(BOARD, THREAD);
	m_threads_tree_model->clear();
	Json::Value posts = json["posts"];
	for(int i=0;i<posts.size();++i) {
		Gtk::TreeModel::Row row = *(m_threads_tree_model->append());
		
		string text = standardPostFormatting(posts[i]);
		row[m_post_list.text] = text;
		row[m_post_list.tim] = posts[i]["tim"].asString();
		row[m_post_list.ext] = trim(posts[i]["ext"].asString());
		
		ostringstream convert2;
		convert2 << posts[i]["no"].asInt();
		row[m_post_list.no] = convert2.str();
		
		row[m_post_list.file] = posts[i].isMember("filename") ? 1 : 0;
		
		if(posts[i].isMember("filename")) {
			row[m_post_list.fn] = posts[i]["filename"].asString();
		}
		
		boost::regex double_meme_arrows("(&gt;&gt;(?!&gt;)\\d{1,})");
		string curPost = stripBreaks(posts[i]["com"].asString());
		boost::sregex_token_iterator iter(curPost.begin(), curPost.end(), double_meme_arrows, 0);
		boost::sregex_token_iterator end;
		
		boost::regex actual_arrows("&gt;&gt;");
		string tool = "";
		for( ; iter != end; ++iter ) {
			string s = boost::regex_replace(string(*iter), actual_arrows, "");
			int s2 = atoi(s.c_str());
			for(int j=0;j<posts.size();++j) {
				if(posts[j]["no"].asInt() == s2) {
					tool = tool+"<b>"+*iter+"</b>\n"+stripTags(posts[j]["com"].asString())+"\n\n";
					break;
				}
			}
		}
		
		row[m_post_list.tool] = trim(tool);
	}
}
Exemplo n.º 14
0
void Mediator::redraw()
{
  Glib::RefPtr<Gdk::Window> Window = mref_DrawingArea.get_window();

  if (Window)
  {
    Window->clear();

    if (!m_Layers.empty())
    {
      Cairo::RefPtr<Cairo::Context> Context = Window->create_cairo_context();
      Gtk::Allocation allocation = mref_DrawingArea.get_allocation();
      const int width = allocation.get_width();
      const int height = allocation.get_height();

      Context->rectangle(0, 0, width, height);
      Context->clip();
      Context->set_antialias(Cairo::ANTIALIAS_SUBPIXEL);
      Context->scale(mref_DrawingArea.getScale(), -mref_DrawingArea.getScale());
      Context->translate(-mref_DrawingArea.getXTranslate(),
          -mref_DrawingArea.getYTranslate());
      std::vector<Layer*>::reverse_iterator rit;
      for (rit = m_Layers.rbegin(); rit < m_Layers.rend(); ++rit)
      {
        if ((*rit)->getIsDisplay())
        {
          (*rit)->initialiseLayerContext(Context, mref_DrawingArea.getScale());
          if ((*rit)->getClassName() == m_SelectedClassName)
          {
            (*rit)->draw(Context, mref_DrawingArea.getScale(),
                m_SelectedUnitIds, (*rit)->getDisplayID());
          }
          else
          {
            std::set<int> tempVoidVector;
            (*rit)->draw(Context, mref_DrawingArea.getScale(), tempVoidVector,
                (*rit)->getDisplayID());
          }
        }
      }
    }
  }
}
Exemplo n.º 15
0
bool ClassificationCell::on_expose_event(GdkEventExpose *e)
{
  char buf[10];
  sprintf (buf, "%.0f", round(value));

  //  std::stringstream buf;
  //buf.precision(0);
  //buf.setf(std::ios::fixed, std::ios::floatfield);
  int w=0, h=0;

  Glib::RefPtr<Gdk::Window> window = get_window();
  if (value > 50.0)
    window->set_background(green);
  else if (value > 25.0)
    window->set_background(lightgreen);
  else if (value > 0.05)
    window->set_background(lightred);
  else
    window->set_background(white);

  window->clear();
  window->draw_rectangle(gc, false, 0, 0, 39, 29);

  //  buf << value;
  
  
  //  printf ("string %s\n", buf.str().c_str());

  Glib::RefPtr<Pango::Layout> p = create_pango_layout(Glib::ustring(buf));
  p->set_alignment(Pango::ALIGN_CENTER);
  p->get_pixel_size(w, h);
  int nx = (40-w) / 2 + 1;
  int ny = (30-h) / 2 + 1;
  window->draw_layout(gc, nx, ny, p);
  window->invalidate_rect(Gdk::Rectangle(0,0,40,30), false);
  
  return true;
}
Exemplo n.º 16
0
void VRGuiNav_on_preset_changed(GtkComboBox* cb, gpointer data) {
    VRNavPreset* preset = VRSceneManager::get()->getActiveScene()->getPreset(getComboboxText("combobox5"));
    if (preset == 0) return;

    //get binding type liststore
    Glib::RefPtr<Gtk::ListStore> store = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object("binding_types"));

    //TODO: get all bindings from preset and update nav_bindings
    navBindings_store->clear();
    for (uint i=0; i<preset->getBindings().size(); i++) {
        VRNavBinding b = preset->getBindings()[i];

        string type = "Event";
        if (b.doRepeat) type = "State";

        Gtk::ListStore::Row row = *navBindings_store->append();
        gtk_list_store_set (navBindings_store->gobj(), row.gobj(), 0, b.key, -1);
        gtk_list_store_set (navBindings_store->gobj(), row.gobj(), 1, b.state, -1);
        gtk_list_store_set (navBindings_store->gobj(), row.gobj(), 2, type.c_str(), -1);
        gtk_list_store_set (navBindings_store->gobj(), row.gobj(), 3, b.cb->getName().c_str(), -1);
        gtk_list_store_set (navBindings_store->gobj(), row.gobj(), 4, NULL, -1);
    }
}
Exemplo n.º 17
0
void on_refresh_posts_clicked(Glib::RefPtr<Gtk::ListStore> m_threads_tree_model) {
	///To be executed when the refresh button is clicked while viewing a thread
	
	Gtk::Spinner *spin = 0;
	builder->get_widget("spinner1", spin);
	spin->show();
	spin->set_visible(true);
	
	Gtk::TreeView *tree = 0;
	builder->get_widget("treeview4", tree);
	tree->hide();
	tree->set_visible(false);
	
	m_threads_tree_model->clear();
	getPostData(m_threads_tree_model);
	webkit_web_view_load_uri(pWebKitView, "about:blank");
	
	spin->hide();
	spin->set_visible(false);
	
	tree->show();
	tree->set_visible(true);
}
Exemplo n.º 18
0
void VRGuiNet_updateList() {
    auto scene = VRSceneManager::getCurrent();
    if (scene == 0) return;

    // update script list
    Glib::RefPtr<Gtk::ListStore> store = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object("Sockets"));
    store->clear();

    map<string, VRSocket*> sockets = scene->getSockets();
    map<string, VRSocket*>::iterator itr;
    for (itr = sockets.begin(); itr != sockets.end(); itr++) {
        Gtk::ListStore::Row row = *store->append();
        VRSocket* socket = itr->second;
        gtk_list_store_set(store->gobj(), row.gobj(), 0, socket->getType().c_str(), -1);
        gtk_list_store_set(store->gobj(), row.gobj(), 1, socket->getPort(), -1);
        gtk_list_store_set(store->gobj(), row.gobj(), 2, socket->getIP().c_str(), -1);
        gtk_list_store_set(store->gobj(), row.gobj(), 3, socket->getCallback().c_str(), -1);
        gtk_list_store_set(store->gobj(), row.gobj(), 4, socket->getSignal()->getName().c_str(), -1);
        gtk_list_store_set(store->gobj(), row.gobj(), 5, socket->getName().c_str(), -1);
        gtk_list_store_set(store->gobj(), row.gobj(), 6, socket, -1);
        gtk_list_store_set(store->gobj(), row.gobj(), 7, socket->isClient(), -1);
    }
}
Exemplo n.º 19
0
bool RegionChooser::on_expose_event(GdkEventExpose* event)
{
    Glib::RefPtr<Gdk::Window> window = get_window();
    window->clear();
    const int h = KEYBOARD_HEIGHT;
    const int w = get_width() - 1;
    const int bh = int(h * 0.55);

    Glib::RefPtr<const Gdk::GC> black = get_style()->get_black_gc();
    Glib::RefPtr<const Gdk::GC> white = get_style()->get_white_gc();

    window->draw_rectangle(black, false, 0, h1, w, h - 1);
    gc->set_foreground(grey1);
    int x1 = int(w * 20.5 / 128.0 + 0.5);
    int x2 = int(w * 109.5 / 128.0 + 0.5);
    window->draw_rectangle(gc, true, 1, h1 + 1,
                           x1 - 1, h - 2);
    window->draw_rectangle(white, true, x1 + 1, h1 + 1, x2 - x1 - 1, h - 2);
    window->draw_rectangle(gc, true, x2 + 1, h1 + 1,
                           w - x2 - 1, h - 2);
    for (int i = 0 ; i < 128 ; i++) {
        int note = (i + 3) % 12;
        int x = int(w * i / 128.0 + 0.5);

        if (note == 1 || note == 4 || note == 6 || note == 9 || note == 11) {
            int x2 = int(w * (i + 0.5) / 128.0 + 0.5);
            window->draw_line(black, x2, h1 + bh, x2, h1 + h);

            int x3 = int(w * (i + 1) / 128.0 + 0.5);
            window->draw_rectangle(black, true, x, h1 + 1, x3 - x + 1, bh);
        } else if (note == 3 || note == 8) {
            window->draw_line(black, x, h1 + 1, x, h1 + h);
        }
        if (note == 3) draw_digit(i);
    }

    if (instrument) {
        int i = 0;
        gig::Region *next_region;
        int x3 = -1;
        for (gig::Region *r = regions.first() ; r ; r = next_region) {

            if (x3 < 0) x3 = int(w * (r->KeyRange.low) / 128.0 + 0.5);
            next_region = regions.next();
            if (!next_region || r->KeyRange.high + 1 != next_region->KeyRange.low) {
                int x2 = int(w * (r->KeyRange.high + 1) / 128.0 + 0.5);
                window->draw_line(black, x3, 0, x2, 0);
                window->draw_line(black, x3, h1 - 1, x2, h1 - 1);
                window->draw_line(black, x2, 1, x2, h1 - 2);
                window->draw_rectangle(white, true, x3 + 1, 1, x2 - x3 - 1, h1 - 2);
                x3 = -1;
            }
            i++;
        }

        for (gig::Region *r = regions.first() ; r ; r = regions.next()) {
            int x = int(w * (r->KeyRange.low) / 128.0 + 0.5);
            window->draw_line(black, x, 1, x, h1 - 2);
        }

        if (region) {
            int x1 = int(w * (region->KeyRange.low) / 128.0 + 0.5);
            int x2 = int(w * (region->KeyRange.high + 1) / 128.0 + 0.5);
            gc->set_foreground(red);
            window->draw_rectangle(gc, true, x1 + 1, 1, x2 - x1 - 1, h1 - 2);
        }
    }
    return true;
}
Exemplo n.º 20
0
bool DimRegionChooser::on_expose_event(GdkEventExpose* event)
{
    if (!region) return true;

    // This is where we draw on the window
    Glib::RefPtr<Gdk::Window> window = get_window();
    Glib::RefPtr<Pango::Context> context = get_pango_context();

    Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context);

    window->clear();

    // draw labels on the left (reflecting the dimension type)
    int y = 0;
    double maxwidth = 0;
    for (int i = 0 ; i < region->Dimensions ; i++) {
        int nbZones = region->pDimensionDefinitions[i].zones;
        if (nbZones) {
            const char* dstr;
            char dstrbuf[10];
            switch (region->pDimensionDefinitions[i].dimension) {
            case gig::dimension_none: dstr="none"; break;
            case gig::dimension_samplechannel: dstr="samplechannel"; break;
            case gig::dimension_layer: dstr="layer"; break;
            case gig::dimension_velocity: dstr="velocity"; break;
            case gig::dimension_channelaftertouch: dstr="channelaftertouch"; break;
            case gig::dimension_releasetrigger: dstr="releasetrigger"; break;
            case gig::dimension_keyboard: dstr="keyboard"; break;
            case gig::dimension_roundrobin: dstr="roundrobin"; break;
            case gig::dimension_random: dstr="random"; break;
            case gig::dimension_smartmidi: dstr="smartmidi"; break;
            case gig::dimension_roundrobinkeyboard: dstr="roundrobinkeyboard"; break;
            case gig::dimension_modwheel: dstr="modwheel"; break;
            case gig::dimension_breath: dstr="breath"; break;
            case gig::dimension_foot: dstr="foot"; break;
            case gig::dimension_portamentotime: dstr="portamentotime"; break;
            case gig::dimension_effect1: dstr="effect1"; break;
            case gig::dimension_effect2: dstr="effect2"; break;
            case gig::dimension_genpurpose1: dstr="genpurpose1"; break;
            case gig::dimension_genpurpose2: dstr="genpurpose2"; break;
            case gig::dimension_genpurpose3: dstr="genpurpose3"; break;
            case gig::dimension_genpurpose4: dstr="genpurpose4"; break;
            case gig::dimension_sustainpedal: dstr="sustainpedal"; break;
            case gig::dimension_portamento: dstr="portamento"; break;
            case gig::dimension_sostenutopedal: dstr="sostenutopedal"; break;
            case gig::dimension_softpedal: dstr="softpedal"; break;
            case gig::dimension_genpurpose5: dstr="genpurpose5"; break;
            case gig::dimension_genpurpose6: dstr="genpurpose6"; break;
            case gig::dimension_genpurpose7: dstr="genpurpose7"; break;
            case gig::dimension_genpurpose8: dstr="genpurpose8"; break;
            case gig::dimension_effect1depth: dstr="effect1depth"; break;
            case gig::dimension_effect2depth: dstr="effect2depth"; break;
            case gig::dimension_effect3depth: dstr="effect3depth"; break;
            case gig::dimension_effect4depth: dstr="effect4depth"; break;
            case gig::dimension_effect5depth: dstr="effect5depth"; break;
            default:
                sprintf(dstrbuf, "%d",
                        region->pDimensionDefinitions[i].dimension);
                dstr = dstrbuf;
                break;
            }
            layout->set_text(dstr);

            Pango::Rectangle rectangle = layout->get_logical_extents();
            double text_w = double(rectangle.get_width()) / Pango::SCALE;
            if (text_w > maxwidth) maxwidth = text_w;
            double text_h = double(rectangle.get_height()) / Pango::SCALE;
            Glib::RefPtr<const Gdk::GC> fg = get_style()->get_fg_gc(get_state());
            window->draw_layout(fg, 4, int(y + (h - text_h) / 2 + 0.5), layout);

        }
        y += h;
    }

    // draw dimensions' zones areas
    y = 0;
    int bitpos = 0;
    label_width = int(maxwidth + 10);
    for (int i = 0 ; i < region->Dimensions ; i++) {
        int nbZones = region->pDimensionDefinitions[i].zones;
        if (nbZones) {
            // draw focus rectangle around dimension's label and zones
            if (has_focus() && focus_line == i) {
                Gdk::Rectangle farea(0, y, 150, 20);
                get_style()->paint_focus(window, get_state(), farea, *this, "",
                                         0, y, label_width, 20);
            }

            Glib::RefPtr<const Gdk::GC> black = get_style()->get_black_gc();
            // draw top and bottom lines of dimension's zones
            window->draw_line(black, label_width, y, w - 1, y);
            window->draw_line(black, w - 1, y + h - 1, label_width, y + h - 1);
            // erase whole dimension's zones area
            window->draw_rectangle(get_style()->get_white_gc(), true,
                                   label_width + 1, y + 1, (w - label_width - 2), h - 2);

            int c = 0;
            if (dimregno >= 0) {
                int mask = ~(((1 << region->pDimensionDefinitions[i].bits) - 1) << bitpos);
                c = dimregno & mask; // mask away this dimension
            }
            bool customsplits =
                ((region->pDimensionDefinitions[i].split_type == gig::split_type_normal &&
                 region->pDimensionRegions[c]->DimensionUpperLimits[i]) ||
                (region->pDimensionDefinitions[i].dimension == gig::dimension_velocity &&
                 region->pDimensionRegions[c]->VelocityUpperLimit));

            // draw dimension's zone borders
            if (customsplits) {
                window->draw_line(black, label_width, y + 1, label_width, y + h - 2);
                for (int j = 0 ; j < nbZones ; j++) {
                    gig::DimensionRegion *d = region->pDimensionRegions[c + (j << bitpos)];
                    int upperLimit = d->DimensionUpperLimits[i];
                    if (!upperLimit) upperLimit = d->VelocityUpperLimit;
                    int v = upperLimit + 1;
                    int x = int((w - label_width - 1) * v / 128.0 + 0.5);
                    window->draw_line(black, label_width + x, y + 1, label_width + x, y + h - 2);
                }
            } else {
                for (int j = 0 ; j <= nbZones ; j++) {
                    int x = int((w - label_width - 1) * j / double(nbZones) + 0.5);
                    window->draw_line(black, label_width + x, y + 1, label_width + x, y + h - 2);
                }
            }

            // draw fill for currently selected zone
            if (dimregno >= 0) {
                gc->set_foreground(red);
                int dr = (dimregno >> bitpos) & ((1 << region->pDimensionDefinitions[i].bits) - 1);
                if (customsplits) {
                    int x1 = 0;
                    for (int j = 0 ; j < nbZones ; j++) {
                        gig::DimensionRegion *d = region->pDimensionRegions[c + (j << bitpos)];
                        int upperLimit = d->DimensionUpperLimits[i];
                        if (!upperLimit) upperLimit = d->VelocityUpperLimit;
                        int v = upperLimit + 1;
                        int x2 = int((w - label_width - 1) * v / 128.0 + 0.5);
                        if (j == dr && x1 < x2) {
                            window->draw_rectangle(gc, true, label_width + x1 + 1, y + 1,
                                                   (x2 - x1) - 1, h - 2);
                            break;
                        }
                        x1 = x2;
                    }
                } else {
                    if (dr < nbZones) {
                        int x1 = int((w - label_width - 1) * dr / double(nbZones) + 0.5);
                        int x2 = int((w - label_width - 1) * (dr + 1) / double(nbZones) + 0.5);
                        window->draw_rectangle(gc, true, label_width + x1 + 1, y + 1,
                                               (x2 - x1) - 1, h - 2);
                    }
                }
            }

            y += h;
        }
        bitpos += region->pDimensionDefinitions[i].bits;
    }
Exemplo n.º 21
0
 void clear_window ()
 {
     m_window->clear();
 }
Exemplo n.º 22
0
/* Method XML_to_TreeModel */
bool ClusterSettings::XML_to_TreeModel (const Glib::ustring& filename,
                                Glib::RefPtr<Gtk::ListStore> sensors_store)
{
  /* Create parser */
// TODO validate xml file
  try
  {
    xmlpp::DomParser parser (filename, false);
    if (parser)
    {
      /* Get root node */
      const xmlpp::Node *root_node = parser.get_document  ()->get_root_node ();

      /* Get cluster node and cluster name */
      xmlpp::Node::NodeList cluster_list =
                            root_node->get_children ("Cluster");
      xmlpp::Node::NodeList::iterator cluster_iter = cluster_list.begin ();
      const xmlpp::Element *cluster_node =
                            dynamic_cast<const xmlpp::Element*> (*cluster_iter);
      set_name (cluster_node->get_attribute_value ("name"));

      /* Get sensors */
      xmlpp::Node::NodeList sensors_list =
                            cluster_node->get_children ("Sensor");
      xmlpp::Node::NodeList::iterator sensor_iter;
      Gtk::TreeModel::Row row;
      sensors_store->clear ();
      for (sensor_iter = sensors_list.begin ();
           sensor_iter != sensors_list.end ();
           sensor_iter++)
      {
        const xmlpp::Element *sensor_element =
                            dynamic_cast<const xmlpp::Element*> (*sensor_iter);
        row = *(sensors_store->append ());
        row[m_Columns.m_col_tag] =
                      sensor_element->get_attribute_value ("tag");
        if (!sensor_element->get_attribute_value ("online").compare ("true"))
          row[m_Columns.m_col_online] = true;
        else
          row[m_Columns.m_col_online] = false;
        row[m_Columns.m_col_x] =
                      Glib::Ascii::strtod (
                      sensor_element->get_attribute_value ("x"));
        row[m_Columns.m_col_y] =
                      Glib::Ascii::strtod (
                      sensor_element->get_attribute_value ("y"));
        Glib::ustring tmp = sensor_element->get_attribute_value ("adata");
        row[m_Columns.m_col_adata] = atoi(tmp.c_str ());
        row[m_Columns.m_col_type] =
                      sensor_element->get_attribute_value ("type");
      }
    }
  }
  catch (const std::exception& ex)
  {
    std::cout << "Exception caught: " << ex.what () << std::endl;
    return false;
  }

  /* Return success */
  return true;
}