summaryrefslogtreecommitdiffstats
path: root/Project/Text.cpp
blob: 25c9b85de31007cbeac5fce43623b010ff0f4c9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "Text.h"

#include "Bus.h"
#include "Line.h"
#include "Transformer.h"
#include "SyncGenerator.h"
#include "IndMotor.h"
#include "SyncMotor.h"
#include "Load.h"
#include "Inductor.h"
#include "Capacitor.h"

Text::Text() : Element()
{
    SetText(m_text);
}

Text::Text(wxPoint2DDouble position) : Element()
{
    SetText(m_text);
    SetPosition(position);
}

Text::~Text() {}

bool Text::Contains(wxPoint2DDouble position) const
{
    wxPoint2DDouble ptR = RotateAtPosition(position, -m_angle);
    return m_rect.Contains(ptR);
}

void Text::Draw(wxPoint2DDouble translation, double scale, wxDC& dc)
{
    if(consolidate) {
        glString.setFont(wxFont(10, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
        glString.consolidate(&dc);
        //glString.bind();
        consolidate = false;
    }
    /*if(m_selected) {
        glColor4d(0.0, 0.5, 1.0, 0.5);
        wxGLString backSelection(m_text);
        backSelection.setFont(wxFont(10, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
        backSelection.consolidate(&dc);
        backSelection.bind();
        backSelection.render(m_position.m_x, m_position.m_y);
    }*/
    
    glColor4d(0.0, 0.0, 0.0, 1.0);
    //glString.render(m_position.m_x, m_position.m_y);
}

bool Text::Intersects(wxRect2DDouble rect) const
{
    if(m_angle == 0.0 || m_angle == 180.0) return m_rect.Intersects(rect);
    return RotatedRectanglesIntersects(m_rect, rect, m_angle, 0.0);
}

void Text::SetText(wxString text)
{
    m_text = text;
    glString = text;
    
    consolidate = true;
}