diff --git a/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.cpp b/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.cpp index 2a8dc2d8d857ac50af4d3d03cc18d08eb856305e..8336691be5355264aef9a6d0049473802d8fd6fe 100644 --- a/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.cpp +++ b/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.cpp @@ -53,6 +53,11 @@ void ControllerMainWindow::setTrackerList(QStringListModel *trackerList) dynamic_cast<MainWindow*>(m_View)->setTrackerList(trackerList); } +void ControllerMainWindow::setTrackerParamterWidget(IView *widget) +{ + dynamic_cast<MainWindow*>(m_View)->addTrackerParameterView(widget); +} + void ControllerMainWindow::createModel() { // no model for MainWindow diff --git a/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.h b/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.h index 750b8c164f45adc858e60bfeb65dd8750a245534..b25db6bcb0778392493f1a7f3c522d8269d8802a 100644 --- a/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.h +++ b/BioTracker/CoreApp/BioTracker/Controller/ControllerMainWindow.h @@ -18,6 +18,7 @@ public: void activeTracking(); void deactiveTrackring(); void setTrackerList(QStringListModel *trackerList); + void setTrackerParamterWidget(IView* widget); // IController interface diff --git a/BioTracker/CoreApp/BioTracker/Controller/ControllerPlugin.cpp b/BioTracker/CoreApp/BioTracker/Controller/ControllerPlugin.cpp index b13c070aca73214bacc7126c9f787075687a4943..baab2536fd200cccb873826bf399ba86e9fb9b81 100644 --- a/BioTracker/CoreApp/BioTracker/Controller/ControllerPlugin.cpp +++ b/BioTracker/CoreApp/BioTracker/Controller/ControllerPlugin.cpp @@ -18,11 +18,15 @@ void ControllerPlugin::loadPluginFromFileName(QString str) if( loader->loadPluginFromFilename(str)) { createPlugin(); + // Add Plugin name to Main Window IController * ctrA = m_BioTrackerContext->requestController(ENUMS::CONTROLLERTYPE::MAINWINDOW); QPointer< ControllerMainWindow > ctrMainWindow = qobject_cast<ControllerMainWindow *>(ctrA); ctrMainWindow->setTrackerList(qobject_cast<PluginLoader *>(m_Model)->getPluginMetaData()); + //Add Tracker Parameter to Main Window + ctrMainWindow->setTrackerParamterWidget(m_BioTrackerPlugin->getTrackerParameterWidget()); + } } diff --git a/BioTracker/CoreApp/BioTracker/View/MainWindow.cpp b/BioTracker/CoreApp/BioTracker/View/MainWindow.cpp index be95b59cdefd1dcb9b40038353f3e4a4184255b4..0f06db3fcb5b6b54347140d2358d4c084903bcea 100644 --- a/BioTracker/CoreApp/BioTracker/View/MainWindow.cpp +++ b/BioTracker/CoreApp/BioTracker/View/MainWindow.cpp @@ -47,6 +47,14 @@ void MainWindow::addVideoView(IView *videoView) //ui->videoViewLayout->addWidget(dynamic_cast<BioTracker3VideoView *>(videoView)); } +void MainWindow::addTrackerParameterView(IView *parameter) +{ + dynamic_cast<QWidget*>(parameter)->setParent(this); + + ui->scrollArea->setWidget(dynamic_cast<QWidget *>(parameter)); + ui->scrollArea->setWidgetResizable(true); +} + void MainWindow::setTrackerList(QStringListModel *trackerList) { ui->comboBox_TrackerSelect->setModel(trackerList); diff --git a/BioTracker/CoreApp/BioTracker/View/MainWindow.h b/BioTracker/CoreApp/BioTracker/View/MainWindow.h index be5c2451bcfdb95019d800919024145eb74c58d4..b9cec6c615be0689b16262dd578823e90f4e8047 100644 --- a/BioTracker/CoreApp/BioTracker/View/MainWindow.h +++ b/BioTracker/CoreApp/BioTracker/View/MainWindow.h @@ -25,7 +25,7 @@ public: void addVideoControllWidget(IView *widget); void addVideoView(IView *videoView); - + void addTrackerParameterView(IView *parameter); void setTrackerList(QStringListModel *trackerList); private Q_SLOTS: diff --git a/BioTracker/Interfaces/BioTrackerInterfaces/Interfaces/IBioTrackerPlugin.h b/BioTracker/Interfaces/BioTrackerInterfaces/Interfaces/IBioTrackerPlugin.h index a1fbf6d2203f756262d9c03ba233789d47f3d8e7..0bc8dbf1134475e9a30658acbb7f0c377be86a94 100644 --- a/BioTracker/Interfaces/BioTrackerInterfaces/Interfaces/IBioTrackerPlugin.h +++ b/BioTracker/Interfaces/BioTrackerInterfaces/Interfaces/IBioTrackerPlugin.h @@ -15,6 +15,8 @@ public: virtual void createPlugin() = 0; + virtual IView *getTrackerParameterWidget() = 0; + private: virtual void connectInterfaces() = 0; diff --git a/BioTracker/Plugin/BioTrackerPlugin/BioTrackerPlugin.cpp b/BioTracker/Plugin/BioTrackerPlugin/BioTrackerPlugin.cpp index 9bc9737e65f82a1e634185fda699d9fbeec765bf..c94ebf4293a86e4edfbf6b2956cd61ad316325b6 100644 --- a/BioTracker/Plugin/BioTrackerPlugin/BioTrackerPlugin.cpp +++ b/BioTracker/Plugin/BioTrackerPlugin/BioTrackerPlugin.cpp @@ -6,6 +6,11 @@ BioTrackerPlugin::BioTrackerPlugin() { } +IView *BioTrackerPlugin::getTrackerParameterWidget() +{ + return qobject_cast<ControllerTrackingAlgorithm *> (m_TrackerController)->getTrackingParameterWidget(); +} + #if QT_VERSION < 0x050000 Q_EXPORT_PLUGIN2(BioTrackerPlugin, BioTrackerPlugin) #endif // QT_VERSION < 0x050000 diff --git a/BioTracker/Plugin/BioTrackerPlugin/BioTrackerPlugin.h b/BioTracker/Plugin/BioTrackerPlugin/BioTrackerPlugin.h index 7709423c15a93f649e5eceb39307ea2f9f2cea22..98fe4fac40bd9da48e1a9107520ffea927d4c34e 100644 --- a/BioTracker/Plugin/BioTrackerPlugin/BioTrackerPlugin.h +++ b/BioTracker/Plugin/BioTrackerPlugin/BioTrackerPlugin.h @@ -21,6 +21,8 @@ public: BioTrackerPlugin(); // IBioTrackerPlugin interface + IView *getTrackerParameterWidget(); + public: void createPlugin(); @@ -41,6 +43,7 @@ private slots: private: IController *m_TrackerController; + }; #endif // BIOTRACKERPLUGIN_H diff --git a/BioTracker/Plugin/BioTrackerPlugin/BioTrackerPlugin.pro b/BioTracker/Plugin/BioTrackerPlugin/BioTrackerPlugin.pro index 6ea9a3f2159fa90c262ab081cd37ef05d74d6a6a..54ff62f50d7d759b360b4f90b39b615e05dbe9e3 100644 --- a/BioTracker/Plugin/BioTrackerPlugin/BioTrackerPlugin.pro +++ b/BioTracker/Plugin/BioTrackerPlugin/BioTrackerPlugin.pro @@ -38,7 +38,9 @@ SOURCES += BioTrackerPlugin.cpp \ Controller/ControllerTrackingAlgorithm.cpp \ Controller/null_Controller.cpp \ Controller/ControllerTrackedComponent.cpp \ - View/TrackedElementView.cpp + View/TrackedElementView.cpp \ + Model/TrackerParameter.cpp \ + View/TrackerParameterView.cpp HEADERS += BioTrackerPlugin.h\ @@ -51,7 +53,9 @@ HEADERS += BioTrackerPlugin.h\ Controller/ControllerTrackingAlgorithm.h \ Controller/null_Controller.h \ Controller/ControllerTrackedComponent.h \ - View/TrackedElementView.h + View/TrackedElementView.h \ + Model/TrackerParameter.h \ + View/TrackerParameterView.h unix { @@ -61,3 +65,6 @@ unix { DISTFILES += \ BioTrackerPlugin.json + +FORMS += \ + View/TrackerParameterView.ui diff --git a/BioTracker/Plugin/BioTrackerPlugin/Controller/ControllerTrackingAlgorithm.cpp b/BioTracker/Plugin/BioTrackerPlugin/Controller/ControllerTrackingAlgorithm.cpp index a5f5cb86eb750f0c62264629f2ef8bf03004a2fe..139bdac401a9f12534b3d418117c8caf884f1061 100644 --- a/BioTracker/Plugin/BioTrackerPlugin/Controller/ControllerTrackingAlgorithm.cpp +++ b/BioTracker/Plugin/BioTrackerPlugin/Controller/ControllerTrackingAlgorithm.cpp @@ -1,5 +1,8 @@ #include "ControllerTrackingAlgorithm.h" +#include "Model/TrackerParameter.h" +#include "View/TrackerParameterView.h" + ControllerTrackingAlgorithm::ControllerTrackingAlgorithm(QObject *parent, IBioTrackerContext *context, ENUMS::CONTROLLERTYPE ctr) : IController(parent, context, ctr) { @@ -16,14 +19,20 @@ void ControllerTrackingAlgorithm::doTracking(std::shared_ptr<cv::Mat> mat, uint qobject_cast<BioTrackerTrackingAlgorithm *>(m_Model)->doTracking(mat, number); } +IView *ControllerTrackingAlgorithm::getTrackingParameterWidget() +{ + return m_View; +} + void ControllerTrackingAlgorithm::createModel() { - m_Model = new BioTrackerTrackingAlgorithm(); + m_TrackingParameter = new TrackerParameter(this); + m_Model = new BioTrackerTrackingAlgorithm(m_TrackingParameter); } void ControllerTrackingAlgorithm::createView() { - + m_View = new TrackerParameterView(0, this, m_TrackingParameter); } void ControllerTrackingAlgorithm::connectModelToController() diff --git a/BioTracker/Plugin/BioTrackerPlugin/Controller/ControllerTrackingAlgorithm.h b/BioTracker/Plugin/BioTrackerPlugin/Controller/ControllerTrackingAlgorithm.h index 260bf58ee5cb80a834869d2201d223e0d5ed08a5..1f6cb7171bbdb03b57603290566362ff53ada6ba 100644 --- a/BioTracker/Plugin/BioTrackerPlugin/Controller/ControllerTrackingAlgorithm.h +++ b/BioTracker/Plugin/BioTrackerPlugin/Controller/ControllerTrackingAlgorithm.h @@ -18,6 +18,8 @@ public: void doTracking(std::shared_ptr<cv::Mat> mat, uint number); + IView *getTrackingParameterWidget(); + protected: void createModel() override; void createView() override; @@ -30,6 +32,10 @@ Q_SIGNALS: private Q_SLOTS: void receiveCvMatFromTrackingAlgorithm(std::shared_ptr<cv::Mat> mat, QString name); void receiveTrackingDone(); + + +private: + IModel* m_TrackingParameter; }; #endif // CONTROLLERTRACKINGALGORITHM_H diff --git a/BioTracker/Plugin/BioTrackerPlugin/Model/BioTrackerTrackingAlgorithm.cpp b/BioTracker/Plugin/BioTrackerPlugin/Model/BioTrackerTrackingAlgorithm.cpp index e211c1077ce0bf43490bc71d5ef2581f2af78b13..30953670c38036bfc939d8e46d864d5bbcabfd0b 100644 --- a/BioTracker/Plugin/BioTrackerPlugin/Model/BioTrackerTrackingAlgorithm.cpp +++ b/BioTracker/Plugin/BioTrackerPlugin/Model/BioTrackerTrackingAlgorithm.cpp @@ -1,7 +1,8 @@ #include "BioTrackerTrackingAlgorithm.h" -BioTrackerTrackingAlgorithm::BioTrackerTrackingAlgorithm() +BioTrackerTrackingAlgorithm::BioTrackerTrackingAlgorithm(IModel *parameter) { + m_TrackingParameter = parameter; // setTrackedComponentFactory(factory); } diff --git a/BioTracker/Plugin/BioTrackerPlugin/Model/BioTrackerTrackingAlgorithm.h b/BioTracker/Plugin/BioTrackerPlugin/Model/BioTrackerTrackingAlgorithm.h index ed0388197ef87c0049bd0d76ec9846c938bf30cd..9a657b46113b7419bf87c7e0b4daef4616345426 100644 --- a/BioTracker/Plugin/BioTrackerPlugin/Model/BioTrackerTrackingAlgorithm.h +++ b/BioTracker/Plugin/BioTrackerPlugin/Model/BioTrackerTrackingAlgorithm.h @@ -17,7 +17,7 @@ class BioTrackerTrackingAlgorithm : public IModelTrackingAlgorithm { Q_OBJECT public: - BioTrackerTrackingAlgorithm(/*QObject *parent = 0, ITrackedComponentFactory *factory = 0*/); + BioTrackerTrackingAlgorithm(IModel* parameter/*QObject *parent = 0, ITrackedComponentFactory *factory = 0*/); Q_SIGNALS: void emitCvMatA(std::shared_ptr<cv::Mat> image, QString name); @@ -29,6 +29,8 @@ Q_SIGNALS: private: TrackedElement *m_TrackedElement; + + IModel* m_TrackingParameter; }; #endif // BIOTRACKERTRACKINGALGORITHM_H diff --git a/BioTracker/Plugin/BioTrackerPlugin/Model/TrackerParameter.cpp b/BioTracker/Plugin/BioTrackerPlugin/Model/TrackerParameter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..43384a1f707cbf67d1d721c4b84c90339e2b2794 --- /dev/null +++ b/BioTracker/Plugin/BioTrackerPlugin/Model/TrackerParameter.cpp @@ -0,0 +1,21 @@ +#include "TrackerParameter.h" + +TrackerParameter::TrackerParameter(QObject *parent) : + IModel(parent) +{ + m_Threshold = 12345; + + Q_EMIT notifyView(); +} + +void TrackerParameter::setThreshold(int x) +{ + m_Threshold = x; + + Q_EMIT notifyView(); +} + +int TrackerParameter::getThreshold() +{ + return m_Threshold; +} diff --git a/BioTracker/Plugin/BioTrackerPlugin/Model/TrackerParameter.h b/BioTracker/Plugin/BioTrackerPlugin/Model/TrackerParameter.h new file mode 100644 index 0000000000000000000000000000000000000000..51074e7ffdc9fccfcfebe9c4565685e2c424842f --- /dev/null +++ b/BioTracker/Plugin/BioTrackerPlugin/Model/TrackerParameter.h @@ -0,0 +1,21 @@ +#ifndef TRACKERPARAMETER_H +#define TRACKERPARAMETER_H + + +#include "Interfaces/IModel/IModel.h" + +class TrackerParameter : public IModel +{ + Q_OBJECT +public: + TrackerParameter(QObject *parent = 0); + + void setThreshold(int x); + + int getThreshold(); + +private: + int m_Threshold; +}; + +#endif // TRACKERPARAMETER_H diff --git a/BioTracker/Plugin/BioTrackerPlugin/View/TrackerParameterView.cpp b/BioTracker/Plugin/BioTrackerPlugin/View/TrackerParameterView.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f4cb3b6af4c9968f5e2059ff8d20ce41bf133874 --- /dev/null +++ b/BioTracker/Plugin/BioTrackerPlugin/View/TrackerParameterView.cpp @@ -0,0 +1,34 @@ +#include "TrackerParameterView.h" +#include "ui_TrackerParameterView.h" + +TrackerParameterView::TrackerParameterView(QWidget *parent, IController *controller, IModel *model) : + IViewWidget(parent, controller, model), + ui(new Ui::TrackerParameterView) +{ + ui->setupUi(this); + + ui->lineEdit->setValidator( new QIntValidator(this)); + + getNotified(); +} + +TrackerParameterView::~TrackerParameterView() +{ + delete ui; +} + +void TrackerParameterView::on_pushButton_clicked() +{ + int threshold = ui->lineEdit->text().toInt(); + + TrackerParameter *parameter = qobject_cast<TrackerParameter *>(getModel()); + parameter->setThreshold(threshold); +} + +void TrackerParameterView::getNotified() +{ + TrackerParameter *parameter = qobject_cast<TrackerParameter *>(getModel()); + int threshold = parameter->getThreshold(); + + ui->lineEdit->setText(QString::number(threshold)); +} diff --git a/BioTracker/Plugin/BioTrackerPlugin/View/TrackerParameterView.h b/BioTracker/Plugin/BioTrackerPlugin/View/TrackerParameterView.h new file mode 100644 index 0000000000000000000000000000000000000000..e3252a0c0b7c3da1daaf8d4ebd0d4ff0fad71701 --- /dev/null +++ b/BioTracker/Plugin/BioTrackerPlugin/View/TrackerParameterView.h @@ -0,0 +1,31 @@ +#ifndef TRACKERPARAMETERVIEW_H +#define TRACKERPARAMETERVIEW_H + +#include "Interfaces/IView/IViewWidget.h" +#include "Model/TrackerParameter.h" + +namespace Ui { +class TrackerParameterView; +} + +class TrackerParameterView : public IViewWidget +{ + Q_OBJECT + +public: + explicit TrackerParameterView(QWidget *parent = 0, IController *controller = 0, IModel *model = 0); + ~TrackerParameterView(); + +private slots: + void on_pushButton_clicked(); + +private: + Ui::TrackerParameterView *ui; + + // IViewWidget interface +public slots: + + void getNotified(); +}; + +#endif // TRACKERPARAMETERVIEW_H diff --git a/BioTracker/Plugin/BioTrackerPlugin/View/TrackerParameterView.ui b/BioTracker/Plugin/BioTrackerPlugin/View/TrackerParameterView.ui new file mode 100644 index 0000000000000000000000000000000000000000..19e5471bf3ff753195bdfe87827c376639cc10e6 --- /dev/null +++ b/BioTracker/Plugin/BioTrackerPlugin/View/TrackerParameterView.ui @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>TrackerParameterView</class> + <widget class="QWidget" name="TrackerParameterView"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>168</width> + <height>106</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Threshold</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit"/> + </item> + </layout> + </item> + <item row="1" column="0"> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>Set Values</string> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui>