+/*\r
+* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
+*\r
+* This file is part of CasparCG.\r
+*\r
+* CasparCG is free software: you can redistribute it and/or modify\r
+* it under the terms of the GNU General Public License as published by\r
+* the Free Software Foundation, either version 3 of the License, or\r
+* (at your option) any later version.\r
+*\r
+* CasparCG is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+* GNU General Public License for more details.\r
+\r
+* You should have received a copy of the GNU General Public License\r
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
+*\r
+*/\r
#include "../stdafx.h"\r
\r
#include "graph.h"\r
#pragma warning (disable : 4244)\r
\r
#include "../concurrency/executor.h"\r
-#include "../utility/timer.h"\r
#include "../env.h"\r
\r
#include <SFML/Graphics.hpp>\r
\r
class context : public drawable\r
{ \r
- timer timer_;\r
sf::RenderWindow window_;\r
\r
std::list<std::shared_ptr<drawable>> drawables_;\r
}\r
\r
private:\r
- context()\r
+ context() : executor_(L"diagnostics")\r
{\r
- executor_.start();\r
executor_.begin_invoke([this]\r
- {\r
+ { \r
+ SetThreadPriority(GetCurrentThread(), BELOW_NORMAL_PRIORITY_CLASS);\r
window_.Create(sf::VideoMode(600, 1000), "CasparCG Diagnostics");\r
window_.SetPosition(0, 0);\r
window_.SetActive();\r
glClear(GL_COLOR_BUFFER_BIT);\r
window_.Draw(*this);\r
window_.Display();\r
- timer_.tick(1.0/50.0);\r
+ boost::this_thread::sleep(boost::posix_time::milliseconds(20));\r
executor_.begin_invoke([this]{tick();});\r
}\r
\r
class line : public drawable\r
{\r
boost::optional<diagnostics::guide> guide_;\r
- boost::circular_buffer<std::pair<float, bool>> line_data_;\r
+ boost::circular_buffer<std::pair<double, bool>> line_data_;\r
\r
- std::vector<float> tick_data_;\r
+ std::vector<double> tick_data_;\r
bool tick_tag_;\r
color c_;\r
public:\r
line_data_.push_back(std::make_pair(-1.0f, false));\r
}\r
\r
- void update(float value)\r
+ void update(double value)\r
{\r
tick_data_.push_back(value);\r
}\r
\r
- void set(float value)\r
+ void set(double value)\r
{\r
tick_data_.clear();\r
tick_data_.push_back(value);\r
target.Draw(*guide_);\r
\r
glBegin(GL_LINE_STRIP);\r
- glColor4f(c_.red, c_.green, c_.blue, 1.0f); \r
+ glColor4f(c_.red, c_.green, c_.blue, 0.8f); \r
for(size_t n = 0; n < line_data_.size(); ++n) \r
if(line_data_[n].first > -0.5)\r
- glVertex3f(x+n*dx, std::max(0.05f, std::min(0.95f, (1.0f-line_data_[n].first)*0.8f + 0.1f)), 0.0f); \r
+ glVertex3d(x+n*dx, std::max(0.05, std::min(0.95, (1.0f-line_data_[n].first)*0.8 + 0.1f)), 0.0); \r
glEnd();\r
\r
glEnable(GL_LINE_STIPPLE);\r
, name_(parent_printer_ ? narrow(parent_printer_()) : "")\r
, counter_(0){}\r
\r
- void update(const std::string& name, float value)\r
+ void update(const std::string& name, double value)\r
{\r
- context::begin_invoke([=]\r
- {\r
- lines_[name].update(value);\r
- });\r
+ lines_[name].update(value);\r
}\r
\r
- void set(const std::string& name, float value)\r
+ void set(const std::string& name, double value)\r
{\r
- context::begin_invoke([=]\r
- {\r
- lines_[name].set(value);\r
- });\r
+ lines_[name].set(value);\r
}\r
\r
void tag(const std::string& name)\r
{\r
- context::begin_invoke([=]\r
- {\r
- lines_[name].tag();\r
- });\r
+ lines_[name].tag();\r
}\r
\r
void set_color(const std::string& name, color c)\r
{\r
- context::begin_invoke([=]\r
- {\r
- lines_[name].set_color(c);\r
- });\r
+ lines_[name].set_color(c);\r
}\r
\r
- void guide(const std::string& name, float value)\r
+ void guide(const std::string& name, double value)\r
{\r
- context::begin_invoke([=]\r
- {\r
- lines_[name].guide(diagnostics::guide(value));\r
- });\r
+ lines_[name].guide(diagnostics::guide(value)); \r
}\r
\r
private:\r
context::register_drawable(impl_);\r
}\r
\r
-void graph::update(const std::string& name, float value){if(impl_)impl_->update(name, value);}\r
-void graph::set(const std::string& name, float value){if(impl_)impl_->set(name, value);}\r
-void graph::tag(const std::string& name){if(impl_)impl_->tag(name);}\r
-void graph::guide(const std::string& name, float value){if(impl_)impl_->guide(name, value);}\r
-void graph::set_color(const std::string& name, color c){if(impl_)impl_->set_color(name, c);}\r
+void graph::update_value(const std::string& name, double value)\r
+{\r
+ if(impl_)\r
+ { \r
+ auto p = impl_;\r
+ context::begin_invoke([=]\r
+ { \r
+ p->update(name, value);\r
+ });\r
+ }\r
+}\r
+void graph::set_value(const std::string& name, double value)\r
+{\r
+ if(impl_)\r
+ { \r
+ auto p = impl_;\r
+ context::begin_invoke([=]\r
+ { \r
+ p->set(name, value);\r
+ });\r
+ }\r
+}\r
+void graph::set_color(const std::string& name, color c)\r
+{ \r
+ if(impl_)\r
+ { \r
+ auto p = impl_;\r
+ context::begin_invoke([=]\r
+ { \r
+ p->set_color(name, c);\r
+ });\r
+ }\r
+}\r
+void graph::add_tag(const std::string& name)\r
+{ \r
+ if(impl_)\r
+ { \r
+ auto p = impl_;\r
+ context::begin_invoke([=]\r
+ { \r
+ p->tag(name);\r
+ });\r
+ }\r
+}\r
+void graph::add_guide(const std::string& name, double value)\r
+{ \r
+ if(impl_)\r
+ { \r
+ auto p = impl_;\r
+ context::begin_invoke([=]\r
+ { \r
+ p->guide(name, value);\r
+ });\r
+ }\r
+}\r
\r
safe_ptr<graph> create_graph(const std::string& name)\r
{\r