本文整理汇总了C++中gdk::Rectangle::get_x方法的典型用法代码示例。如果您正苦于以下问题:C++ Rectangle::get_x方法的具体用法?C++ Rectangle::get_x怎么用?C++ Rectangle::get_x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdk::Rectangle
的用法示例。
在下文中一共展示了Rectangle::get_x方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: boundToScreenCoordinates
void GazeTracker::boundToScreenCoordinates(Point &estimate) {
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);
// If x or y coordinates are outside screen boundaries, correct them
if (estimate.x < monitorGeometry.get_x()) {
estimate.x = monitorGeometry.get_x();
}
if (estimate.y < monitorGeometry.get_y()) {
estimate.y = monitorGeometry.get_y();
}
if (estimate.x >= monitorGeometry.get_x() + monitorGeometry.get_width()) {
estimate.x = monitorGeometry.get_x() + monitorGeometry.get_width();
}
if (estimate.y >= monitorGeometry.get_y() + monitorGeometry.get_height()) {
estimate.y = monitorGeometry.get_y() + monitorGeometry.get_height();
}
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例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();
}
示例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;}
示例7: 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();
}
示例8: sample_width
void
studio::render_gradient_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Gradient &gradient)
{
int height = ca.get_height();
int width = ca.get_width()-4;
float sample_width(1.0f/(float)width);
Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
const Color bg1(0.25, 0.25, 0.25);
const Color bg2(0.5, 0.5, 0.5);
Gdk::Color gdk_c;
int i;
for(i=0;i<width;i++)
{
const Color c(gradient(float(i)/float(width),sample_width));
const Color c1(Color::blend(c,bg1,1.0).clamped());
const Color c2(Color::blend(c,bg2,1.0).clamped());
gushort r1(256*App::gamma.r_F32_to_U8(c1.get_r()));
gushort g1(256*App::gamma.g_F32_to_U8(c1.get_g()));
gushort b1(256*App::gamma.b_F32_to_U8(c1.get_b()));
gushort r2(256*App::gamma.r_F32_to_U8(c2.get_r()));
gushort g2(256*App::gamma.g_F32_to_U8(c2.get_g()));
gushort b2(256*App::gamma.b_F32_to_U8(c2.get_b()));
if((i*2/height)&1)
{
gdk_c.set_rgb(r1,g1,b1);
gc->set_rgb_fg_color(gdk_c);
window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y(), 1, height/2);
gdk_c.set_rgb(r2,g2,b2);
gc->set_rgb_fg_color(gdk_c);
window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y()+height/2, 1, height/2);
}
else
{
gdk_c.set_rgb(r2,g2,b2);
gc->set_rgb_fg_color(gdk_c);
window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y(), 1, height/2);
gdk_c.set_rgb(r1,g1,b1);
gc->set_rgb_fg_color(gdk_c);
window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y()+height/2, 1, height/2);
}
}
gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, ca.get_width()-3, height-3);
gc->set_rgb_fg_color(Gdk::Color("#000000"));
window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), ca.get_width()-1, height-1);
}
示例9: x
void
CellRenderer_TimeTrack::render_vfunc(
const Glib::RefPtr<Gdk::Drawable>& window,
Gtk::Widget& widget,
const Gdk::Rectangle& /*background_area*/,
const Gdk::Rectangle& area_,
const Gdk::Rectangle& /*expose_area*/,
Gtk::CellRendererState /*flags*/)
{
if(!window)
return;
Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
Glib::RefPtr<Gdk::GC> inactive_gc(Gdk::GC::create(window));
Gtk::Adjustment *adjustment=get_adjustment();
// Gtk::StateType state = Gtk::STATE_ACTIVE;
// Gtk::ShadowType shadow;
Gdk::Color
curr_time_color("#0000ff"),
inactive_color("#000000"),
keyframe_color("#a07f7f");
Gdk::Color activepoint_color[2];
activepoint_color[0]=Gdk::Color("#ff0000");
activepoint_color[1]=Gdk::Color("#00ff00");
inactive_gc->set_rgb_fg_color(inactive_color);
inactive_gc->set_stipple(Gdk::Bitmap::create(stipple_xpm,2,2));
inactive_gc->set_fill(Gdk::STIPPLED);
synfig::Canvas::Handle canvas(property_canvas().get_value());
synfigapp::ValueDesc value_desc = property_value_desc().get_value();
synfig::ValueNode *base_value = value_desc.get_value_node().get();
// synfig::ValueNode_Animated *value_node=dynamic_cast<synfig::ValueNode_Animated*>(base_value);
synfig::ValueNode_DynamicList *parent_value_node(0);
if(property_value_desc().get_value().parent_is_value_node())
parent_value_node=dynamic_cast<synfig::ValueNode_DynamicList*>(property_value_desc().get_value().get_parent_value_node().get());
// If the canvas is defined, then load up the keyframes
if(canvas)
{
const synfig::KeyframeList& keyframe_list(canvas->keyframe_list());
synfig::KeyframeList::const_iterator iter;
for(iter=keyframe_list.begin(); iter!=keyframe_list.end(); ++iter)
{
if(!iter->get_time().is_valid())
continue;
const int x((int)((float)area_.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(iter->get_time()-adjustment->get_lower())));
if(iter->get_time()>=adjustment->get_lower() && iter->get_time()<adjustment->get_upper())
{
gc->set_rgb_fg_color(keyframe_color);
window->draw_rectangle(gc, true, area_.get_x()+x, area_.get_y(), 1, area_.get_height()+1);
}
}
}
//render all the time points that exist
{
const synfig::Node::time_set *tset = get_times_from_vdesc(value_desc);
if(tset)
{
const synfig::Time time_offset = get_time_offset_from_vdesc(value_desc);
synfig::Node::time_set::const_iterator i = tset->begin(), end = tset->end();
float lower = adjustment->get_lower(),
upper = adjustment->get_upper();
Glib::RefPtr<Gdk::GC> gc = Gdk::GC::create(widget.get_window());
Gdk::Rectangle area(area_);
gc->set_clip_rectangle(area);
gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
bool valselected = sel_value.get_value_node() == base_value && !sel_times.empty();
float cfps = get_canvas()->rend_desc().get_frame_rate();
vector<Time> drawredafter;
Time diff = actual_time - actual_dragtime;//selected_time-drag_time;
for(; i != end; ++i)
{
//find the coordinate in the drawable space...
Time t_orig = i->get_time();
if(!t_orig.is_valid()) continue;
Time t = t_orig - time_offset;
if(t<adjustment->get_lower() || t>adjustment->get_upper()) continue;
//if it found it... (might want to change comparison, and optimize
// sel_times.find to not produce an overall nlogn solution)
bool selected=false;
//not dragging... just draw as per normal
//if move dragging draw offset
//.........这里部分代码省略.........
示例10:
/** Render the cell.
* This is called to render the cell.
* @param window window
* @param widget widget
* @param background_area dimensions of the background area
* @param cell_area dimensions of the cell area
* @param expose_area dimensions of the exposed area
* @param flags render flags
*/
void
TwoLinesCellRenderer::render_vfunc(const Glib::RefPtr<Gdk::Drawable> &window,
Gtk::Widget &widget,
const Gdk::Rectangle &background_area,
const Gdk::Rectangle &cell_area,
const Gdk::Rectangle &expose_area,
Gtk::CellRendererState flags)
#endif
{
#ifdef GLIBMM_PROPERTIES_ENABLED
// Get cell size
int x_offset = 0, y_offset = 0;
#if GTK_VERSION_LT(3,0)
int width = 0, height = 0;
get_size(widget, cell_area, x_offset, y_offset, width, height);
// Get cell state
//Gtk::StateType state;
Gtk::StateType text_state;
if ((flags & Gtk::CELL_RENDERER_SELECTED) != 0) {
//state = Gtk::STATE_SELECTED;
text_state = (widget.has_focus()) ? Gtk::STATE_SELECTED : Gtk::STATE_ACTIVE;
} else {
//state = Gtk::STATE_NORMAL;
text_state = (widget.is_sensitive()) ? Gtk::STATE_NORMAL : Gtk::STATE_INSENSITIVE;
}
// Draw color text
Glib::RefPtr<Gdk::Window> win =
Glib::RefPtr<Gdk::Window>::cast_dynamic(window);
#endif
Glib::RefPtr<Pango::Layout> layout_ptr =
widget.create_pango_layout(__property_line1);
Pango::Rectangle rect1 = layout_ptr->get_pixel_logical_extents();
#if GTK_VERSION_GE(3,0)
cr->move_to(cell_area.get_x() + x_offset + 2 * property_xpad(),
cell_area.get_y() + y_offset + 2 * property_ypad());
layout_ptr->show_in_cairo_context(cr);
#else
widget.get_style()->paint_layout(win, text_state, true, cell_area,
widget, "cellrenderertext",
cell_area.get_x() + x_offset + 2 * property_xpad(),
cell_area.get_y() + y_offset + 2 * property_ypad(),
layout_ptr);
#endif
if (__property_line2_enabled.get_value()) {
Glib::RefPtr<Pango::Layout> layout2 =
widget.create_pango_layout(__property_line2);
#if GTK_VERSION_GE(3,0)
Pango::FontDescription font2("sans 10");
#else
Glib::RefPtr<Gtk::Style> style = widget.get_style();
Pango::FontDescription font2 = style->get_font();
#endif
font2.set_size((int)roundf(Pango::SCALE_SMALL * font2.get_size()));
layout2->set_font_description(font2);
//Pango::Rectangle rect2 = layout2->get_pixel_logical_extents();
layout2->set_ellipsize(Pango::ELLIPSIZE_END);
layout2->set_width((cell_area.get_width() - property_xpad()) * Pango::SCALE);
#if GTK_VERSION_GE(3,0)
cr->move_to(cell_area.get_x() + x_offset + property_xpad(),
cell_area.get_y() + y_offset + property_ypad() +
rect1.get_height() + 4);
layout2->show_in_cairo_context(cr);
#else
widget.get_style()->paint_layout (win, text_state, true, cell_area,
widget, "cellrenderertext",
cell_area.get_x() + x_offset + property_xpad(),
cell_area.get_y() + y_offset + property_ypad() + rect1.get_height() + 4,
layout2);
#endif
}
#endif
}
示例11: height
void
studio::render_color_to_window(const Cairo::RefPtr<Cairo::Context> &cr, const Gdk::Rectangle &ca, const synfig::Color &color)
{
const int height(ca.get_height());
const int width(ca.get_width());
const int square_size(height/2);
if(color.get_alpha()!=1.0)
{
// In this case we need to render the alpha squares
const Color bg1(
colorconv_apply_gamma(
Color::blend(color,Color(0.75, 0.75, 0.75),1.0).clamped() ));
const Color bg2(
colorconv_apply_gamma(
Color::blend(color,Color(0.5, 0.5, 0.5),1.0).clamped() ));
bool toggle(false);
for(int i=0;i<width;i+=square_size)
{
const int square_width(min(square_size,width-i));
if(toggle)
{
cr->set_source_rgb(bg1.get_r(), bg1.get_g(), bg1.get_b());
cr->rectangle(ca.get_x()+i, ca.get_y(), square_width, square_size);
cr->fill();
cr->set_source_rgb(bg2.get_r(), bg2.get_g(), bg2.get_b());
cr->rectangle(ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
cr->fill();
toggle=false;
}
else
{
cr->set_source_rgb(bg2.get_r(), bg2.get_g(), bg2.get_b());
cr->rectangle(ca.get_x()+i, ca.get_y(), square_width, square_size);
cr->fill();
cr->set_source_rgb(bg1.get_r(), bg1.get_g(), bg1.get_b());
cr->rectangle(ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
cr->fill();
toggle=true;
}
}
}
else
{
synfig::Color c = colorconv_apply_gamma(color);
cr->set_source_rgb(c.get_r(), c.get_g(), c.get_b());
cr->rectangle(ca.get_x(), ca.get_y(), width-1, height-1);
cr->fill();
}
cr->set_source_rgb(1.0, 1.0, 1.0);
cr->rectangle(ca.get_x()+1, ca.get_y()+1, width-3, height-3);
cr->stroke();
cr->set_source_rgb(0.0, 0.0, 0.0);
cr->rectangle(ca.get_x(), ca.get_y(), width-1, height-1);
cr->stroke();
}
示例12: 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();
}
示例13:
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();
}
示例14: pixel_width
bool
CellRenderer_TimeTrack::activate_vfunc(
GdkEvent* event,
Gtk::Widget& /*widget*/,
const Glib::ustring& treepath,
const Gdk::Rectangle& /*background_area*/,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState /*flags*/)
{
if (!event)
{
// Catch a null event received us a result of a keypress (only?)
return true; //On tab key press, Focus go to next panel. If return false, focus goes to canvas
}
path=treepath;
synfig::ValueNode_Animated::WaypointList::iterator iter;
Glib::RefPtr<Gtk::Adjustment> adjustment=get_adjustment();
// synfig::ValueNode_Animated *value_node=dynamic_cast<synfig::ValueNode_Animated*>(property_value_desc().get_value().get_value_node().get());
synfig::Canvas::Handle canvas(get_canvas());
Time deltatime = 0;
Time curr_time;
switch(event->type)
{
case GDK_MOTION_NOTIFY:
curr_time=((float)event->motion.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
mode = NONE;
{
Gdk::ModifierType mod;
Gdk::Event(event).get_state(mod);
mode = mod;
}
break;
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
default:
curr_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
{
Gdk::ModifierType mod;
Gdk::Event(event).get_state(mod);
mode = mod;
}
break;
}
actual_time = curr_time;
if(canvas)
curr_time=curr_time.round(canvas->rend_desc().get_frame_rate());
selected_time=curr_time;
Time pixel_width((adjustment->get_upper()-adjustment->get_lower())/cell_area.get_width());
switch(event->type)
{
case GDK_BUTTON_PRESS:
//selected_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
//Deal with time point selection, but only if they aren't involved in the insanity...
if(/*!value_node && */event->button.button == 1)
{
Time stime;
/*! UI specification:
When nothing is selected, clicking on a point in either normal mode or
additive mode will select the time point closest to the click.
Subtractive click will do nothing
When things are already selected, clicking on a selected point does
nothing (in both normal and add mode). Add mode clicking on an unselected
point adds it to the set. Normal clicking on an unselected point will
select only that one time point. Subtractive clicking on any point
will remove it from the the set if it is included.
*/
synfigapp::ValueDesc valdesc = property_value_desc().get_value();
const Node::time_set *tset = get_times_from_vdesc(valdesc);
const synfig::Time time_offset = get_time_offset_from_vdesc(valdesc);
bool clickfound = tset && get_closest_time(*tset,actual_time+time_offset,pixel_width*cell_area.get_height(),stime);
bool selectmode = mode & SELECT_MASK;
//NOTE LATER ON WE SHOULD MAKE IT SO MULTIPLE VALUENODES CAN BE SELECTED AT ONCE
//we want to jump to the value desc if we're not currently on it
// but only if we want to add the point
if(clickfound && !(sel_value == valdesc))
{
sel_value = valdesc;
sel_times.clear();
}
//now that we've made sure we're selecting the correct value, deal with the already selected points
set<Time>::iterator foundi = clickfound ? sel_times.find(stime) : sel_times.end();
bool found = foundi != sel_times.end();
//remove all other points from our list... (only select the one we need)
if(!selectmode && !found)
//.........这里部分代码省略.........
示例15: if
bool
on_event(GdkEvent *event)
{
switch(event->type)
{
case GDK_SCROLL:
if(mimic_tree_view)
{
if(event->scroll.direction==GDK_SCROLL_DOWN)
{
mimic_tree_view->get_vadjustment()->set_value(
std::min(
mimic_tree_view->get_vadjustment()->get_value()+
mimic_tree_view->get_vadjustment()->get_step_increment(),
mimic_tree_view->get_vadjustment()->get_upper()-
mimic_tree_view->get_vadjustment()->get_page_size()
)
);
mimic_tree_view->get_vadjustment()->value_changed();
}
else if(event->scroll.direction==GDK_SCROLL_UP)
{
mimic_tree_view->get_vadjustment()->set_value(
std::max(
mimic_tree_view->get_vadjustment()->get_value()-
mimic_tree_view->get_vadjustment()->get_step_increment(),
mimic_tree_view->get_vadjustment()->get_lower()
)
);
mimic_tree_view->get_vadjustment()->value_changed();
}
}
break;
case GDK_BUTTON_PRESS:
{
Gtk::TreeModel::Path path;
Gtk::TreeViewColumn *column;
int cell_x, cell_y;
if(!get_path_at_pos(
int(event->button.x),int(event->button.y), // x, y
path, // TreeModel::Path&
column, //TreeViewColumn*&
cell_x,cell_y //int&cell_x,int&cell_y
)
) break;
const Gtk::TreeRow row = *(get_model()->get_iter(path));
if(column && column->get_first_cell_renderer()==cellrenderer_time_track)
{
Gdk::Rectangle rect;
get_cell_area(path,*column,rect);
cellrenderer_time_track->property_value_desc()=row[model.value_desc];
cellrenderer_time_track->property_canvas()=row[model.canvas];
cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
return true;
//return signal_param_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
}
}
break;
case GDK_MOTION_NOTIFY:
{
Gtk::TreeModel::Path path;
Gtk::TreeViewColumn *column;
int cell_x, cell_y;
if(!get_path_at_pos(
(int)event->motion.x,(int)event->motion.y, // x, y
path, // TreeModel::Path&
column, //TreeViewColumn*&
cell_x,cell_y //int&cell_x,int&cell_y
)
) break;
if(!get_model()->get_iter(path))
break;
Gtk::TreeRow row = *(get_model()->get_iter(path));
if ((event->motion.state&GDK_BUTTON1_MASK || event->motion.state&GDK_BUTTON3_MASK) &&
column &&
cellrenderer_time_track == column->get_first_cell_renderer())
{
Gdk::Rectangle rect;
get_cell_area(path,*column,rect);
cellrenderer_time_track->property_value_desc()=row[model.value_desc];
cellrenderer_time_track->property_canvas()=row[model.canvas];
cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
queue_draw();
//queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
return true;
}
/* else
if(last_tooltip_path.get_depth()<=0 || path!=last_tooltip_path)
{
tooltips_.unset_tip(*this);
Glib::ustring tooltips_string(row[layer_model.tooltip]);
last_tooltip_path=path;
if(!tooltips_string.empty())
{
//.........这里部分代码省略.........