~gimaker/peekabot/coord-sys-default

« back to all changes in this revision

Viewing changes to src/gui/Decorator.cc

  • Committer: Staffan Gimåker
  • Date: 2009-06-29 10:09:26 UTC
  • mfrom: (665.1.39 renderer-redux)
  • Revision ID: staffan@gimaker.se-20090629100926-ju5kx8jwzy422rwu
Merged the renderer-redux branch.

This represents a major overhaul to the rendering engine, with a less contrived
design and better performance. Both memory and CPU utilization should be 
better in general.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
 
1
/*
 
2
 * Copyright Anders Boberg 2007.
 
3
 * Copyright Staffan Gimåker 2008-2009.
 
4
 *
 
5
 * ---
 
6
 *
2
7
 * This file is part of peekabot.
3
8
 *
4
9
 * peekabot is free software; you can redistribute it and/or modify
16
21
 */
17
22
 
18
23
#include <boost/bind.hpp>
19
 
#include <iostream>
20
24
 
21
25
#include "Decorator.hh"
22
 
#include "../IDTranslationTable.hh"
23
26
#include "UserInterfaceUtilities.hh"
24
 
#include "../renderer/Renderer.hh"
25
27
#include "Manipulator.hh"
 
28
#include "../actions/SetSelected.hh"
 
29
#include "../RendererRelay.hh"
 
30
#include "../renderer/api/Renderer.hh"
26
31
 
27
32
 
28
33
using namespace peekabot;
29
34
using namespace peekabot::gui;
30
 
using peekabot::renderer::TheRenderer;
31
35
 
32
36
 
33
37
Decorator::Decorator(UserInterfaceUtilities &uiu)
60
64
        boost::bind(&Decorator::selection_changed, this, _1, true));
61
65
    m_uiu.on_object_deselected().disconnect(
62
66
        boost::bind(&Decorator::selection_changed, this, _1, false));
63
 
    
 
67
 
64
68
    if(m_uiu.get_manipulator() != 0)
65
69
    {
66
70
        m_uiu.get_manipulator()->get_mode_signal().disconnect(
76
80
 
77
81
void Decorator::selection_changed(ObjectID id, bool selected) throw()
78
82
{
79
 
    NodeID node_id = TheIDTranslationTable::instance().get_node_id(id);
80
 
 
81
 
    if( selected )
82
 
        TheRenderer::instance().select_node(node_id);
83
 
    else
84
 
        TheRenderer::instance().deselect_node(node_id);
 
83
    m_uiu.post_action(new SetSelected(id, selected));
85
84
}
86
85
 
87
86
void Decorator::mode_changed(ManipulatorMode mode) throw()
88
87
{
89
 
    //std::cout << "mode=" << mode << std::endl;
 
88
    renderer::api::Renderer &r = TheRendererRelay::instance().get_renderer();
90
89
 
91
90
    if( mode == MOVE_MODE )
92
91
    {
93
 
        TheRenderer::instance().set_transformation_guides_mode(
 
92
        r.set_transformation_guides_mode(
94
93
            renderer::MOVE_TRANSFORMATION_GUIDES);
95
 
        TheRenderer::instance().set_transformation_guides_coord_sys(
 
94
        r.set_transformation_guides_coord_sys(
96
95
            m_uiu.get_manipulator()->get_system());
97
 
        TheRenderer::instance().set_transformation_guides_axes(
 
96
        r.set_transformation_guides_axes(
98
97
            m_uiu.get_manipulator()->get_axes());
99
98
    }
100
99
    else if( mode == ROTATE_MODE )
101
100
    {
102
 
        TheRenderer::instance().set_transformation_guides_mode(
 
101
        r.set_transformation_guides_mode(
103
102
            renderer::ROTATE_TRANSFORMATION_GUIDES);
104
 
        TheRenderer::instance().set_transformation_guides_coord_sys(
 
103
        r.set_transformation_guides_coord_sys(
105
104
            m_uiu.get_manipulator()->get_system());
106
 
        TheRenderer::instance().set_transformation_guides_axes(
 
105
        r.set_transformation_guides_axes(
107
106
            m_uiu.get_manipulator()->get_axes());
108
 
        TheRenderer::instance().set_transformation_guides_pivot(
 
107
        r.set_transformation_guides_pivot(
109
108
            m_uiu.get_manipulator()->get_pivot());
110
109
    }
111
110
    else
112
111
    {
113
 
        TheRenderer::instance().set_transformation_guides_mode(
 
112
        r.set_transformation_guides_mode(
114
113
            renderer::NO_TRANSFORMATION_GUIDES);
115
114
    }
116
115
}
117
116
 
118
117
void Decorator::coordinate_system_changed(CoordinateSystem coord_sys) throw()
119
118
{
120
 
    //std::cout << "coord_sys=" << coord_sys << std::endl;
121
 
 
122
 
    TheRenderer::instance().set_transformation_guides_coord_sys(coord_sys);
 
119
    renderer::api::Renderer &r = TheRendererRelay::instance().get_renderer();
 
120
    r.set_transformation_guides_coord_sys(coord_sys);
123
121
}
124
122
 
125
123
 
126
124
void Decorator::pivot_changed(RotationCenterpoint pivot) throw()
127
125
{
128
 
    TheRenderer::instance().set_transformation_guides_pivot(pivot);
 
126
    renderer::api::Renderer &r = TheRendererRelay::instance().get_renderer();
 
127
    r.set_transformation_guides_pivot(pivot);
129
128
}
130
129
 
131
130
 
132
131
void Decorator::axes_changed(Axis axes) throw()
133
132
{
134
 
    TheRenderer::instance().set_transformation_guides_axes(axes);
 
133
    renderer::api::Renderer &r = TheRendererRelay::instance().get_renderer();
 
134
    r.set_transformation_guides_axes(axes);
135
135
}
136
136