~ubuntu-branches/ubuntu/wily/ginkgocadx/wily-proposed

« back to all changes in this revision

Viewing changes to src/cadxcore/widgets/welipse.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2013-10-24 21:28:17 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20131024212817-ej1skb9og09d3ht6
Tags: 3.5.0.1137.31+dfsg-1
New upstream release [October 2013]

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *  $Id: welipse.cpp $
4
4
 *  Ginkgo CADx Project
5
5
 *
6
 
 *  Copyright 2008-12 MetaEmotion S.L. All rights reserved.
 
6
 *  Copyright 2008-14 MetaEmotion S.L. All rights reserved.
7
7
 *  http://ginkgo-cadx.com
8
8
 *
9
9
 *  This file is licensed under LGPL v3 license.
52
52
 
53
53
                m_Stop = evento.iP;
54
54
 
55
 
                m_BB[0].Asignar(m_Start.x, m_Start.y);
56
 
                m_BB[1].Asignar(m_Stop.x, m_Start.y);
57
 
                m_BB[2].Asignar(m_Stop.x, m_Stop.y);
58
 
                m_BB[3].Asignar(m_Start.x, m_Stop.y);
 
55
                GNC::GCS::Vector a = m_Start.ProyeccionOrtogonalSobreRecta(m_Stop,  m_Stop - evento.c->ScreenDirectionCosines[0]);              
 
56
                GNC::GCS::Vector b = m_Start.ProyeccionOrtogonalSobreRecta(m_Stop,  m_Stop - evento.c->ScreenDirectionCosines[1]);
 
57
                m_BB[0] = m_Start;
 
58
                m_BB[1] = a;
 
59
                m_BB[2] = m_Stop;
 
60
                m_BB[3] = b;
59
61
 
60
62
 
61
63
                TVector diff = m_Stop - m_Start;
65
67
                        bBox[1] = m_BB[2];
66
68
                        GNC::GCS::Vector::OrdenarBoundingBox(bBox);
67
69
 
 
70
                        TVector centro = m_BB[0].PuntoMedio(m_BB[2]);
 
71
 
 
72
                        TVector m_RadioMayor = m_BB[0] - m_BB[1];
 
73
                        TVector m_RadioMenor = m_BB[0] - m_BB[3];
 
74
 
 
75
                        /*
68
76
                        TVector centro = bBox[0].PuntoMedio(bBox[1]);
69
77
 
70
78
                        TVector radio1(bBox[1].x - centro.x, 0.0f);
71
79
                        TVector radio2(0.0f, bBox[1].y - centro.y);
 
80
                        */
72
81
 
73
 
                        WElipse* w = new WElipse(centro, radio1, radio2, m_pManager, evento.c->GetRenderer()->GetVID(), "Elipse", m_GID);
 
82
                        WElipse* w = new WElipse(centro, m_RadioMayor/2, m_RadioMenor/2, m_pManager, evento.c->GetRenderer()->GetVID(), "Elipse", m_GID);
74
83
                        m_pManager->InsertarWidget(w);
75
84
                        m_pManager->LanzarEventoCreacion(w);
76
85
                        ConsumirEvento();
88
97
                m_Start = evento.iP;
89
98
                m_Stop = m_Start;
90
99
 
91
 
                m_BB[0].Asignar(m_Start.x, m_Start.y);
92
 
                m_BB[1].Asignar(m_Stop.x, m_Start.y);
93
 
                m_BB[2].Asignar(m_Stop.x, m_Stop.y);
94
 
                m_BB[3].Asignar(m_Start.x, m_Stop.y);
 
100
                GNC::GCS::Vector a = m_Start.ProyeccionOrtogonalSobreRecta(m_Stop,  m_Stop - evento.c->ScreenDirectionCosines[0]);              
 
101
                GNC::GCS::Vector b = m_Start.ProyeccionOrtogonalSobreRecta(m_Stop,  m_Stop - evento.c->ScreenDirectionCosines[1]);
 
102
                m_BB[0] = m_Start;
 
103
                m_BB[1] = a;
 
104
                m_BB[2] = m_Stop;
 
105
                m_BB[3] = b;
95
106
 
96
107
                m_pManager->Modificado();
97
108
                m_Estado = WBS_Creando;
104
115
 
105
116
                m_Stop = evento.iP;
106
117
 
107
 
                m_BB[0].Asignar(m_Start.x, m_Start.y);
108
 
                m_BB[1].Asignar(m_Stop.x, m_Start.y);
109
 
                m_BB[2].Asignar(m_Stop.x, m_Stop.y);
110
 
                m_BB[3].Asignar(m_Start.x, m_Stop.y);
 
118
                GNC::GCS::Vector a = m_Start.ProyeccionOrtogonalSobreRecta(m_Stop,  m_Stop - evento.c->ScreenDirectionCosines[0]);              
 
119
                GNC::GCS::Vector b = m_Start.ProyeccionOrtogonalSobreRecta(m_Stop,  m_Stop - evento.c->ScreenDirectionCosines[1]);
 
120
                m_BB[0] = m_Start;
 
121
                m_BB[1] = a;
 
122
                m_BB[2] = m_Stop;
 
123
                m_BB[3] = b;
111
124
 
112
125
                m_pManager->Modificado();
113
126
                evento.Skip(false);
128
141
{
129
142
 
130
143
        if (m_Estado == WBS_Creando) {
131
 
 
132
 
 
133
144
                TVector centro = m_BB[0].PuntoMedio(m_BB[2]);
134
 
                TVector radios = ((m_BB[2] - m_BB[0]) / 2.0f).ValorAbsoluto();
135
 
 
 
145
 
 
146
                TVector m_RadioMayor = m_BB[0] - m_BB[1];
 
147
                TVector m_RadioMenor = m_BB[0] - m_BB[3];
 
148
 
 
149
                double m_NormaRadioMayor = m_RadioMayor.Norma2()/2;
 
150
                double m_NormaRadioMenor = m_RadioMenor.Norma2()/2;
 
151
 
 
152
                double m_Angulo = m_RadioMayor.AnguloSobreAbscisa();
 
153
                
136
154
                float step = M_2PI / 100;
137
155
 
138
156
                glLineWidth(2.0f);
141
159
 
142
160
                        for ( float angulo = 0; angulo < M_2PI; angulo += step)
143
161
                        {
144
 
                                glVertex3f(centro.x + (radios.x * cos (angulo)) , centro.y + (radios.y * sin (angulo)), 0.0f);
 
162
                                GNC::GCS::Vector v (m_NormaRadioMayor * cos(angulo), m_NormaRadioMenor * sin(angulo));
 
163
                                v = centro + v.RotacionSobreZ(m_Angulo);
 
164
                                glVertex3f(v.x , v.y, 0.0f);
145
165
                        }
146
166
 
147
167
                glEnd();
148
 
 
149
168
        }
150
169
        else {
151
170
 
161
180
 
162
181
//region "Constructor y destructor"
163
182
 
164
 
GNC::GCS::Widgets::WElipse::WElipse(TVector centro, TVector radio1, TVector radio2, IWidgetsManager* pManager, long vid, const char* nombre, long gid) : GNC::GCS::Widgets::IWidget(pManager, vid, nombre, gid), GNC::GCS::Widgets::IWidgetSerializable()
 
183
GNC::GCS::Widgets::WElipse::WElipse(TVector centro, TVector radio1, TVector radio2, IWidgetsManager* pManager, long vid, const char* nombre, long gid) : GNC::GCS::Widgets::IWidget(pManager, vid, nombre, gid,TID_USER_ANNOTATION_WIDGET), GNC::GCS::Widgets::IWidgetSerializable()
165
184
{
166
185
        m_Centro = centro;
167
186
        m_RadioMayor = radio1;