mirror of https://github.com/CGAL/cgal
oops, forgot Qt
This commit is contained in:
parent
b197e42c61
commit
ad173f7bcc
|
|
@ -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) {
|
/*class Timer_listener: public Timer::Listener
|
||||||
drawable_=d;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,56 +24,56 @@
|
||||||
#include <qtimer.h>
|
#include <qtimer.h>
|
||||||
namespace CGAL
|
namespace CGAL
|
||||||
{
|
{
|
||||||
namespace Kinetic
|
namespace Kinetic
|
||||||
|
{
|
||||||
|
namespace internal
|
||||||
{
|
{
|
||||||
namespace internal
|
class Qt_timer: QObject
|
||||||
{
|
{
|
||||||
class Qt_timer: QObject
|
Q_OBJECT
|
||||||
{
|
public:
|
||||||
Q_OBJECT
|
class Listener
|
||||||
public:
|
{
|
||||||
class Listener
|
public:
|
||||||
{
|
typedef Qt_timer* Notifier_handle;
|
||||||
public:
|
Listener(Notifier_handle h): h_(h){h->set_listener(this);}
|
||||||
typedef Qt_timer* Notifier_handle;
|
typedef enum {TICKS}
|
||||||
Listener(Notifier_handle h): h_(h){h->set_listener(this);}
|
Notification_type;
|
||||||
typedef enum {TICKS}
|
virtual void new_notification(Notification_type) =0;
|
||||||
Notification_type;
|
virtual ~Listener() {
|
||||||
virtual void new_notification(Notification_type) =0;
|
h_->set_listener(NULL);
|
||||||
virtual ~Listener() {
|
}
|
||||||
h_->set_listener(NULL);
|
protected:
|
||||||
}
|
Notifier_handle h_;
|
||||||
protected:
|
};
|
||||||
Notifier_handle h_;
|
|
||||||
};
|
|
||||||
|
|
||||||
Qt_timer();
|
Qt_timer();
|
||||||
|
|
||||||
int ticks() const
|
int ticks() const
|
||||||
{
|
{
|
||||||
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;
|
||||||
};
|
};
|
||||||
void run(double time_in_seconds);
|
void run(double time_in_seconds);
|
||||||
protected:
|
protected:
|
||||||
QTimer timer_;
|
QTimer timer_;
|
||||||
Listener *cb_;
|
Listener *cb_;
|
||||||
int tick_;
|
int tick_;
|
||||||
int id_;
|
int id_;
|
||||||
|
|
||||||
friend class Listener;
|
friend class Listener;
|
||||||
void set_listener(Listener *l) {
|
void set_listener(Listener *l) {
|
||||||
cb_=l;
|
cb_=l;
|
||||||
}
|
}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void timerDone();
|
void timerDone();
|
||||||
};
|
};
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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) {}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue