[gnomemm] Info about libgnomecanvasmm



I have a problem to connect a signal to an object who I derived from
SigC::Object: it looks like insensible to any kind of event, and i don't
understand why!
This object contain in it a lot of canvas primitives who draw a diagram.
I group all primitivies to move all ones by group. It doesn't work! Why?

Wish you give me a way to "light" my object?

I use libgnomecanvas 2.0.1, libsigc 1.2.5 e GCC 3.3.3 on Fedora Core 2.

Many thanks...
...sorry for my English... I try to improve it!!!
-- 
Rocker
  alias "Davide Anastasia"
"Everything you know is wrong"
Linux User #341094

P.S. I send you my source... You can find probably my problem in
ModelClassObject costructor.
//
// File: ModelClassObject.cc
// Created by: Davide "Rocker" Anastasia <s242248 studenti ing unipi it>
// Created on: Thu Jul 29 00:39:16 2004
//

#define SIDE_BORDER			15
#define UP_DOWN_BORDER		6
#define SIZE_FONT			16
#define LIFE_LINE			40
#define LIFE_TIME			200
#define LIFE_TIME_BORDER	6
#define TEXT_TO_LINE		1
#define ANCHOR_DIM			3

#include "ModelClassObject.h"
#include "CanvasMgr.h"
#include "DragBox.h"
#include "macro.cc"
#include "AnchorBox.h"

#include <iostream>

// CanvasMgr is derived from Gnome::Canvas::Canvas
ModelClassObject::ModelClassObject(CanvasMgr* mgr, int id) :
	ModelObjBase(mgr, id)
{
	
	// This group contain all element who make a model element
	my_self_group_ = manage( new Gnome::Canvas::Group( *mgr->root() ) );
	// This signal don't work... why???
	my_self_group_->signal_event().connect(slot(*this, &ModelClassObject::onOver));

	// Text label
	label_ = manage( new Gnome::Canvas::Text(*my_self_group_) );
	label_->property_text() = ":Untitled";
	label_->property_x() = SIDE_BORDER + label_->property_text_width()/2;
	label_->property_y() = UP_DOWN_BORDER + label_->property_text_height()/2;
	label_->property_font() = "Sans SIZE_FONT";
	label_->property_fill_color() = "black";
	
	underline_points_ = new Gnome::Canvas::Points();
	underline_points_->push_back(Gnome::Art::Point(SIDE_BORDER, UP_DOWN_BORDER+label_->property_text_height()+TEXT_TO_LINE));
	underline_points_->push_back(Gnome::Art::Point(SIDE_BORDER+label_->property_text_width(), UP_DOWN_BORDER+label_->property_text_height()+TEXT_TO_LINE));
	underline_line_ = manage( new Gnome::Canvas::Line(*my_self_group_, *underline_points_) );
		
	setIsObject(true);

	// vars
	double right_box_pos = SIDE_BORDER*2 + label_->property_text_width();
	double bottom_box_pos = UP_DOWN_BORDER*2 + label_->property_text_height();
	
	// name class box
	box_ = manage( new Gnome::Canvas::Rect(*my_self_group_,
			0, 0,
			right_box_pos, bottom_box_pos) );
	box_->property_outline_color() = "black";
	
	// time line
	upper_points_ = new Gnome::Canvas::Points();
	upper_points_->push_back(Gnome::Art::Point(right_box_pos/2,bottom_box_pos));
	upper_points_->push_back(Gnome::Art::Point(right_box_pos/2,bottom_box_pos + LIFE_LINE));
	upper_line_ = manage( new Gnome::Canvas::Line(*my_self_group_, *upper_points_) );
	upper_line_->property_line_style() = Gdk::LINE_ON_OFF_DASH;				// Linea tratteggiata!
	upper_line_->property_fill_color() = "black";
	upper_line_->property_width_pixels() = 1;
	
	// life box
	lifetime_box_ = manage ( new Gnome::Canvas::Rect(*my_self_group_,
			right_box_pos/2 - LIFE_TIME_BORDER, bottom_box_pos + LIFE_LINE,
			right_box_pos/2 + LIFE_TIME_BORDER, bottom_box_pos + LIFE_LINE + LIFE_TIME) );
	lifetime_box_->property_outline_color() = "black";
	
	
	
	// time line
	lower_points_ = new Gnome::Canvas::Points();
	lower_points_->push_back(Gnome::Art::Point(right_box_pos/2,bottom_box_pos + LIFE_LINE + LIFE_TIME));
	lower_points_->push_back(Gnome::Art::Point(right_box_pos/2,bottom_box_pos + LIFE_LINE*2 + LIFE_TIME));
	lower_line_ = manage( new Gnome::Canvas::Line(*my_self_group_, *lower_points_) );
	lower_line_->property_line_style() = Gdk::LINE_ON_OFF_DASH;				// Linea tratteggiata!
	lower_line_->property_fill_color() = "black";
	
	// DragBox... to change form of diagram
	// db_box_ = manage( new DragBox(*my_self_group_) );
	// db_box_->move_drag_box(right_box_pos, bottom_box_pos);
	db_lifeline_up_ = manage( new DragBox(*my_self_group_) );
	db_lifeline_up_->move_drag_box(right_box_pos/2 - LIFE_TIME_BORDER, bottom_box_pos + LIFE_LINE);
	
	db_lifeline_down_ = manage( new DragBox(*my_self_group_) );
	db_lifeline_down_->move_drag_box(right_box_pos/2 + LIFE_TIME_BORDER, bottom_box_pos + LIFE_LINE + LIFE_TIME);
	
	anchor_ = manage( new AnchorBox(my_self_group_, H) );
}


ModelClassObject::~ModelClassObject()
{
	delete lower_points_;
	delete upper_points_;
}

void
ModelClassObject::setIsObject(bool var)
{
	if ( var == true ) {
		underline_line_->property_fill_color() = "black";
		is_object_ = true;
	} else {
		underline_line_->property_fill_color().reset_value();
		is_object_ = false;
	} 
}

bool
ModelClassObject::getIsObject() {
	return is_object_;	
}

void
ModelClassObject::move(double x, double y)
{
	my_self_group_->move(x, y);
}

void
ModelClassObject::moveTo(double x, double y)
{
	my_self_group_->property_x() = x;
	my_self_group_->property_y() = y;
}

#ifdef _DEBUG
bool
ModelClassObject::onOver(GdkEvent* event)
{
	std::cout << "OnOver" << std::endl;
	
	return 1;
}
#endif
//
// File: ModelClassObject.h
// Created by: Davide "Rocker" Anastasia <s242248 studenti ing unipi it>
// Created on: Thu Jul 29 00:39:16 2004
//
// Questa classe definisce la forma di una classe o di un oggetto nel diagramma
// La sola differenza tra l'una e l'altra è la sottolineatura della label.


#ifndef _MODELCLASSOBJECT_H_
#define _MODELCLASSOBJECT_H_

#include <libgnomecanvasmm/canvas.h>
#include <libgnomecanvasmm/group.h>
#include <libgnomecanvasmm/text.h>
#include <libgnomecanvasmm/line.h>
#include <libgnomecanvasmm/rect.h>

#include "ModelObjBase.h"
#include "CanvasMgr.h"
#include "DragBox.h"
#include "macro.cc"
#include "AnchorBox.h"

class AnchorBox;

class ModelClassObject : virtual public ModelObjBase
{
	public:
		ModelClassObject(CanvasMgr*, int);
		 ~ModelClassObject();
		
		// Gestione delle proprietà
		void setIsConcurrent(bool);
		bool getIsConcurrent();
	
		void setIsObject(bool);
		bool getIsObject();
		
		// Gestione degli eventi
		bool on_item_event(GdkEvent*);
		
		// Gestione del movimento
		void move(double, double);
		void moveTo(double, double);

		#ifdef _DEBUG
		bool onOver(GdkEvent*);
		#endif
	
	
		virtual void getXMI() {};
		virtual void getSVG() {};	
		virtual void update() {};
	
	protected:
		Gnome::Canvas::Group* my_self_group_;

		Gnome::Canvas::Rect* box_;
		Gnome::Canvas::Text* label_;
	
		Gnome::Canvas::Points* underline_points_;
		Gnome::Canvas::Line* underline_line_;
	
		Gnome::Canvas::Points* upper_points_;
		Gnome::Canvas::Line* upper_line_;
	
		Gnome::Canvas::Rect* lifetime_box_;
	
		Gnome::Canvas::Points* lower_points_;
		Gnome::Canvas::Line* lower_line_;
	
		DragBox* db_box_;
		DragBox* db_lifeline_up_;
		DragBox* db_lifeline_down_;
	
		// Definisco se l'oggetto è una classe o un oggetto e se è o no concorrente
		bool is_concurrent_;
		bool is_object_;
		
		AnchorBox* anchor_;
};


#endif	//_MODELCLASSOBJECT_H_
//
// File: ModelObjBase.cc
// Created by: Davide "Rocker" Anastasia <s242248 studenti ing unipi it>
// Created on: Sun May 30 23:55:33 2004
//

#include "ModelObjBase.h"
#include "CanvasMgr.h"

ModelObjBase::ModelObjBase(CanvasMgr* canvas, int id)
{
	my_manager_ = canvas;
	myId = id;
}


ModelObjBase::~ModelObjBase()
{
}
//
// File: ModelObjBase.h
// Created by: Davide "Rocker" Anastasia <s242248 studenti ing unipi it>
// Created on: Sun May 30 23:55:33 2004
//

#ifndef _MODELOBJBASE_H_
#define _MODELOBJBASE_H_

#include <libgnomecanvasmm.h>
#include <gtkmm.h>
//#include <sigc++/sigc++.h>

#include "CanvasMgr.h"

class CanvasMgr;

class ModelObjBase : public virtual SigC::Object
					// : public Gtk::EventBox
{
	public:
		ModelObjBase(CanvasMgr*, int);
		virtual ~ModelObjBase();
	
		// ModelObjBase interface
		virtual void getXMI() = 0;	// Da definire il tipo di ritorno!
		virtual void getSVG() = 0;	// Da definire il tipo di ritorno!
									// Probabilmente il tipo di ritorno di queste
									// due funzioni è un oggetto di Xerces-C++
	
		virtual void update() = 0;
	
		// virtual bool on_item_event(GdkEvent*) = 0;
	
	protected:
		CanvasMgr* my_manager_;
		int myId;
		
};


#endif	//_MODELOBJBASE_H_

Attachment: signature.asc
Description: Questa parte del messaggio =?ISO-8859-1?Q?=E8?= firmata



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]