oops, forgot Qt

This commit is contained in:
Daniel Russel 2007-06-11 20:52:05 +00:00
parent b197e42c61
commit ad173f7bcc
4 changed files with 76 additions and 65 deletions

View File

@ -60,10 +60,10 @@ public:
Gui_base(typename Simulator::Handle sh): mode_(STOPPED), paused_mode_(STOPPED), Gui_base(typename Simulator::Handle sh): mode_(STOPPED), paused_mode_(STOPPED),
fps_(60), speed_log_(0), fps_(60), speed_log_(0),
dir_of_time_(1), timer_(new Timer()), dir_of_time_(1), timer_(new Timer()),
timer_callback_(timer_,const_cast<This*>(this)),
drawable_(NULL), processing_(false) { drawable_(NULL), processing_(false) {
sim_= sh; sim_= sh;
target_cur_time_= CGAL::to_interval(sim_->current_time()).first; target_cur_time_= CGAL::to_interval(sim_->current_time()).first;
CGAL_KINETIC_INIT_LISTEN(Timer, timer_);
} }
virtual ~Gui_base() { virtual ~Gui_base() {
@ -111,19 +111,20 @@ public:
} }
} }
class Listener_core /*class Listener_core
{ {
public: public:
typedef typename This::Handle Notifier_handle; typedef typename This::Handle Notifier_handle;
typedef enum {CURRENT_TIME} typedef enum {CURRENT_TIME}
Notification_type; Notification_type;
}; };*/
//! The class to extend if you want to receive events. //! The class to extend if you want to receive events.
/*! See CGAL::Listener to a description of how runtime /*! See CGAL::Listener to a description of how runtime
notifications are handled. notifications are handled.
*/ */
typedef CGAL::Kinetic::Listener<Listener_core> Listener; CGAL_KINETIC_LISTENER(CURRENT_TIME);
friend class CGAL::Kinetic::Listener<Listener_core>; //typedef CGAL::Kinetic::Listener<Listener_core> Listener;
//friend class CGAL::Kinetic::Listener<Listener_core>;
//! get the simulator //! get the simulator
typename Simulator::Handle& simulator() { typename Simulator::Handle& simulator() {
@ -177,16 +178,9 @@ protected:
} }
} }
const Listener* listener() const
{
return drawable_;
}
void set_listener(Listener* d) {
drawable_=d;
}
class Timer_listener: public Timer::Listener /*class Timer_listener: public Timer::Listener
{ {
public: public:
Timer_listener(Timer *tm, This *t):Timer::Listener(tm), t_(t) { Timer_listener(Timer *tm, This *t):Timer::Listener(tm), t_(t) {
@ -198,7 +192,8 @@ protected:
This *t_; This *t_;
}; };
friend class Timer_listener; friend class Timer_listener;*/
CGAL_KINETIC_LISTEN1(Timer, TICKS, timer_rang);
void timer_rang() { void timer_rang() {
// do something here // do something here
@ -309,7 +304,8 @@ protected:
default: default:
std::cerr << "Run callback in invalid mode." << std::endl; std::cerr << "Run callback in invalid mode." << std::endl;
} }
if (drawable_ != NULL) drawable_->new_notification(Listener::CURRENT_TIME); CGAL_KINETIC_SIGNAL(CURRENT_TIME);
// if (drawable_ != NULL) drawable_->new_notification(Listener::CURRENT_TIME);
set_is_processing(false); set_is_processing(false);

View File

@ -54,7 +54,7 @@ namespace CGAL
return tick_; return tick_;
} }
void clear() { void clear() {
//CGAL_precondition(id_!=-1); //CGAL_precondition(id_!=-1);
if (id_!= -1) timer_.killTimer(id_); if (id_!= -1) timer_.killTimer(id_);
id_=-1; id_=-1;
}; };

View File

@ -169,5 +169,20 @@ private: \
#define CGAL_KINETIC_SIGNAL(field) if (listener_!= NULL) listener_->new_notification(Listener::field) #define CGAL_KINETIC_SIGNAL(field) if (listener_!= NULL) listener_->new_notification(Listener::field)
#define CGAL_KINETIC_LISTENER_DESTRUCTOR CGAL_assertion(listener_==NULL); #define CGAL_KINETIC_LISTENER_DESTRUCTOR CGAL_assertion(listener_==NULL);
#define CGAL_KINETIC_LISTEN1(Notifier, Signal, func) private:\
class Notifier##_listener: public Notifier::Listener {\
This *t_; \
public: \
Notifier##_listener(Notifier* tm, This &t): Notifier::Listener(tm), t_(t){} \
void new_notification(typename Notifier::Listener::Notification_type t) {\
if (t== Notifier::Listener::Signal) t_->func(); \
}\
};\
friend class Notifier##_listener;\
Notifier##_listener listener_##Notifier##_;
#define CGAL_KINETIC_INIT_LISTEN(Notifier, ptr) listener_##Notifier##_=Notifier##_listener(ptr, const_cast<This*>(this))
CGAL_KINETIC_END_NAMESPACE CGAL_KINETIC_END_NAMESPACE
#endif #endif

View File

@ -37,14 +37,14 @@ void intrusive_ptr_release(const Ref_counted_base *t);
class Ref_counted_base: boost::noncopyable class Ref_counted_base: boost::noncopyable
{ {
typedef Ref_counted_base This; typedef Ref_counted_base This;
Ref_counted_base(const Ref_counted_base&) : reference_count_(0) { /*Ref_counted_base(const Ref_counted_base&) : reference_count_(0) {
std::cerr << "Copy constructor called. Why?" << std::endl; std::cerr << "Copy constructor called. Why?" << std::endl;
} }*/
Ref_counted_base operator=(const Ref_counted_base&) const /*Ref_counted_base operator=(const Ref_counted_base&) const
{ {
std::cerr << "Assignment called. Why?" << std::endl; std::cerr << "Assignment called. Why?" << std::endl;
return *this; return *this;
} }*/
public: public:
Ref_counted_base() : reference_count_(0) {} Ref_counted_base() : reference_count_(0) {}