Exemplo n.º 1
0
void ArrowModel::onPointUpdated(void)
{
    GraphicModel::points.clear();
    double x1, y1;
    GyPoint pt;

    if(!bNullArrow)
    {
        // Adding label position 
        Glib::RefPtr<Goocanvas::Item> item = parentWindow->m_Canvas->get_item(label); 
        if(item)
        {
            Goocanvas::Bounds bi = item->get_bounds();
            bi = item->get_bounds();
            pt.x = bi.get_x1();
            pt.y = bi.get_y1();
        }
        else
            pt.x = pt.y = -1;
    }

    GraphicModel::points.push_back(pt);

    Goocanvas::Points pts = this->property_points().get_value();
    for(int i=0; i<pts.get_num_points(); i++)
    {
        pts.get_coordinate(i, x1, y1);
        pt.x = x1;
        pt.y = y1;
        GraphicModel::points.push_back(pt);
    }
}
Exemplo n.º 2
0
bool MidpointModel::onItemMotionNotifyEvent(const Glib::RefPtr<Goocanvas::Item>& item, 
                    GdkEventMotion* event)
{
    if(item && _dragging && item == _dragging)
    {
        parentWindow->setModified();
        double new_x = event->x ;
        double new_y = event->y ;   
        item->translate(new_x - _drag_x, new_y - _drag_y);
  
        if(event->state  & GDK_CONTROL_MASK)
        {
           int index = arrow->getIndex(point_x, point_y);
           if(index)
           {
                Gdk::Point current_point, base_point;
                int dist;

                current_point = getContactPoint();

                // adjusting to the previous point
                base_point = arrow->getPoint(index-1);                               
                dist =  current_point.get_y() -  base_point.get_y();
                if(abs(dist) <= AUTOSNIPE_MARGINE)
                    item->translate(0, -dist);
                dist =  current_point.get_x() -  base_point.get_x();
                if(abs(dist) <= AUTOSNIPE_MARGINE)
                    item->translate(-dist, 0);

                // adjusting to the next point
                base_point = arrow->getPoint(index+1);                               
                dist =  current_point.get_y() -  base_point.get_y();
                if(abs(dist) <= AUTOSNIPE_MARGINE)
                    item->translate(0, -dist);
                dist =  current_point.get_x() -  base_point.get_x();
                if(abs(dist) <= AUTOSNIPE_MARGINE)
                    item->translate(-dist, 0);
           }
        }

        Goocanvas::Bounds bi = item->get_bounds();
        bi = item->get_bounds();

        if(bi.get_x1() < 0)
            item->translate(-bi.get_x1(), 0);
        if(bi.get_y1() < 0)
            item->translate(0, -bi.get_y1());
       
        snapToGrid();

        // updating arrows coordination        
        updateCoordiantes();
    }
    return true;
}
Exemplo n.º 3
0
void ArrowModel::setLabelPosition(double x, double y)
{
    if(!bNullArrow)
    {

        Glib::RefPtr<Goocanvas::Item> item = parentWindow->m_Canvas->get_item(label); 
        if(item)
        {
            Goocanvas::Bounds bi = item->get_bounds();
            bi = item->get_bounds();
            item->translate(x-bi.get_x1(), y-bi.get_y1());
        }
        onPointUpdated();
    }        
}
Exemplo n.º 4
0
void ApplicationModel::updateBounds(void)
{
    for(int i=0; i<this->get_n_children(); i++)
    {
        Glib::RefPtr<Goocanvas::Item> item = parentWindow->m_Canvas->get_item(this->get_child(i));
        if(item)
        {
            Goocanvas::Bounds bd = item->get_bounds();
            bounds.set_x1( (bounds.get_x1() < bd.get_x1()) ? bounds.get_x1(): bd.get_x1() );
            bounds.set_x2( (bounds.get_x2() > bd.get_x2()) ? bounds.get_x2(): bd.get_x2() );
            bounds.set_y1( (bounds.get_y1() < bd.get_y1()) ? bounds.get_y1(): bd.get_y1() );
            bounds.set_y2( (bounds.get_y2() > bd.get_y2()) ? bounds.get_y2(): bd.get_y2() );
        }
    }

    width = MAX(MIN_WIDTH + text_w, bounds.get_x2()-bounds.get_x1() + 2*ITEMS_MARGIE);
    height = MAX(MIN_HEIGHT, bounds.get_y2()-bounds.get_y1() + 2*ITEMS_MARGIE + text_h);

    Goocanvas::Points points(6);
    points.set_coordinate(0, 0, 0);
    points.set_coordinate(1, text_w+TEXT_MARGINE*2, 0);
    points.set_coordinate(2, text_w+TEXT_MARGINE*2, text_h+TEXT_MARGINE);
    points.set_coordinate(3, width, text_h+TEXT_MARGINE);
    points.set_coordinate(4, width, height);
    points.set_coordinate(5, 0, height);
    poly->property_points().set_value(points);

    Goocanvas::Points points3(3);
    points3.set_coordinate(0, width, text_h+TEXT_MARGINE);
    points3.set_coordinate(1, width, height);
    points3.set_coordinate(2, 0, height);
    shadow->property_points().set_value(points3);

}
Exemplo n.º 5
0
void getUrl(){
	//get the actual Url
	Gtk::TextBuffer::iterator start, end;
	Glib::RefPtr<Gtk::TextBuffer> buffer = textview_url->get_buffer();
	buffer->get_bounds (start, end);
	url = buffer->get_text(start, end, FALSE);
}
Exemplo n.º 6
0
bool ExternalPortModel::onItemMotionNotifyEvent(const Glib::RefPtr<Goocanvas::Item>& item, 
                    GdkEventMotion* event)
{
    if(bNested)
        return true;

    if(item && _dragging && item == _dragging)
    {
        parentWindow->setModified();
        double new_x = event->x ;
        double new_y = event->y ;   
        item->get_parent()->translate(new_x - _drag_x, new_y - _drag_y);
        
        Goocanvas::Bounds bi = item->get_bounds();
        bi = item->get_parent()->get_bounds();

        if(bi.get_x1() < 0)
            item->get_parent()->translate(-bi.get_x1(), 0);
        if(bi.get_y1() < 0)
            item->get_parent()->translate(0, -bi.get_y1());
       
        snapToGrid();

        // updating arrows coordination        
        updateArrowCoordination();

        bool needUpdate = false;
        if(parentWindow->m_Canvas)
        {
            Goocanvas::Bounds bc;
            parentWindow->m_Canvas->get_bounds(bc);
            needUpdate = (bi.get_x2() > bc.get_x2()) || (bi.get_y2() > bc.get_y2());
            if(needUpdate)
            {
                new_x = (bi.get_x2() > bc.get_x2()) ? bi.get_x2() : bc.get_x2(); 
                new_y = (bi.get_y2() > bc.get_y2()) ? bi.get_y2() : bc.get_y2(); 
                parentWindow->m_Canvas->set_bounds(0,0, new_x, new_y);            
                if(parentWindow->m_Grid)
                {
                    g_object_set(parentWindow->m_Grid, "width", new_x, NULL);
                    g_object_set(parentWindow->m_Grid, "height", new_y, NULL);
                }
            }
        }


    }
    return true;
}