-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathControllerTextureObject.cpp
More file actions
118 lines (85 loc) · 3.53 KB
/
Copy pathControllerTextureObject.cpp
File metadata and controls
118 lines (85 loc) · 3.53 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include "ControllerTextureObject.h"
#include "../biotracker_gui/biotracker/View/BioTracker3VideoView.h"
#include "../biotracker_gui/biotracker/View/BioTracker3MainWindow.h"
#include "Controller/ControllerGraphicScene.h"
#include "Controller/ControllerPlayer.h"
#include "Model/BioTracker3Player.h"
#include "../biotracker_gui/biotracker/View/TextureObjectView.h"
ControllerTextureObject::ControllerTextureObject(QObject *parent, IBioTrackerContext *context, ENUMS::CONTROLLERTYPE ctr) :
IController(parent, context, ctr)
{
m_TextureViewNamesModel= new QStringListModel();
m_TextureViewNamesModel->setStringList(m_TextureViewNames);
}
void ControllerTextureObject::changeTextureModel(QString name)
{
if(name == QString("") )
name = m_DefaultTextureName;
checkIfTextureModelExists(name);
m_Model = m_TextureObjects.value(name);
changeTextureView(m_Model);
}
void ControllerTextureObject::addTextureElementView(IView *view)
{
//dynamic_cast<BioTracker3VideoView *>(m_View)->addTrackedElementView(view);
}
void ControllerTextureObject::connectController()
{
// IController *ctrM = m_BioTrackerContext->requestController(ENUMS::CONTROLLERTYPE::MAINWINDOW);
// BioTracker3MainWindow *mainWin = dynamic_cast<BioTracker3MainWindow *>(ctrM->getView());
// mainWin->addVideoView(m_View);
IController *ctr = m_BioTrackerContext->requestController(ENUMS::CONTROLLERTYPE::PLAYER);
ControllerPlayer *ctrPlayer = dynamic_cast<ControllerPlayer *>(ctr);
BioTracker3Player *player = dynamic_cast<BioTracker3Player *>(ctrPlayer->getModel());
QObject::connect(player, &BioTracker3Player::emitCurrentFrame, this, &ControllerTextureObject::receiveCvMat);
BioTracker3VideoControllWidget *videoView = dynamic_cast<BioTracker3VideoControllWidget *> (ctrPlayer->getView());
videoView->setVideoViewComboboxModel(m_TextureViewNamesModel);
IController *ctrG = m_BioTrackerContext->requestController(ENUMS::CONTROLLERTYPE::GRAPHICSVIEW);
ControllerGraphicScene *ctrGraphics = dynamic_cast<ControllerGraphicScene *>(ctrG);
QGraphicsPixmapItem *item = dynamic_cast<QGraphicsPixmapItem *>(m_View);
ctrGraphics->addTextureObject(item);
}
void ControllerTextureObject::receiveCvMat(cv::Mat mat, QString name)
{
checkIfTextureModelExists(name);
m_TextureObjects.value(name)->set(mat);
}
void ControllerTextureObject::createModel()
{
createNewTextureObjectModel(m_DefaultTextureName);
m_Model = m_TextureObjects.value(m_DefaultTextureName);
}
void ControllerTextureObject::createView()
{
m_View = new TextureObjectView(this, this, m_Model);
// this is the gl widget
// m_View = new BioTracker3VideoView(0, this, m_Model);
}
void ControllerTextureObject::connectModelController()
{
}
void ControllerTextureObject::checkIfTextureModelExists(QString name)
{
if(name == QString("") )
name = m_DefaultTextureName;
bool itemIsInList = false;
for (int i = 0 ; i < m_TextureViewNames.size(); ++i) {
if (m_TextureViewNames.at(i) == name) {
itemIsInList = true;
}
}
if (!itemIsInList) {
createNewTextureObjectModel(name);
}
}
void ControllerTextureObject::createNewTextureObjectModel(QString name)
{
BioTracker3TextureObject *newTextureModel = new BioTracker3TextureObject(this, name);
m_TextureObjects.insert(name, newTextureModel);
m_TextureViewNames.append(name);
m_TextureViewNamesModel->setStringList(m_TextureViewNames);
}
void ControllerTextureObject::changeTextureView(IModel *model)
{
m_View->setNewModel(model);
}