diff --git a/BaseToolkit.cpp b/BaseToolkit.cpp index 8234193..26dafd6 100644 --- a/BaseToolkit.cpp +++ b/BaseToolkit.cpp @@ -85,7 +85,8 @@ std::string BaseToolkit::byte_to_string(long b) ++i; numbytes /= 1024.0; } - oss << std::fixed << std::setprecision(2) << numbytes << *i; + oss << std::fixed << std::setprecision(2) << numbytes; + if (i != list.end()) oss << *i; return oss.str(); } @@ -102,7 +103,8 @@ std::string BaseToolkit::bits_to_string(long b) ++i; numbytes /= 1000.0; } - oss << std::fixed << std::setprecision(2) << numbytes << *i; + oss << std::fixed << std::setprecision(2) << numbytes; + if (i != list.end()) oss << *i; return oss.str(); } diff --git a/Connection.cpp b/Connection.cpp index d41a05c..b0cf80c 100644 --- a/Connection.cpp +++ b/Connection.cpp @@ -157,7 +157,8 @@ void Connection::listen() #ifdef CONNECTION_DEBUG Log::Info("Accepting handshake on port %d", Connection::manager().connections_[0].port_handshake); #endif - Connection::manager().receiver_->Run(); + if (Connection::manager().receiver_) + Connection::manager().receiver_->Run(); } void Connection::ask() diff --git a/Decorations.cpp b/Decorations.cpp index 1572631..d8e6726 100644 --- a/Decorations.cpp +++ b/Decorations.cpp @@ -249,7 +249,7 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection) init(); } - if ( visible_ ) { + if ( visible_ && handle_) { static Mesh *handle_active = new Mesh("mesh/border_handles_overlay_filled.ply"); // set color diff --git a/GeometryView.cpp b/GeometryView.cpp index aaa5425..f54e084 100644 --- a/GeometryView.cpp +++ b/GeometryView.cpp @@ -224,7 +224,7 @@ void GeometryView::draw() scene.accept(draw_overlays); // 4. Draw control overlays of current source on top (if selectable) - if (canSelect(s)) { + if (s!=nullptr && canSelect(s)) { s->setMode(Source::CURRENT); DrawVisitor dv(s->overlays_[mode_], projection); scene.accept(dv); @@ -411,39 +411,40 @@ std::pair GeometryView::pick(glm::vec2 P) if (current->workspace() != Settings::application.current_workspace){ current = nullptr; } - - // find if the current source was picked - auto itp = pv.rbegin(); - for (; itp != pv.rend(); ++itp){ - // test if source contains this node - Source::hasNode is_in_source((*itp).first ); - if ( is_in_source( current ) ){ - // a node in the current source was clicked ! - pick = *itp; - break; + else { + // find if the current source was picked + auto itp = pv.rbegin(); + for (; itp != pv.rend(); ++itp){ + // test if source contains this node + Source::hasNode is_in_source((*itp).first ); + if ( is_in_source( current ) ){ + // a node in the current source was clicked ! + pick = *itp; + break; + } + } + // not found: the current source was not clicked + if (itp == pv.rend()) { + current = nullptr; + } + // picking on the menu handle: show context menu + else if ( pick.first == current->handles_[mode_][Handles::MENU] ) { + openContextMenu(MENU_SOURCE); + } + // pick on the lock icon; unlock source + else if ( UserInterface::manager().ctrlModifier() && pick.first == current->lock_ ) { + lock(current, false); + pick = { nullptr, glm::vec2(0.f) }; + } + // pick on the open lock icon; lock source and cancel pick + else if ( UserInterface::manager().ctrlModifier() && pick.first == current->unlock_ ) { + lock(current, true); + pick = { nullptr, glm::vec2(0.f) }; + } + // pick a locked source ; cancel pick + else if ( current->locked() ) { + pick = { nullptr, glm::vec2(0.f) }; } - } - // not found: the current source was not clicked - if (itp == pv.rend()) { - current = nullptr; - } - // picking on the menu handle: show context menu - else if ( pick.first == current->handles_[mode_][Handles::MENU] ) { - openContextMenu(MENU_SOURCE); - } - // pick on the lock icon; unlock source - else if ( UserInterface::manager().ctrlModifier() && pick.first == current->lock_ ) { - lock(current, false); - pick = { nullptr, glm::vec2(0.f) }; - } - // pick on the open lock icon; lock source and cancel pick - else if ( UserInterface::manager().ctrlModifier() && pick.first == current->unlock_ ) { - lock(current, true); - pick = { nullptr, glm::vec2(0.f) }; - } - // pick a locked source ; cancel pick - else if ( current->locked() ) { - pick = { nullptr, glm::vec2(0.f) }; } } // the clicked source changed (not the current source) @@ -516,7 +517,7 @@ std::pair GeometryView::pick(glm::vec2 P) bool GeometryView::canSelect(Source *s) { - return ( View::canSelect(s) && s->ready() && s->active() && s->workspace() == Settings::application.current_workspace); + return ( s!=nullptr && View::canSelect(s) && s->ready() && s->active() && s->workspace() == Settings::application.current_workspace); } diff --git a/GlmToolkit.cpp b/GlmToolkit.cpp index b9b8817..8dba6d1 100644 --- a/GlmToolkit.cpp +++ b/GlmToolkit.cpp @@ -57,6 +57,16 @@ GlmToolkit::AxisAlignedBoundingBox::AxisAlignedBoundingBox() : { } +GlmToolkit::AxisAlignedBoundingBox::AxisAlignedBoundingBox(const GlmToolkit::AxisAlignedBoundingBox &D) : + mMin(D.mMin), mMax(D.mMax) +{ +} + +void GlmToolkit::AxisAlignedBoundingBox::operator = (const GlmToolkit::AxisAlignedBoundingBox &D ) { + mMin = D.mMin; + mMax = D.mMax; +} + void GlmToolkit::AxisAlignedBoundingBox::extend(const glm::vec3& point) { if (isNull()) { diff --git a/GlmToolkit.h b/GlmToolkit.h index 54e3e30..fb25305 100644 --- a/GlmToolkit.h +++ b/GlmToolkit.h @@ -15,11 +15,8 @@ class AxisAlignedBoundingBox { public: AxisAlignedBoundingBox(); - - inline void operator = (const AxisAlignedBoundingBox &D ) { - mMin = D.mMin; - mMax = D.mMax; - } + AxisAlignedBoundingBox(const AxisAlignedBoundingBox &D); + void operator = (const AxisAlignedBoundingBox &D ); // test inline bool isNull() const { return mMin.x > mMax.x || mMin.y > mMax.y || mMin.z > mMax.z;} diff --git a/ImGuiVisitor.cpp b/ImGuiVisitor.cpp index 1260172..8ab2d77 100644 --- a/ImGuiVisitor.cpp +++ b/ImGuiVisitor.cpp @@ -152,14 +152,6 @@ void ImGuiVisitor::visit(FrameBufferSurface &n) ImGui::Text("Framebuffer"); } -void ImGuiVisitor::visit(MediaSurface &n) -{ - ImGui::Text("%s", n.path().c_str()); - - if (n.mediaPlayer()) - n.mediaPlayer()->accept(*this); -} - void ImGuiVisitor::visit(MediaPlayer &n) { ImGui::Text("Media Player"); diff --git a/ImGuiVisitor.h b/ImGuiVisitor.h index 818d625..745124f 100644 --- a/ImGuiVisitor.h +++ b/ImGuiVisitor.h @@ -17,7 +17,6 @@ public: void visit (Group& n) override; void visit (Switch& n) override; void visit (Primitive& n) override; - void visit (MediaSurface& n) override; void visit (FrameBufferSurface& n) override; // Elements with attributes diff --git a/ImageProcessingShader.cpp b/ImageProcessingShader.cpp index 489ce07..65b0a79 100644 --- a/ImageProcessingShader.cpp +++ b/ImageProcessingShader.cpp @@ -12,7 +12,7 @@ const char* ImageProcessingShader::filter_names[12] = { "None", "Blur", "Sharpen ImageProcessingShader::ImageProcessingShader(): Shader() { program_ = &imageProcessingShadingProgram; - reset(); + ImageProcessingShader::reset(); } void ImageProcessingShader::use() diff --git a/ImageShader.cpp b/ImageShader.cpp index 9a2e8f8..d17a677 100644 --- a/ImageShader.cpp +++ b/ImageShader.cpp @@ -27,7 +27,7 @@ ImageShader::ImageShader(): Shader(), stipple(0.f), mask_texture(0) // static program shader program_ = &imageShadingProgram; // reset instance - reset(); + ImageShader::reset(); } void ImageShader::use() @@ -85,7 +85,7 @@ AlphaShader::AlphaShader(): ImageShader() MaskShader::MaskShader(): Shader(), mode(0) { // reset instance - reset(); + MaskShader::reset(); // static program shader program_ = &maskPrograms[0]; } diff --git a/Log.cpp b/Log.cpp index d27e6cb..aafc408 100644 --- a/Log.cpp +++ b/Log.cpp @@ -144,7 +144,10 @@ struct AppLog } }; -static AppLog logs; +AppLog logs; +list notifications; +list warnings; +float notifications_timeout = 0.f; void Log::Info(const char* fmt, ...) { @@ -160,9 +163,6 @@ void Log::ShowLogWindow(bool* p_open) logs.Draw( ICON_FA_LIST_UL " Logs", p_open); } -static list notifications; -static float notifications_timeout = 0.f; - void Log::Notify(const char* fmt, ...) { ImGuiTextBuffer buf; @@ -180,9 +180,6 @@ void Log::Notify(const char* fmt, ...) Log::Info("%s", buf.c_str()); } - -static list warnings; - void Log::Warning(const char* fmt, ...) { ImGuiTextBuffer buf; diff --git a/Mesh.cpp b/Mesh.cpp index e709f84..8d75bf9 100644 --- a/Mesh.cpp +++ b/Mesh.cpp @@ -263,7 +263,6 @@ bool parsePLY(string ascii, break; default: // ignore normals or other types - value = parseValue(stringstream); break; } } diff --git a/Mixer.cpp b/Mixer.cpp index 8773379..578502d 100644 --- a/Mixer.cpp +++ b/Mixer.cpp @@ -36,9 +36,9 @@ #include "Mixer.h" #define THREADED_LOADING -static std::vector< std::future > sessionLoaders_; -static std::vector< std::future > sessionImporters_; -static std::vector< SessionSource * > sessionSourceToImport_; +std::vector< std::future > sessionLoaders_; +std::vector< std::future > sessionImporters_; +std::vector< SessionSource * > sessionSourceToImport_; const std::chrono::milliseconds timeout_ = std::chrono::milliseconds(4); @@ -1165,7 +1165,7 @@ void Mixer::merge(SessionSource *source) void Mixer::swap() { - if (!back_session_) + if (!back_session_ || !session_) return; if (session_) { diff --git a/NetworkToolkit.cpp b/NetworkToolkit.cpp index 9643a31..f93347c 100644 --- a/NetworkToolkit.cpp +++ b/NetworkToolkit.cpp @@ -99,8 +99,7 @@ void add_interface(int fd, const char *name) { strncpy(ifreq.ifr_name, name, IFNAMSIZ); if(ioctl(fd, SIOCGIFADDR, &ifreq)==0) { char host[128]; - int family; - switch(family=ifreq.ifr_addr.sa_family) { + switch(ifreq.ifr_addr.sa_family) { case AF_INET: case AF_INET6: getnameinfo(&ifreq.ifr_addr, sizeof ifreq.ifr_addr, host, sizeof host, 0, 0, NI_NUMERICHOST); diff --git a/Primitives.cpp b/Primitives.cpp index 167795d..50d5344 100644 --- a/Primitives.cpp +++ b/Primitives.cpp @@ -121,52 +121,6 @@ void ImageSurface::accept(Visitor& v) v.visit(*this); } -MediaSurface::MediaSurface(const std::string& p, Shader *s) : Surface(s), path_(p) -{ - mediaplayer_ = new MediaPlayer; -} - -MediaSurface::~MediaSurface() -{ - delete mediaplayer_; -} - -void MediaSurface::init() -{ - Surface::init(); - - mediaplayer_->open(path_); - mediaplayer_->play(true); -} - -void MediaSurface::draw(glm::mat4 modelview, glm::mat4 projection) -{ - if ( !initialized() ) { - init(); - // set the texture to the media player once openned - if ( mediaplayer_->isOpen() ) - textureindex_ = mediaplayer_->texture(); - } - - Surface::draw(modelview, projection); -} - -void MediaSurface::update( float dt ) -{ - if ( mediaplayer_->isOpen() ) { - mediaplayer_->update(); - scale_.x = mediaplayer_->aspectRatio(); - } - - Primitive::update( dt ); -} - -void MediaSurface::accept(Visitor& v) -{ - Surface::accept(v); - v.visit(*this); -} - FrameBufferSurface::FrameBufferSurface(FrameBuffer *fb, Shader *s) : Surface(s), frame_buffer_(fb) { } @@ -401,6 +355,24 @@ LineSquare::LineSquare(float linewidth) : Group() } +LineSquare::LineSquare(const LineSquare &square) +{ + top_ = new HLine(square.top_->width); + top_->translation_ = glm::vec3(0.f, 1.f, 0.f); + attach(top_); + bottom_ = new HLine(square.bottom_->width); + bottom_->translation_ = glm::vec3(0.f, -1.f, 0.f); + attach(bottom_); + left_ = new VLine(square.left_->width); + left_->translation_ = glm::vec3(-1.f, 0.f, 0.f); + attach(left_); + right_ = new VLine(square.right_->width); + right_->translation_ = glm::vec3(1.f, 0.f, 0.f); + attach(right_); + + setColor(square.color()); +} + void LineSquare::setLineWidth(float v) { top_->width = v; @@ -417,7 +389,6 @@ void LineSquare::setColor(glm::vec4 c) right_->color = c; } - LineStrip::LineStrip(const std::vector &path, float linewidth) : Primitive(new Shader), arrayBuffer_(0), path_(path) { diff --git a/Primitives.h b/Primitives.h index 9114154..3e09694 100644 --- a/Primitives.h +++ b/Primitives.h @@ -62,31 +62,6 @@ protected: }; -/** - * @brief The MediaSurface class is a Surface to draw a video - * - * URI is passed to a Media Player to handle the video playback - * Height = 1.0, Width is set by the aspect ratio of the image - */ -class MediaSurface : public Surface { - -public: - MediaSurface(const std::string& p, Shader *s = new ImageShader); - ~MediaSurface(); - - void init () override; - void draw (glm::mat4 modelview, glm::mat4 projection) override; - void accept (Visitor& v) override; - void update (float dt) override; - - inline std::string path() const { return path_; } - inline MediaPlayer *mediaPlayer() const { return mediaplayer_; } - -protected: - std::string path_; - MediaPlayer *mediaplayer_; -}; - /** * @brief The FrameBufferSurface class is a Surface to draw a framebuffer * @@ -166,6 +141,7 @@ class LineSquare : public Group { public: LineSquare(float linewidth = 1.f); + LineSquare(const LineSquare &square); void setLineWidth(float v); inline float lineWidth() const { return top_->width; } diff --git a/RenderingManager.cpp b/RenderingManager.cpp index d2d6b57..39f5f82 100644 --- a/RenderingManager.cpp +++ b/RenderingManager.cpp @@ -100,7 +100,7 @@ void Rendering::LinkPipeline( GstPipeline *pipeline ) #endif -static std::map GLFW_window_; +std::map GLFW_window_; static void glfw_error_callback(int error, const char* description) { diff --git a/Resource.cpp b/Resource.cpp index 64d1829..29bea2d 100644 --- a/Resource.cpp +++ b/Resource.cpp @@ -162,9 +162,8 @@ uint Resource::getTextureDDS(const std::string& path, float *aspect_ratio) uint mipMapCount = *(uint*)&(header[24]); uint fourCC = *(uint*)&(header[80]); - // how big is it going to be including all mipmaps? - uint bufsize; - bufsize = mipMapCount > 1 ? linearSize * 2 : linearSize; + // how big is it going to be including all mipmaps? + uint bufsize = mipMapCount > 1 ? linearSize * 2 : linearSize; // get the buffer = bytes [128 - ] const char *buffer = fp + 128; @@ -188,7 +187,7 @@ uint Resource::getTextureDDS(const std::string& path, float *aspect_ratio) } } - if (height == 0){ + if (height == 0 || bufsize == 0){ Log::Error("Invalid image in ressource %s", std::string(path).c_str()); return 0; } diff --git a/SessionVisitor.cpp b/SessionVisitor.cpp index f343434..cc9ebd5 100644 --- a/SessionVisitor.cpp +++ b/SessionVisitor.cpp @@ -309,14 +309,6 @@ void SessionVisitor::visit(FrameBufferSurface &) xmlCurrent_->SetAttribute("type", "FrameBufferSurface"); } -void SessionVisitor::visit(MediaSurface &n) -{ - // Node of a different type - xmlCurrent_->SetAttribute("type", "MediaSurface"); - - n.mediaPlayer()->accept(*this); -} - void SessionVisitor::visit(MediaPlayer &n) { XMLElement *newelement = xmlDoc_->NewElement("MediaPlayer"); diff --git a/SessionVisitor.h b/SessionVisitor.h index 935e75b..e2a4c8b 100644 --- a/SessionVisitor.h +++ b/SessionVisitor.h @@ -40,7 +40,6 @@ public: void visit (Primitive& n) override; void visit (Surface&) override; void visit (ImageSurface& n) override; - void visit (MediaSurface& n) override; void visit (FrameBufferSurface&) override; void visit (LineStrip& n) override; void visit (LineSquare&) override; diff --git a/Settings.cpp b/Settings.cpp index c06b03d..c61b5fb 100644 --- a/Settings.cpp +++ b/Settings.cpp @@ -13,8 +13,7 @@ using namespace tinyxml2; Settings::Application Settings::application; - -static string settingsFilename = ""; +string settingsFilename = ""; void Settings::Save() { diff --git a/Shader.cpp b/Shader.cpp index 18ccb6a..1333fd9 100644 --- a/Shader.cpp +++ b/Shader.cpp @@ -206,7 +206,7 @@ Shader::Shader() : blending(BLEND_OPACITY) id_ = BaseToolkit::uniqueId(); program_ = &simpleShadingProgram; - reset(); + Shader::reset(); } diff --git a/Stream.cpp b/Stream.cpp index 3ea5d8c..4a5c654 100644 --- a/Stream.cpp +++ b/Stream.cpp @@ -56,7 +56,7 @@ Stream::Stream() Stream::~Stream() { - close(); + Stream::close(); // cleanup opengl texture if (textureindex_) diff --git a/Timeline.cpp b/Timeline.cpp index c46e156..94ae38e 100644 --- a/Timeline.cpp +++ b/Timeline.cpp @@ -302,8 +302,7 @@ size_t Timeline::fillSectionsArrays( float* const gaps, float* const fading) if (gaps_.size() > 0) { // indices to define [s e[] sections - size_t s = 0; - size_t e = MAX_TIMELINE_ARRAY; + size_t s = 0, e; arraysize = 0; auto it = gaps_.begin(); diff --git a/Timeline.h b/Timeline.h index 0ddc232..9e37bf8 100644 --- a/Timeline.h +++ b/Timeline.h @@ -18,6 +18,11 @@ struct TimeInterval { reset(); } + TimeInterval(const TimeInterval& b) + { + begin = b.begin; + end = b.end; + } TimeInterval(GstClockTime a, GstClockTime b) : TimeInterval() { if ( a != GST_CLOCK_TIME_NONE && b != GST_CLOCK_TIME_NONE) { diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 7f900c9..03dfb5f 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -66,7 +66,7 @@ using namespace std; #include "ImageProcessingShader.h" #include "TextEditor.h" -static TextEditor editor; +TextEditor editor; #include "UserInterfaceManager.h" #define PLOT_ARRAY_SIZE 180 @@ -85,14 +85,14 @@ void SetNextWindowVisible(ImVec2 pos, ImVec2 size, float margin = 180.f); const std::chrono::milliseconds timeout = std::chrono::milliseconds(4); static std::atomic fileDialogPending_ = false; -static std::vector< std::future > saveSessionFileDialogs; -static std::vector< std::future > openSessionFileDialogs; -static std::vector< std::future > importSessionFileDialogs; -static std::vector< std::future > fileImportFileDialogs; -static std::vector< std::future > recentFolderFileDialogs; -static std::vector< std::future > recordFolderFileDialogs; +std::vector< std::future > saveSessionFileDialogs; +std::vector< std::future > openSessionFileDialogs; +std::vector< std::future > importSessionFileDialogs; +std::vector< std::future > fileImportFileDialogs; +std::vector< std::future > recentFolderFileDialogs; +std::vector< std::future > recordFolderFileDialogs; -static std::vector< std::future > _video_recorders; +std::vector< std::future > _video_recorders; FrameGrabber *delayTrigger(FrameGrabber *g, std::chrono::milliseconds delay) { std::this_thread::sleep_for (delay); return g; @@ -1181,7 +1181,7 @@ void UserInterface::RenderPreview() else openInitializeSystemLoopback = true; } - else { + else if (webcam_emulator_ != nullptr) { webcam_emulator_->stop(); webcam_emulator_ = nullptr; } @@ -1651,15 +1651,18 @@ void UserInterface::RenderMetrics(bool *p_open, int* p_corner, int *p_mode) ImGui::Text("%s", GstToolkit::time_to_string(time_-start_time_1_, GstToolkit::TIME_STRING_FIXED).c_str()); ImGui::PopFont(); ImGui::SameLine(0, 10); + ImGui::PushID( "timermetric1" ); if (ImGuiToolkit::IconButton(12, 14)) start_time_1_ = time_; // reset timer 1 + ImGui::PopID(); ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE); ImGui::Text("%s", GstToolkit::time_to_string(time_-start_time_2_, GstToolkit::TIME_STRING_FIXED).c_str()); ImGui::PopFont(); ImGui::SameLine(0, 10); + ImGui::PushID( "timermetric2" ); if (ImGuiToolkit::IconButton(12, 14)) start_time_2_ = time_; // reset timer 2 - + ImGui::PopID(); } else { ImGuiToolkit::PushFont(ImGuiToolkit::FONT_MONO); @@ -1987,7 +1990,7 @@ SourceController::SourceController() : min_width_(0.f), h_space_(0.f), v_space_( timeline_height_(0.f), scrollbar_(0.f), mediaplayer_height_(0.f), buttons_width_(0.f), active_label_(LABEL_AUTO_MEDIA_PLAYER), active_selection_(-1), selection_context_menu_(false), selection_mediaplayer_(nullptr), selection_target_slower_(0), selection_target_faster_(0), - mediaplayer_active_(nullptr), mediaplayer_mode_(false), mediaplayer_slider_pressed_(false), mediaplayer_timeline_zoom_(1.f) + mediaplayer_active_(nullptr), mediaplayer_edit_fading_(false), mediaplayer_mode_(false), mediaplayer_slider_pressed_(false), mediaplayer_timeline_zoom_(1.f) { info_.setExtendedStringMode(); } diff --git a/Visitor.h b/Visitor.h index af4dc0f..e54a6fc 100644 --- a/Visitor.h +++ b/Visitor.h @@ -11,7 +11,6 @@ class Primitive; class Scene; class Surface; class ImageSurface; -class MediaSurface; class FrameBufferSurface; class LineStrip; class LineSquare; @@ -54,7 +53,6 @@ public: // not mandatory for all others virtual void visit (Surface&) {} virtual void visit (ImageSurface&) {} - virtual void visit (MediaSurface&) {} virtual void visit (FrameBufferSurface&) {} virtual void visit (LineStrip&) {} virtual void visit (LineSquare&) {}