~ubuntu-branches/ubuntu/lucid/structure-synth/lucid

« back to all changes in this revision

Viewing changes to StructureSynth/JavaScriptSupport/Debug.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Miriam Ruiz
  • Date: 2009-04-13 13:28:45 UTC
  • Revision ID: james.westby@ubuntu.com-20090413132845-d7d42t4llxjxq0ez
Tags: upstream-0.9
ImportĀ upstreamĀ versionĀ 0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "Debug.h"
 
2
 
 
3
#include <QScriptEngine>
 
4
#include <QMessageBox>
 
5
#include <QApplication>
 
6
#include <QThread>
 
7
#include "SyntopiaCore/Logging/Logging.h"
 
8
#include "../../SyntopiaCore/GLEngine/Sphere.h"
 
9
 
 
10
 
 
11
using namespace SyntopiaCore::Logging;
 
12
 
 
13
 
 
14
 
 
15
namespace StructureSynth {
 
16
        namespace JavaScriptSupport {   
 
17
 
 
18
                namespace {
 
19
                        // Dont know why Qt has chosen to make 'sleep' protected.
 
20
                        class MyThread : public QThread {
 
21
                        public:
 
22
                                static void sleep(unsigned long msecs) { msleep(msecs); }
 
23
                        };
 
24
 
 
25
 
 
26
                };
 
27
 
 
28
                Debug::Debug(){
 
29
                        progress = 0;
 
30
                }
 
31
 
 
32
                Debug::~Debug() {
 
33
                }
 
34
 
 
35
                void Debug::Info(QString input) {
 
36
                        INFO(input);
 
37
                }
 
38
 
 
39
                void Debug::Message(QString input) {
 
40
                        QMessageBox::information(0, "JavaScript Message", input);
 
41
                }
 
42
 
 
43
                void Debug::ShowProgress(QString caption) {
 
44
                        delete(progress); 
 
45
                        progress = new QProgressDialog(caption, "Cancel", 0, 1000, 0);
 
46
                        progress->setWindowModality(Qt::WindowModal);
 
47
                        progress->show();
 
48
 
 
49
                }
 
50
 
 
51
                void Debug::SetProgress(double percentage) {
 
52
                        if (progress) progress->setValue(percentage*1000.0);
 
53
                        qApp->processEvents();
 
54
                }
 
55
 
 
56
                void Debug::HideProgress() {
 
57
                        delete(progress);
 
58
                        progress = 0;
 
59
                }
 
60
 
 
61
                void Debug::Sleep(int ms) {
 
62
                        MyThread::sleep(ms);
 
63
                }
 
64
 
 
65
                void World::addSphere2(Vector3 center, float radius) {
 
66
                        SyntopiaCore::GLEngine::Object3D* o = new SyntopiaCore::GLEngine::Sphere( center.getObj(), radius);
 
67
                        o->setColor(this->rgb, this->alpha);
 
68
                        engine->addObject(o);
 
69
                }
 
70
 
 
71
                void World::setColor2(Vector3 rgb, float alpha) {
 
72
                        this->rgb = rgb.getObj();
 
73
                        this->alpha = alpha;
 
74
                }
 
75
 
 
76
                Vector3::Vector3(){ };
 
77
 
 
78
                Vector3::Vector3(float x, float y, float z){ 
 
79
                        //INFO(QString("Vector3(%1,%2,%3)").arg(x).arg(y).arg(z));
 
80
                        v = SyntopiaCore::Math::Vector3f(x,y,z); 
 
81
                };
 
82
 
 
83
                Vector3::Vector3(const StructureSynth::JavaScriptSupport::Vector3 & vx) : QObject(), QScriptable() {
 
84
                        v = vx.v;
 
85
                        //INFO(QString("Vector3 CopyConstructor(%1,%2,%3)").arg(v.x()).arg(v.y()).arg(v.z()));
 
86
 
 
87
                }
 
88
        }
 
89
}