• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ gdk::Rectangle类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中gdk::Rectangle的典型用法代码示例。如果您正苦于以下问题:C++ Rectangle类的具体用法?C++ Rectangle怎么用?C++ Rectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Rectangle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: insert_bug

  bool BugzillaNoteAddin::insert_bug(int x, int y, const std::string & uri, int id)
  {
    try {
      BugzillaLink::Ptr link_tag = 
        BugzillaLink::Ptr::cast_dynamic(get_note()->get_tag_table()->create_dynamic_tag(TAG_NAME));
      link_tag->set_bug_url(uri);

      // Place the cursor in the position where the uri was
      // dropped, adjusting x,y by the TextView's VisibleRect.
      Gdk::Rectangle rect;
      get_window()->editor()->get_visible_rect(rect);
      x = x + rect.get_x();
      y = y + rect.get_y();
      Gtk::TextIter cursor;
      gnote::NoteBuffer::Ptr buffer = get_buffer();
      get_window()->editor()->get_iter_at_location(cursor, x, y);
      buffer->place_cursor (cursor);

      std::string string_id = boost::lexical_cast<std::string>(id);
      buffer->undoer().add_undo_action (new InsertBugAction (cursor, 
                                                             string_id, 
                                                             link_tag));

      std::vector<Glib::RefPtr<Gtk::TextTag> > tags;
      tags.push_back(link_tag);
      buffer->insert_with_tags (cursor, 
                                string_id, 
                                tags);
      return true;
    } 
    catch (...)
    {
		}
    return false;
  }
开发者ID:haobug,项目名称:gnote,代码行数:35,代码来源:bugzillanoteaddin.cpp


示例2: GlobalMainFrame

// Construct the dialog
LightTextureChooser::LightTextureChooser()
:	gtkutil::BlockingTransientWindow(_("Choose texture"), GlobalMainFrame().getTopLevelWindow()),
	_selector(Gtk::manage(new ShaderSelector(this, getPrefixList(), true))) // true >> render a light texture
{
	// Set the default size of the window
	Gdk::Rectangle rect;

	if (GlobalGroupDialog().getDialogWindow()->is_visible())
	{
		rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalGroupDialog().getDialogWindow());
	}
	else
	{
		rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalMainFrame().getTopLevelWindow());
	}

	set_default_size(static_cast<int>(rect.get_width()*0.6f), static_cast<int>(rect.get_height()*0.6f));

	// Construct main VBox, and pack in ShaderSelector and buttons panel
	Gtk::VBox* vbx = Gtk::manage(new Gtk::VBox(false, 6));

	vbx->pack_start(*_selector, true, true, 0);
	vbx->pack_start(createButtons(), false, false, 0);

	add(*vbx);
}
开发者ID:OpenTechEngine,项目名称:DarkRadiant,代码行数:27,代码来源:LightTextureChooser.cpp


示例3: makeLUT

Gui_DisplayBaseClass::Gui_DisplayBaseClass(Gui_ProcessorHandler& processor_hand):
    m_processor_hand(processor_hand),
    m_deco(this,processor_hand,m_show_idx,m_show_point,m_ROI),
    m_ROI(cv::Point(0,0),cv::Point(0,0)),
    m_draw_result(false),
    m_alph_mask(128),
    m_show_idx(-1),m_show_point(false),m_show_mask(true),
    m_cursor(Gdk::CROSS)
    {

    this->add_events( Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK );
    this->signal_scroll_event().connect( sigc::mem_fun( *this, &Gui_DisplayBaseClass::on_scroll) );
    this->signal_button_press_event().connect( sigc::mem_fun( *this, &Gui_DisplayBaseClass::on_click) );

    m_color.set_rgb_p(0.2,0.2,0.2);
    this->modify_bg(Gtk::STATE_NORMAL,m_color);

    m_processor_hand.signal_state().connect( sigc::mem_fun(*this,&Gui_DisplayBaseClass::myRedraw));

    Glib::RefPtr< Gdk::Screen > screen = Gdk::Screen::get_default();
    Gdk::Rectangle rect;
    screen->get_monitor_geometry(screen->get_primary_monitor(),rect);
    set_size_request(rect.get_width()/4,rect.get_height()/4);



    makeLUT();




}
开发者ID:IsaacLuo,项目名称:OpenCFU,代码行数:32,代码来源:Gui_DisplayBaseClass.cpp


示例4: ChooseEntity

std::string EntityChooser::ChooseEntity(const std::string& preSelectedEntity)
{
	gtkutil::Dialog dlg(_("Select Entity"), GlobalMainFrame().getTopLevelWindow());

	Gdk::Rectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalMainFrame().getTopLevelWindow());

	dlg.set_default_size(static_cast<int>(rect.get_width()/2), static_cast<int>(2*rect.get_height()/3));

	// Instantiate a new chooser class
	EntityChooserPtr chooser(new EntityChooser);
	chooser->setSelectedEntity(preSelectedEntity);

	// add this to the dialog window
	IDialog::Handle handle = dlg.addElement(chooser);

	if (dlg.run() == IDialog::RESULT_OK)
	{
		return dlg.getElementValue(handle);
	}
	else
	{
		// Cancelled
		return "";
	}
}
开发者ID:OpenTechEngine,项目名称:DarkRadiant,代码行数:25,代码来源:EntityChooser.cpp


示例5: drawButton

void ItemView::drawButton(const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Image* image, Gdk::Rectangle rect)
{
    const Glib::RefPtr<Gdk::Pixbuf> icon = image->get_pixbuf();

    const int iconLeft = rect.get_x() + (rect.get_width() * 0.5) - (icon->get_width() * 0.5);
    const int iconTop = rect.get_y() + (rect.get_height() * 0.5) - (icon->get_height() * 0.5);

    Gdk::Cairo::set_source_pixbuf(cr, icon, iconLeft, iconTop);
    cr->rectangle(iconLeft, iconTop, icon->get_width(), icon->get_height());
    cr->fill();
}
开发者ID:pzagawa,项目名称:myagenda,代码行数:11,代码来源:NoteItemView.cpp


示例6: isHit

bool ItemView::isHit(GdkEventButton* event, Gdk::Rectangle& rect)
{
    const int left = rect.get_x();
    const int top = rect.get_y();
    const int right = left + rect.get_width();
    const int bottom = top + rect.get_height();

    if (event->x > left && event->x < right)
        if (event->y > top && event->y < bottom)
            return true;

    return false;}
开发者ID:pzagawa,项目名称:myagenda,代码行数:12,代码来源:NoteItemView.cpp


示例7: change

void LinkHints::change(ElementProperty *prop) {
	bool ch = false;
	Gdk::Rectangle r = prop->parent->drawRect();
	for(iterator h = begin(); h != end(); h++)
		if((*h)->prop == prop) {
			(*h)->updateText();
			ch = true;
		}
	if(ch) {
		r.join(prop->parent->drawRect());
		prop->parent->parent->on_redraw_rect.run(&r);
	}
}
开发者ID:hiasmstudio,项目名称:hiasm5,代码行数:13,代码来源:Element.cpp


示例8:

void sourceview___::scroll2__(SourceView*sv,Gtk::TextIter ti){
	RefPtr<Gtk::TextBuffer> tb=sv->get_buffer();
	tb->place_cursor(ti);
	Gtk::TextBuffer::iterator i1,i2;
	tb->get_selection_bounds(i1,i2);

	Gdk::Rectangle rect;
	sv->get_visible_rect(rect);
	int y = -1;
	int height = -1;
	sv->get_line_yrange(i1, y, height);
	if (y < rect.get_y() + rect.get_height() + 16)
		 sv->scroll_to_mark(tb->get_insert(), 0);
}
开发者ID:zzzzzzzzzzz0,项目名称:zhscript,代码行数:14,代码来源:sourceview___.cpp


示例9: GlobalMainFrame

MD5AnimationViewer::MD5AnimationViewer() :
	gtkutil::BlockingTransientWindow(_("MD5 Animation Viewer"), GlobalMainFrame().getTopLevelWindow()),
	_modelList(Gtk::TreeStore::create(_modelColumns)),
	_modelPopulator(_modelList),
	_animList(Gtk::ListStore::create(_animColumns)),
	_preview(new AnimationPreview)
{
	// Set the default border width in accordance to the HIG
	set_border_width(12);
	set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG);

	// Set the default size of the window
	const Glib::RefPtr<Gtk::Window>& mainWindow = GlobalMainFrame().getTopLevelWindow();

	Gdk::Rectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(mainWindow);
	int height = static_cast<int>(rect.get_height() * 0.6f);

	set_default_size(
		static_cast<int>(rect.get_width() * 0.8f), height
	);

	// Set the default size of the window
	_preview->setSize(rect.get_width() * 0.2f, height);

	// Main dialog vbox
	Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox(false, 12));

	// Create a horizontal box to pack the treeview on the left and the preview on the right
	Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox(false, 6));

	hbox->pack_start(createListPane(), true, true, 0);

	Gtk::VBox* previewBox = Gtk::manage(new Gtk::VBox(false, 0));
	previewBox->pack_start(*_preview, true, true, 0);

	hbox->pack_start(*previewBox, true, true, 0);

	vbox->pack_start(*hbox, true, true, 0);
	vbox->pack_end(createButtons(), false, false, 0);

	// Add main vbox to dialog
	add(*vbox);

	// Populate with model names
	populateModelList();
}
开发者ID:OpenTechEngine,项目名称:DarkRadiant,代码行数:46,代码来源:MD5AnimationViewer.cpp


示例10: GlobalMainFrame

// Create GTK stuff in c-tor
OverlayDialog::OverlayDialog() :
	PersistentTransientWindow(_(DIALOG_TITLE), GlobalMainFrame().getTopLevelWindow(), true),
	_callbackActive(false)
{
	set_border_width(12);

	// Set default size
	Gdk::Rectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalMainFrame().getTopLevelWindow());
	set_default_size(static_cast<int>(rect.get_width()/3), -1);

	// Pack in widgets
	Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox(false, 12));

	vbox->pack_start(createWidgets(), true, true, 0);
	vbox->pack_end(createButtons(), false, false, 0);

	add(*vbox);
}
开发者ID:DerSaidin,项目名称:DarkRadiant,代码行数:19,代码来源:OverlayDialog.cpp


示例11: insert__

int textview___::insert__(std::deque<Glib::ustring>* p,size_t start){
	Gtk::TextView* tv=tv__(p,1+start);
	if(!tv){
		return 1;
	}
	int i=0;
	size_t i_ctl=3+start;
	if(p->size()>i_ctl){
		if((*p)[i_ctl]=="头")
			i=1;
		else if((*p)[i_ctl]=="尾")
			i=2;
		else{
			d_(sh_,err_show_buzhichi_,2,p,i_ctl);
			return 1;
		}
	}
	Glib::RefPtr < Gtk::TextBuffer > tb = tv->get_buffer();
	Gtk::TextBuffer::iterator i1,i2;
	switch(i){
	case 1:
		i1=tb->begin();
		break;
	case 2:
		i1=tb->end();
		break;
	default:
		tb->get_selection_bounds(i1,i2);
		if(i2>i1){
			i1=tb->erase(i1,i2);
		}
		break;
	}
	Gdk::Rectangle rect;
	tv->get_visible_rect(rect);
	int y = -1;
	int height = -1;
	tv->get_line_yrange(i1, y, height);
	tb->place_cursor(tb->insert(i1, (*p)[2+start]));
	if (y < rect.get_y() + rect.get_height() + 16)
		 tv->scroll_to_mark(tb->get_insert(), 0);
	return 1;
}
开发者ID:BGCX261,项目名称:zhscript-svn-to-git,代码行数:43,代码来源:textview___.cpp


示例12: queueDrawIfNeccesary

bool MouseAwareTreeView::queueDrawIfNeccesary(int32_t x, int32_t y, Glib::ustring* pPath)
{
    Gtk::TreeModel::Path mousePath;
    Gtk::TreeViewColumn* pColumn;
    Gdk::Rectangle rect;

    convert_bin_window_to_widget_coords (x, y, m_MouseInfo.x, m_MouseInfo.y);

    if (get_path_at_pos(x, y, mousePath, pColumn, x, y))
    {
        int32_t offsetX, offsetY;
        convert_bin_window_to_widget_coords(0, 0, offsetX, offsetY);

        m_MouseInfo.x -= offsetX;
        m_MouseInfo.y -= offsetY;

        get_cell_area(mousePath, *pColumn, rect);
        queue_draw_area(rect.get_x() + offsetX, rect.get_y() + offsetY, rect.get_width(), rect.get_height());
        if (rect.get_y() != m_CurrentCell)
        {
            m_CurrentCell = rect.get_y();
            m_CellChanged = true;
        }

        if (pPath)
        {
            *pPath = mousePath.to_string();
        }
        return true;
    }

    return false;
}
开发者ID:wwplaygh,项目名称:gejengel,代码行数:33,代码来源:mouseawaretreeview.cpp


示例13: GlobalMainFrame

ParticlesChooser::ParticlesChooser() :
	gtkutil::BlockingTransientWindow(_("Choose particles"), GlobalMainFrame().getTopLevelWindow()),
	_particlesList(Gtk::ListStore::create(COLUMNS())),
	_selectedParticle(""),
	_preview(new gtkutil::ParticlePreview)
{
	set_border_width(12);

	// Set the default size of the window
	const Glib::RefPtr<Gtk::Window>& mainWindow = GlobalMainFrame().getTopLevelWindow();

	Gdk::Rectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(mainWindow);
	int height = static_cast<int>(rect.get_height() * 0.6f);

	set_default_size(
		static_cast<int>(rect.get_width() * 0.4f), height
	);

	// Set the default size of the window
	_preview->setSize(rect.get_width() * 0.2f, height);

	// Main dialog vbox
	Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox(false, 12));

	// Create a horizontal box to pack the treeview on the left and the preview on the right
	Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox(false, 6));

	hbox->pack_start(createTreeView(), true, true, 0);

	Gtk::VBox* previewBox = Gtk::manage(new Gtk::VBox(false, 0));
	previewBox->pack_start(*_preview, true, true, 0);

	hbox->pack_start(*previewBox, true, true, 0);

	vbox->pack_start(*hbox, true, true, 0);
	vbox->pack_end(createButtons(), false, false, 0);

	// Add main vbox to dialog
	add(*vbox);
}
开发者ID:DerSaidin,项目名称:DarkRadiant,代码行数:40,代码来源:ParticlesChooser.cpp


示例14: GlobalMainFrame

// Constructor
SoundChooser::SoundChooser() :
	BlockingTransientWindow(_("Choose sound"), GlobalMainFrame().getTopLevelWindow()),
	_treeStore(Gtk::TreeStore::create(_columns)),
	_treeView(NULL),
	_preview(Gtk::manage(new SoundShaderPreview))
{
	set_border_width(12);
	set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG);

	// Set the default size of the window
	Gdk::Rectangle rect = gtkutil::MultiMonitor::getMonitorForWindow(GlobalMainFrame().getTopLevelWindow());
	set_default_size(rect.get_width() / 2, rect.get_height() / 2);

	// Main vbox
	Gtk::VBox* vbx = Gtk::manage(new Gtk::VBox(false, 12));

    vbx->pack_start(createTreeView(), true, true, 0);
    vbx->pack_start(*_preview, false, false, 0);
    vbx->pack_start(createButtons(), false, false, 0);

    add(*vbx);
}
开发者ID:DerSaidin,项目名称:DarkRadiant,代码行数:23,代码来源:SoundChooser.cpp


示例15: getObjectAtPos

bool LinkHints::getObjectAtPos(gdouble x, gdouble y, ObjectType *obj) {
	for(iterator h = begin(); h != end(); h++) {
		Gdk::Rectangle r = (*h)->drawRect();
		if(x >= r.get_x() && y >= r.get_y() && x <= r.get_x() + r.get_width() && y <= r.get_y() + r.get_height()) {
			*obj = ObjectType(*h);
			return true;
		}
	}
	return false;
}
开发者ID:hiasmstudio,项目名称:hiasm5,代码行数:10,代码来源:Element.cpp


示例16: do_render

void EmblemCellRenderer::do_render(const Cairo::RefPtr<Cairo::Context>& context, int widget, int background_area, Gdk::Rectangle &cell_area, int flags) {
    context->translate(cell_area.get_x(), cell_area.get_y());
    context->rectangle(0, 0, cell_area.get_width(), cell_area.get_height());
    context->clip();

    // TODO: Incorporate padding
    context->push_group();
    if (!this->_icon_name.empty()) {
        Glib::RefPtr<Gdk::Pixbuf> pixbuf = this->_get_pixbuf(this->_icon_name, this->_icon_size);
        context->set_operator(Cairo::OPERATOR_SOURCE);
        // Assumes square icons; may break if we don't get the requested size
        int height_offset = int((cell_area.get_height() - pixbuf->get_height())/2);
        Gdk::Cairo::set_source_pixbuf(context, pixbuf, 0, height_offset);
        context->rectangle(0, height_offset,
                          pixbuf->get_width(), pixbuf->get_height());
        context->fill();

        if (this->_tint_color) {
            Gdk::RGBA* c = this->_tint_color;
            gushort r = c->get_red();
            gushort g = c->get_green();
            gushort b = c->get_blue();
            // Figure out the difference between our tint colour and an
            // empirically determined (i.e., guessed) satisfying luma and
            // adjust the base colours accordingly
            double luma = (r + r + b + g + g + g) / 6.;
            double extra_luma = (1.2 - luma) / 3.;
            r = std::min(r + extra_luma, 1.);
            g = std::min(g + extra_luma, 1.);
            b = std::min(b + extra_luma, 1.);
            context->set_source_rgba(r, g, b, 0.4);
            context->set_operator(Cairo::OPERATOR_ATOP);
            context->paint();
        }

        if (!this->_emblem_name.empty()) {
            Glib::RefPtr<Gdk::Pixbuf> pixbuf = this->_get_pixbuf(this->_emblem_name, this->_emblem_size);
            int x_offset = this->_icon_size - this->_emblem_size;
            context->set_operator(Cairo::OPERATOR_OVER);
            Gdk::Cairo::set_source_pixbuf(context, pixbuf, x_offset, 0);
            context->rectangle(x_offset, 0,
                              cell_area.get_width(), this->_emblem_size);
            context->fill();
        }
    }

    context->pop_group_to_source();
    context->set_operator(Cairo::OPERATOR_OVER);
    context->paint();
}
开发者ID:egore,项目名称:meld,代码行数:50,代码来源:emblemcellrenderer.cpp


示例17: dibujar

bool GraficoDeTorta::dibujar(const Cairo::RefPtr<Cairo::Context>& contexto){
	Gdk::Rectangle rect = dibujo->get_allocation();
	Pango::FontDescription font;
	font.set_family("Monospace");
	font.set_weight(Pango::WEIGHT_BOLD);

	if(stock.size() == 0) return false;
	contexto->set_source_rgb(1.0,1.0,1.0);
	contexto->paint();	
	
	int total = 0;
	for(unsigned int i = 0; i < stock.size(); i++){
		total +=  stock[i].second;
	}
	float step = 2*M_PI/total;
	total = 0;
	

	float angulo0=0;
	for(unsigned int i = 0; i < stock.size(); i++){
		float angulo1 = step*stock[i].second + angulo0;
		dibujarArco(contexto,rect.get_width()/2-rect.get_width()/4,rect.get_height()/2,rect.get_width()<rect.get_height()?rect.get_width()/4:rect.get_height()/4,angulo0,angulo1,red[i],green[i],blue[i]);
		angulo0 = angulo1;
	}
	
	Glib::RefPtr<Pango::Layout> layout;
	std::stringstream s;
	for(unsigned int i = 0; i < stock.size(); i++){
		s.str("");
		s << stock[i].first << "\t" << stock[i].second;
		layout = dibujo->create_pango_layout(s.str());
		layout -> set_font_description(font);
		int t_width, t_height;
		layout->get_pixel_size(t_width,t_height);
		contexto->set_source_rgb(0,0,0);	
		contexto -> move_to((rect.get_width())/2,15*(i+1)+5);
		layout -> show_in_cairo_context(contexto);
		contexto -> set_source_rgb(red[i],green[i],blue[i]);
		contexto -> rectangle(rect.get_width()/2+80,15*(i+1)+5,30,15);
		contexto -> fill();
	}
	return true;
}
开发者ID:horacioMartinez,项目名称:facultad,代码行数:43,代码来源:graficoDeTorta.cpp


示例18:

GazeTrackerGtk::GazeTrackerGtk(int argc, char **argv):
	_picture(argc, argv),
	_vbox(false, 0),
	_buttonBar(true, 0),
	_calibrateButton("Calibrate"),
	_loadButton("Load points"),
	_saveButton("Save points"),
	_chooseButton("Choose points"),
	_pauseButton("Pause"),
	_clearButton("Clear points"),
	_testButton("Test")
{
	try {
		set_title("opengazer 0.1.1");

		Glib::RefPtr<Gdk::Screen> screen = Gdk::Display::get_default()->get_default_screen();
		Gdk::Rectangle rect;
		screen->get_monitor_geometry(Gdk::Screen::get_default()->get_n_monitors() - 1, rect);

		set_size_request(rect.get_width(), rect.get_height());
		move(0, 0);

		// Construct view
		add(_vbox);

		_vbox.pack_start(_buttonBar, false, true, 0);
		_vbox.pack_start(_picture);

		_buttonBar.pack_start(_chooseButton);
		_buttonBar.pack_start(_clearButton);
		_buttonBar.pack_start(_calibrateButton);
		_buttonBar.pack_start(_testButton);
		_buttonBar.pack_start(_pauseButton);
		_buttonBar.pack_start(_saveButton);
		_buttonBar.pack_start(_loadButton);

		// Connect buttons
		_calibrateButton.signal_clicked().connect(sigc::mem_fun(&_picture.gazeTracker, &MainGazeTracker::startCalibration));
		_testButton.signal_clicked().connect(sigc::mem_fun(&_picture.gazeTracker, &MainGazeTracker::startTesting));
		_saveButton.signal_clicked().connect(sigc::mem_fun(&_picture.gazeTracker, &MainGazeTracker::savePoints));
		_loadButton.signal_clicked().connect(sigc::mem_fun(&_picture.gazeTracker, &MainGazeTracker::loadPoints));
		_chooseButton.signal_clicked().connect(sigc::mem_fun(&_picture.gazeTracker, &MainGazeTracker::choosePoints));
		_pauseButton.signal_clicked().connect(sigc::mem_fun(&_picture.gazeTracker, &MainGazeTracker::pauseOrRepositionHead));
		_pauseButton.signal_clicked().connect(sigc::mem_fun(this, &GazeTrackerGtk::changePauseButtonText));
		_clearButton.signal_clicked().connect(sigc::mem_fun(&_picture.gazeTracker, &MainGazeTracker::clearPoints));

		// Display view
		_vbox.show();
		_buttonBar.show();
		_picture.show();
		_calibrateButton.show();
		//_saveButton.show();
		//_loadButton.show();
		_chooseButton.show();
		_pauseButton.show();
		_clearButton.show();
		_testButton.show();
	}
	catch (Utils::QuitNow) {
		std::cout << "Caught it!\n";
	}
}
开发者ID:leokoppel,项目名称:OpenGazer,代码行数:62,代码来源:GazeTrackerGtk.cpp


示例19:

inline bool operator==(const Gdk::Rectangle& a, const Gdk::Rectangle& b)
{
  return a.get_x()==b.get_x() && a.get_y()==b.get_y() && a.get_width()==b.get_width() && a.get_height()==b.get_height();
}
开发者ID:MrBr3,项目名称:Space-Deminer,代码行数:4,代码来源:dependencies.hpp


示例20: calculateTrainingErrors

void GazeTracker::calculateTrainingErrors() {
	int numMonitors = Gdk::Screen::get_default()->get_n_monitors();
	Gdk::Rectangle monitorGeometry;
	Glib::RefPtr<Gdk::Screen> screen = Gdk::Display::get_default()->get_default_screen();

	// Geometry of main monitor
	screen->get_monitor_geometry(numMonitors - 1, monitorGeometry);

	std::vector<Point> points = getSubVector(_calTargets, &CalTarget::point);

	//std::cout << "Input count: " << _inputCount;
	//std::cout << ", Target size: " << _calTargets.size() << std::endl;

	for (int i = 0; i < _calTargets.size(); i++) {
		double xTotal = 0;
		double yTotal = 0;
		double sampleCount = 0;

		//std::cout << points[i].x << ", " << points[i].y << " x " << allOutputCoords[j][0] << ", " << allOutputCoords[j][1] << std::endl;

		int j = 0;
		while (j < _inputCount && points[i].x == allOutputCoords[j][0] && points[i].y == allOutputCoords[j][1]) {
			double xEstimate = (_gaussianProcessX->getmean(Utils::SharedImage(allImages[j], &ignore)) + _gaussianProcessXLeft->getmean(Utils::SharedImage(allImagesLeft[j], &ignore))) / 2;
			double yEstimate = (_gaussianProcessY->getmean(Utils::SharedImage(allImages[j], &ignore)) + _gaussianProcessYLeft->getmean(Utils::SharedImage(allImagesLeft[j], &ignore))) / 2;

			//std::cout << "i, j = (" << i << ", " << j << "), est: " << xEstimate << "(" << _gaussianProcessX->getmean(SharedImage(allImages[j], &ignore)) << "," << _gaussianProcessXLeft->getmean(SharedImage(allImagesLeft[j], &ignore)) << ")" << ", " << yEstimate << "(" << _gaussianProcessY->getmean(SharedImage(allImages[j], &ignore)) << "," << _gaussianProcessYLeft->getmean(SharedImage(allImagesLeft[j], &ignore)) << ")" << std::endl;

			xTotal += xEstimate;
			yTotal += yEstimate;
			sampleCount++;
			j++;
		}

		xTotal /= sampleCount;
		yTotal /= sampleCount;

		*outputFile << "TARGET: (" << _calTargets[i].point.x << "\t, " << _calTargets[i].point.y << "\t),\tESTIMATE: (" << xTotal << "\t, " << yTotal << ")" << std::endl;
		//std::cout << "TARGET: (" << _calTargets[i].point.x << "\t, " << _calTargets[i].point.y << "\t),\tESTIMATE: (" << xTotal << "\t, " << yTotal << "),\tDIFF: (" << fabs(_calTargets[i].point.x- x_total) << "\t, " << fabs(_calTargets[i].point.y - y_total) << ")" << std::endl;

		// Calibration error removal
		_xv[i][0] = xTotal;		// Source
		_xv[i][1] = yTotal;

		// Targets
		_fvX[i] = _calTargets[i].point.x;
		_fvY[i] = _calTargets[i].point.y;
		_sigv[i] = 0;

		int targetId = getTargetId(Point(xTotal, yTotal));

		if (targetId != i) {
			std::cout << "Target id is not the expected one!! (Expected: "<< i << ", Current: " << targetId << ")" << std::endl;
		}
	}

	// Add the corners of the monitor as 4 extra data points. This helps the correction for points that are near the edge of monitor
	_xv[_calTargets.size()][0] = monitorGeometry.get_x();
	_xv[_calTargets.size()][1] = monitorGeometry.get_y();
	_fvX[_calTargets.size()] = monitorGeometry.get_x()-40;
	_fvY[_calTargets.size()] = monitorGeometry.get_y()-40;

	_xv[_calTargets.size()+1][0] = monitorGeometry.get_x() + monitorGeometry.get_width();
	_xv[_calTargets.size()+1][1] = monitorGeometry.get_y();
	_fvX[_calTargets.size()+1] = monitorGeometry.get_x() + monitorGeometry.get_width() + 40;
	_fvY[_calTargets.size()+1] = monitorGeometry.get_y() - 40;

	_xv[_calTargets.size()+2][0] = monitorGeometry.get_x() + monitorGeometry.get_width();
	_xv[_calTargets.size()+2][1] = monitorGeometry.get_y() + monitorGeometry.get_height();
	_fvX[_calTargets.size()+2] = monitorGeometry.get_x() + monitorGeometry.get_width() + 40;
	_fvY[_calTargets.size()+2] = monitorGeometry.get_y() + monitorGeometry.get_height() + 40;

	_xv[_calTargets.size()+3][0] = monitorGeometry.get_x();
	_xv[_calTargets.size()+3][1] = monitorGeometry.get_y() + monitorGeometry.get_height();
	_fvX[_calTargets.size()+3] = monitorGeometry.get_x() - 40;
	_fvY[_calTargets.size()+3] = monitorGeometry.get_y() + monitorGeometry.get_height() + 40;

	int pointCount = _calTargets.size() + 4;
	int N = pointCount;
	N = binomialInv(N, 2) - 1;

	// Find the best beta and gamma parameters for interpolation
	mirBetaGamma(1, 2, pointCount, (double *)_xv, _fvX, _sigv, 0, NULL, NULL, NULL, N, 2, 50.0, &_betaX, &_gammaX);
	mirBetaGamma(1, 2, pointCount, (double *)_xv, _fvY, _sigv, 0, NULL, NULL, NULL, N, 2, 50.0, &_betaY, &_gammaY);

	*outputFile << std::endl << std::endl;
	std::cout << std::endl << std::endl;

	outputFile->flush();

	std::cout << "ERROR CALCULATION FINISHED. BETA = " << _betaX << ", " << _betaY << ", GAMMA IS " << _gammaX << ", " << _gammaY << std::endl;
	for (int i = 0; i < pointCount; i++) {
		std::cout << _xv[i][0] << ", " << _xv[i][1] << std::endl;
	}

	//checkErrorCorrection();
}
开发者ID:MariadeAnton,项目名称:OpenGazer,代码行数:96,代码来源:GazeTracker.cpp



注:本文中的gdk::Rectangle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ gdl::Clock类代码示例发布时间:2022-05-31
下一篇:
C++ gdk::Color类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap