From f443720319e7168387b3c02a8a616c1345e12811 Mon Sep 17 00:00:00 2001 From: brunoherbelin Date: Sun, 4 Apr 2021 13:13:06 +0200 Subject: [PATCH] Programming style improvement: following Cppcheck suggestions. --- BoundingBoxVisitor.cpp | 5 +- Connection.cpp | 8 +- Decorations.cpp | 2 +- DeviceSource.cpp | 20 ++--- DrawVisitor.cpp | 12 ++- DrawVisitor.h | 2 +- FrameGrabber.cpp | 2 +- GarbageVisitor.cpp | 2 +- GeometryView.cpp | 15 ++-- GlmToolkit.cpp | 6 +- ImGuiToolkit.cpp | 31 +++---- ImageShader.cpp | 4 +- LayerView.cpp | 10 +-- LayerView.h | 1 - Log.cpp | 2 +- Mesh.cpp | 9 +- Mixer.cpp | 8 +- MixingView.cpp | 29 +++---- NetworkSource.cpp | 8 +- NetworkToolkit.cpp | 6 +- PatternSource.cpp | 2 +- PickingVisitor.cpp | 10 +-- Primitives.cpp | 9 +- Primitives.h | 4 +- RenderingManager.cpp | 5 +- Resource.cpp | 10 +-- Scene.cpp | 22 +++-- SearchVisitor.cpp | 4 +- Session.cpp | 14 ++- SessionCreator.cpp | 6 +- SessionSource.cpp | 5 +- SessionVisitor.cpp | 2 +- Settings.cpp | 10 +-- Shader.cpp | 9 +- Source.cpp | 10 +-- SourceList.cpp | 16 ++-- SourceList.h | 12 +-- Stream.cpp | 6 +- Streamer.cpp | 12 +-- Streamer.h | 2 +- SystemToolkit.cpp | 64 +++++++------- TextureView.cpp | 8 +- Timeline.cpp | 8 +- Timeline.h | 2 +- TransitionView.cpp | 2 +- UpdateCallback.cpp | 2 +- UserInterfaceManager.cpp | 90 +++++++++++--------- UserInterfaceManager.h | 4 +- View.cpp | 2 +- ext/OSCPack/ip/posix/UdpSocket.cpp | 2 +- ext/OSCPack/osc/OscPrintReceivedElements.cpp | 4 +- 51 files changed, 269 insertions(+), 271 deletions(-) diff --git a/BoundingBoxVisitor.cpp b/BoundingBoxVisitor.cpp index b9e51e7..cd0baab 100644 --- a/BoundingBoxVisitor.cpp +++ b/BoundingBoxVisitor.cpp @@ -11,9 +11,8 @@ #include "BoundingBoxVisitor.h" -BoundingBoxVisitor::BoundingBoxVisitor(bool force): force_(force) +BoundingBoxVisitor::BoundingBoxVisitor(bool force): force_(force), modelview_(glm::identity()) { - modelview_ = glm::identity(); } @@ -39,7 +38,7 @@ void BoundingBoxVisitor::visit(Group &n) if (!n.visible_) return; glm::mat4 mv = modelview_; - for (NodeSet::iterator node = n.begin(); node != n.end(); node++) { + for (NodeSet::iterator node = n.begin(); node != n.end(); ++node) { if ( (*node)->visible_ || force_) (*node)->accept(*this); modelview_ = mv; diff --git a/Connection.cpp b/Connection.cpp index 9693069..d41a05c 100644 --- a/Connection.cpp +++ b/Connection.cpp @@ -114,10 +114,10 @@ ConnectionInfo Connection::info(int index) struct hasName: public std::unary_function { - inline bool operator()(const ConnectionInfo elem) const { + inline bool operator()(const ConnectionInfo &elem) const { return (elem.name.compare(_a) == 0); } - hasName(std::string a) : _a(a) { } + explicit hasName(const std::string &a) : _a(a) { } private: std::string _a; }; @@ -185,7 +185,7 @@ void Connection::ask() // check the list of connections for non responding (disconnected) std::vector< ConnectionInfo >::iterator it = Connection::manager().connections_.begin(); - for(it++; it!=Connection::manager().connections_.end(); ) { + for(++it; it!=Connection::manager().connections_.end(); ) { // decrease life score (*it).alive--; // erase connection if its life score is negative (not responding too many times) @@ -201,7 +201,7 @@ void Connection::ask() } // loop else - it++; + ++it; } } diff --git a/Decorations.cpp b/Decorations.cpp index ef02e64..7fe27cf 100644 --- a/Decorations.cpp +++ b/Decorations.cpp @@ -240,7 +240,6 @@ void Handles::update( float dt ) void Handles::draw(glm::mat4 modelview, glm::mat4 projection) { - static Mesh *handle_active = new Mesh("mesh/border_handles_overlay_filled.ply"); if ( !initialized() ) { if(handle_ && !handle_->initialized()) @@ -251,6 +250,7 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection) } if ( visible_ ) { + static Mesh *handle_active = new Mesh("mesh/border_handles_overlay_filled.ply"); // set color handle_->shader()->color = color; diff --git a/DeviceSource.cpp b/DeviceSource.cpp index a3b638c..80e3350 100644 --- a/DeviceSource.cpp +++ b/DeviceSource.cpp @@ -167,9 +167,9 @@ void Device::remove(const char *device) break; } - nameit++; - descit++; - coit++; + ++nameit; + ++descit; + ++coit; } } @@ -257,7 +257,7 @@ struct hasDevice: public std::unary_function inline bool operator()(const DeviceSource* elem) const { return (elem && elem->device() == _d); } - hasDevice(std::string d) : _d(d) { } + explicit hasDevice(const std::string &d) : _d(d) { } private: std::string _d; }; @@ -360,7 +360,7 @@ void DeviceSource::setDevice(const std::string &devicename) DeviceConfigSet confs = Device::manager().config(index); #ifdef DEVICE_DEBUG Log::Info("Device %s supported configs:", devicename.c_str()); - for( DeviceConfigSet::iterator it = confs.begin(); it != confs.end(); it++ ){ + for( DeviceConfigSet::iterator it = confs.begin(); it != confs.end(); ++it ){ float fps = static_cast((*it).fps_numerator) / static_cast((*it).fps_denominator); Log::Info(" - %s %s %d x %d %.1f fps", (*it).stream.c_str(), (*it).format.c_str(), (*it).width, (*it).height, fps); } @@ -431,11 +431,11 @@ DeviceConfigSet Device::getDeviceConfigs(const std::string &src_description) // get the first pad and its content GstIterator *iter = gst_element_iterate_src_pads(elem); GValue vPad = G_VALUE_INIT; - GstPad* ret = NULL; + GstPad* pad_ret = NULL; if (gst_iterator_next(iter, &vPad) == GST_ITERATOR_OK) { - ret = GST_PAD(g_value_get_object(&vPad)); - GstCaps *device_caps = gst_pad_query_caps (ret, NULL); + pad_ret = GST_PAD(g_value_get_object(&vPad)); + GstCaps *device_caps = gst_pad_query_caps (pad_ret, NULL); // loop over all caps offered by the pad int C = gst_caps_get_size(device_caps); @@ -508,8 +508,8 @@ DeviceConfigSet Device::getDeviceConfigs(const std::string &src_description) gdouble fps_max = 1.0; // loop over all fractions int N = gst_value_list_get_size(val); - for (int n = 0; n < N; n++ ){ - const GValue *frac = gst_value_list_get_value(val, n); + for (int i = 0; i < N; ++i ){ + const GValue *frac = gst_value_list_get_value(val, i); // read one fraction in the list if ( GST_VALUE_HOLDS_FRACTION(frac)) { int n = gst_value_get_fraction_numerator(frac); diff --git a/DrawVisitor.cpp b/DrawVisitor.cpp index 0943e84..c7aa8ec 100644 --- a/DrawVisitor.cpp +++ b/DrawVisitor.cpp @@ -16,13 +16,11 @@ DrawVisitor::DrawVisitor(Node *nodetodraw, glm::mat4 projection, bool force): fo transform_duplicat_ = glm::identity(); } -DrawVisitor::DrawVisitor(std::vector nodestodraw, glm::mat4 projection, bool force): force_(force) +DrawVisitor::DrawVisitor(const std::vector &nodestodraw, glm::mat4 projection, bool force): + force_(force), targets_(nodestodraw), modelview_(glm::identity()), + projection_(projection), num_duplicat_(1), transform_duplicat_(glm::identity()) { - targets_ = nodestodraw; - modelview_ = glm::identity(); - projection_ = projection; - num_duplicat_ = 1; - transform_duplicat_ = glm::identity(); + } void DrawVisitor::loop(int num, glm::mat4 transform) @@ -70,7 +68,7 @@ void DrawVisitor::visit(Group &n) // traverse children glm::mat4 mv = modelview_; - for (NodeSet::iterator node = n.begin(); !targets_.empty() && node != n.end(); node++) { + for (NodeSet::iterator node = n.begin(); !targets_.empty() && node != n.end(); ++node) { if ( (*node)->visible_ || force_) (*node)->accept(*this); modelview_ = mv; diff --git a/DrawVisitor.h b/DrawVisitor.h index fa5dd7c..ce4d4bf 100644 --- a/DrawVisitor.h +++ b/DrawVisitor.h @@ -15,7 +15,7 @@ class DrawVisitor : public Visitor public: DrawVisitor(Node *nodetodraw, glm::mat4 projection, bool force = false); - DrawVisitor(std::vector nodestodraw, glm::mat4 projection, bool force = false); + DrawVisitor(const std::vector &nodestodraw, glm::mat4 projection, bool force = false); void loop(int num, glm::mat4 transform); diff --git a/FrameGrabber.cpp b/FrameGrabber.cpp index 15f836c..211c7c2 100644 --- a/FrameGrabber.cpp +++ b/FrameGrabber.cpp @@ -53,7 +53,7 @@ struct fgId: public std::unary_function inline bool operator()(const FrameGrabber* elem) const { return (elem && elem->id() == _id); } - fgId(uint64_t id) : _id(id) { } + explicit fgId(uint64_t id) : _id(id) { } private: uint64_t _id; }; diff --git a/GarbageVisitor.cpp b/GarbageVisitor.cpp index 9fde05f..6ffada8 100644 --- a/GarbageVisitor.cpp +++ b/GarbageVisitor.cpp @@ -58,7 +58,7 @@ void GarbageVisitor::visit(Group &n) // loop over members of a group // and stop when found - for (NodeSet::iterator node = n.begin(); !found_ && node != n.end(); node++) { + for (NodeSet::iterator node = n.begin(); !found_ && node != n.end(); ++node) { // visit the child node (*node)->accept(*this); // un-stack recursive browsing diff --git a/GeometryView.cpp b/GeometryView.cpp index 0145419..580efcd 100644 --- a/GeometryView.cpp +++ b/GeometryView.cpp @@ -136,10 +136,10 @@ void GeometryView::update(float dt) FrameBuffer *output = Mixer::manager().session()->frame(); if (output){ float aspect_ratio = output->aspectRatio(); - for (NodeSet::iterator node = scene.bg()->begin(); node != scene.bg()->end(); node++) { + for (NodeSet::iterator node = scene.bg()->begin(); node != scene.bg()->end(); ++node) { (*node)->scale_.x = aspect_ratio; } - for (NodeSet::iterator node = scene.fg()->begin(); node != scene.fg()->end(); node++) { + for (NodeSet::iterator node = scene.fg()->begin(); node != scene.fg()->end(); ++node) { (*node)->scale_.x = aspect_ratio; } output_surface_->setTextureIndex( output->texture() ); @@ -271,7 +271,6 @@ void GeometryView::draw() show_context_menu_ = MENU_NONE; } if (ImGui::BeginPopup("GeometrySourceContextMenu")) { - Source *s = Mixer::manager().currentSource(); if (s != nullptr) { if (ImGui::Selectable( ICON_FA_EXPAND " Fit" )){ s->group(mode_)->scale_ = glm::vec3(output_surface_->scale_.x/ s->frame()->aspectRatio(), 1.f, 1.f); @@ -599,8 +598,8 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p // cancel out scaling with SHIFT modifier key if (UserInterface::manager().shiftModifier()) { overlay_rotation_fix_->visible_ = true; - float factor = glm::length( glm::vec2( overlay_selection_->scale_ ) ) / glm::length( glm::vec2( overlay_selection_stored_status_->scale_ ) ); - S = glm::scale(glm::identity(), glm::vec3(factor, factor, 1.f)); + float scale_factor = glm::length( glm::vec2( overlay_selection_->scale_ ) ) / glm::length( glm::vec2( overlay_selection_stored_status_->scale_ ) ); + S = glm::scale(glm::identity(), glm::vec3(scale_factor, scale_factor, 1.f)); } // compute rotation angle @@ -908,9 +907,9 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p overlay_rotation_fix_->copyTransform(overlay_rotation_); overlay_rotation_clock_->visible_ = false; // rotation center to center of source (disregarding scale) - glm::mat4 T = glm::translate(glm::identity(), s->stored_status_->translation_); - source_from = glm::inverse(T) * glm::vec4( scene_from, 1.f ); - source_to = glm::inverse(T) * glm::vec4( scene_to, 1.f ); + glm::mat4 M = glm::translate(glm::identity(), s->stored_status_->translation_); + source_from = glm::inverse(M) * glm::vec4( scene_from, 1.f ); + source_to = glm::inverse(M) * glm::vec4( scene_to, 1.f ); // compute rotation angle float angle = glm::orientedAngle( glm::normalize(glm::vec2(source_from)), glm::normalize(glm::vec2(source_to))); // apply rotation on Z axis diff --git a/GlmToolkit.cpp b/GlmToolkit.cpp index 5d59f20..3df04aa 100644 --- a/GlmToolkit.cpp +++ b/GlmToolkit.cpp @@ -59,9 +59,9 @@ void GlmToolkit::inverse_transform(glm::mat4 M, glm::vec3 &translation, glm::vec // return angle; //} -GlmToolkit::AxisAlignedBoundingBox::AxisAlignedBoundingBox() { - mMin = glm::vec3(1.f); - mMax = glm::vec3(-1.f); +GlmToolkit::AxisAlignedBoundingBox::AxisAlignedBoundingBox() : + mMin(glm::vec3(1.f)), mMax(glm::vec3(-1.f)) +{ } void GlmToolkit::AxisAlignedBoundingBox::extend(const glm::vec3& point) diff --git a/ImGuiToolkit.cpp b/ImGuiToolkit.cpp index ba0f201..6e3ec3c 100644 --- a/ImGuiToolkit.cpp +++ b/ImGuiToolkit.cpp @@ -82,7 +82,7 @@ void ImGuiToolkit::ButtonSwitch(const char* label, bool* toggle, const char* hel // animation ImGuiContext& g = *GImGui; - float ANIM_SPEED = 0.1f; + const float ANIM_SPEED = 0.1f; if (g.LastActiveId == g.CurrentWindow->GetID(label))// && g.LastActiveIdTimer < ANIM_SPEED) { float t_anim = ImSaturate(g.LastActiveIdTimer / ANIM_SPEED); @@ -278,7 +278,7 @@ bool ImGuiToolkit::ComboIcon (std::vector > icons, std::vect { std::vector >::iterator it_icon = icons.begin(); std::vector::iterator it_label = labels.begin(); - for(int i = 0 ; it_icon != icons.end(); i++, it_icon++, it_label++) { + for(int i = 0 ; it_icon != icons.end(); i++, ++it_icon, ++it_label) { ImGui::PushID( id.sum + i + 1); ImVec2 pos = ImGui::GetCursorScreenPos(); // combo selectable item @@ -309,9 +309,7 @@ void ImGuiToolkit::ShowIconsWindow(bool* p_open) if (textureicons == 0) textureicons = Resource::getTextureDDS("images/icons.dds"); - ImGuiIO& io = ImGui::GetIO(); - float my_tex_w = 640.0; - float my_tex_h = 640.0; + const ImGuiIO& io = ImGui::GetIO(); ImGui::Begin("Icons", p_open); @@ -319,6 +317,8 @@ void ImGuiToolkit::ShowIconsWindow(bool* p_open) ImGui::Image((void*)(intptr_t)textureicons, ImVec2(640, 640)); if (ImGui::IsItemHovered()) { + float my_tex_w = 640.0; + float my_tex_h = 640.0; float zoom = 4.0f; float region_sz = 32.0f; // 64 x 64 icons float region_x = io.MousePos.x - pos.x - region_sz * 0.5f; @@ -394,7 +394,7 @@ bool ImGuiToolkit::TimelineSlider(const char* label, guint64 *time, guint64 star return false; // get style & id - ImGuiContext& g = *GImGui; + const ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const float fontsize = g.FontSize; const ImGuiID id = window->GetID(label); @@ -499,16 +499,12 @@ bool ImGuiToolkit::TimelineSlider(const char* label, guint64 *time, guint64 star ImU32 color = ImGui::GetColorU32( style.Colors[ImGuiCol_Text] ); pos = timeline_bbox.GetTL(); guint64 tick = 0; - float tick_percent = 0.f; char overlay_buf[24]; - ImVec2 overlay_size = ImVec2(0.f, 0.f); - ImVec2 mini = ImVec2(0.f, 0.f); - ImVec2 maxi = ImVec2(0.f, 0.f); // render text duration ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%s", GstToolkit::time_to_string(end, GstToolkit::TIME_STRING_MINIMAL).c_str()); - overlay_size = ImGui::CalcTextSize(overlay_buf, NULL); + ImVec2 overlay_size = ImGui::CalcTextSize(overlay_buf, NULL); ImVec2 duration_label = bbox.GetBR() - overlay_size - ImVec2(3.f, 3.f); if (overlay_size.x > 0.0f) ImGui::RenderTextClipped( duration_label, bbox.Max, overlay_buf, NULL, &overlay_size); @@ -526,8 +522,8 @@ bool ImGuiToolkit::TimelineSlider(const char* label, guint64 *time, guint64 star ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%s", GstToolkit::time_to_string(tick, GstToolkit::TIME_STRING_MINIMAL).c_str()); overlay_size = ImGui::CalcTextSize(overlay_buf, NULL); - mini = ImVec2( pos.x - overlay_size.x / 2.f, pos.y + tick_length ); - maxi = ImVec2( pos.x + overlay_size.x / 2.f, pos.y + tick_length + overlay_size.y ); + ImVec2 mini = ImVec2( pos.x - overlay_size.x / 2.f, pos.y + tick_length ); + ImVec2 maxi = ImVec2( pos.x + overlay_size.x / 2.f, pos.y + tick_length + overlay_size.y ); // do not overlap with label for duration if (maxi.x < duration_label.x) ImGui::RenderTextClipped(mini, maxi, overlay_buf, NULL, &overlay_size); @@ -538,7 +534,7 @@ bool ImGuiToolkit::TimelineSlider(const char* label, guint64 *time, guint64 star // next tick tick += tick_step; - tick_percent = static_cast ( static_cast(tick) / static_cast(end) ); + float tick_percent = static_cast ( static_cast(tick) / static_cast(end) ); pos = ImLerp(timeline_bbox.GetTL(), timeline_bbox.GetTR(), tick_percent); } @@ -616,7 +612,6 @@ bool ImGuiToolkit::InvisibleSliderInt(const char* label, uint *index, uint min, bool ImGuiToolkit::EditPlotLines(const char* label, float *array, int values_count, float values_min, float values_max, const ImVec2 size) { - static uint previous_index = UINT32_MAX; bool array_changed = false; // get window @@ -661,12 +656,12 @@ bool ImGuiToolkit::EditPlotLines(const char* label, float *array, int values_cou // enter edit if widget is active if (ImGui::GetActiveID() == id) { + static uint previous_index = UINT32_MAX; bg_color = colors[ImGuiCol_FrameBgActive]; // keep active area while mouse is pressed if (left_mouse_press) { - float x = (float) values_count * mouse_pos_in_canvas.x / bbox.GetWidth(); uint index = CLAMP( (int) floor(x), 0, values_count-1); @@ -710,8 +705,6 @@ bool ImGuiToolkit::EditPlotLines(const char* label, float *array, int values_cou bool ImGuiToolkit::EditPlotHistoLines(const char* label, float *histogram_array, float *lines_array, int values_count, float values_min, float values_max, bool *released, const ImVec2 size) { - static bool active = false; - static uint previous_index = UINT32_MAX; bool array_changed = false; // get window @@ -763,6 +756,8 @@ bool ImGuiToolkit::EditPlotHistoLines(const char* label, float *histogram_array, bg_color = colors[ImGuiCol_FrameBgActive]; // keep active area while mouse is pressed + static bool active = false; + static uint previous_index = UINT32_MAX; if (mouse_press) { diff --git a/ImageShader.cpp b/ImageShader.cpp index e9a1507..75ab368 100644 --- a/ImageShader.cpp +++ b/ImageShader.cpp @@ -97,8 +97,8 @@ MaskShader::MaskShader(): Shader(), mode(0) void MaskShader::use() { // select program to use - mode = CLAMP(mode, 0, 2); - shape = CLAMP(shape, 0, 4); + mode = MINI(mode, 2); + shape = MINI(shape, 4); program_ = mode < 2 ? mask_programs[mode] : mask_programs[shape+2] ; // actual use of shader program diff --git a/LayerView.cpp b/LayerView.cpp index 7c2d91f..6d0ccab 100644 --- a/LayerView.cpp +++ b/LayerView.cpp @@ -80,7 +80,7 @@ void LayerView::draw() // start loop on selection SourceList::iterator it = Mixer::selection().begin(); float depth_first = (*it)->depth(); - for (; it != Mixer::selection().end(); it++) { + for (; it != Mixer::selection().end(); ++it) { // test if selection is contiguous in layer (i.e. not interrupted) SourceList::iterator inter = Mixer::manager().session()->find(depth_first, (*it)->depth()); if ( inter != Mixer::manager().session()->end() && !Mixer::selection().contains(*inter)){ @@ -118,7 +118,7 @@ void LayerView::draw() SourceList::iterator it = dsl.begin(); float depth = (*it)->depth(); float depth_inc = (dsl.back()->depth() - depth) / static_cast(Mixer::selection().size()-1); - for (it++; it != dsl.end(); it++) { + for (++it; it != dsl.end(); ++it) { depth += depth_inc; (*it)->setDepth(depth); } @@ -129,7 +129,7 @@ void LayerView::draw() SourceList dsl = depth_sorted(Mixer::selection().getCopy()); SourceList::iterator it = dsl.begin(); float depth = (*it)->depth(); - for (it++; it != dsl.end(); it++) { + for (++it; it != dsl.end(); ++it) { depth += LAYER_STEP; (*it)->setDepth(depth); } @@ -140,7 +140,7 @@ void LayerView::draw() SourceList dsl = depth_sorted(Mixer::selection().getCopy()); SourceList::iterator it = dsl.begin(); SourceList::reverse_iterator rit = dsl.rbegin(); - for (; it != dsl.end(); it++, rit++) { + for (; it != dsl.end(); ++it, ++rit) { (*it)->setDepth((*rit)->depth()); } Action::manager().store(std::string("Selection Layer Reverse order.")); @@ -268,7 +268,7 @@ float LayerView::setDepth(Source *s, float d) depth = LAYER_BACKGROUND + LAYER_STEP; // find the front-most souce in the workspace (behind FOREGROUND) - for (NodeSet::iterator node = scene.ws()->begin(); node != scene.ws()->end(); node++) { + for (NodeSet::iterator node = scene.ws()->begin(); node != scene.ws()->end(); ++node) { // place in front of previous sources depth = MAX(depth, (*node)->translation_.z + LAYER_STEP); diff --git a/LayerView.h b/LayerView.h index 74ebc59..967a9c7 100644 --- a/LayerView.h +++ b/LayerView.h @@ -24,7 +24,6 @@ private: void updateSelectionOverlay() override; float aspect_ratio; - Mesh *persp_layer_; Mesh *persp_left_, *persp_right_; Group *frame_; diff --git a/Log.cpp b/Log.cpp index 01d1f35..b46cfbf 100644 --- a/Log.cpp +++ b/Log.cpp @@ -205,7 +205,7 @@ void Log::Render(bool *showWarnings) if (!show_notification && !show_warnings) return; - ImGuiIO& io = ImGui::GetIO(); + const ImGuiIO& io = ImGui::GetIO(); float width = io.DisplaySize.x * 0.4f; float pos = io.DisplaySize.x * 0.3f; diff --git a/Mesh.cpp b/Mesh.cpp index 4ce2697..e709f84 100644 --- a/Mesh.cpp +++ b/Mesh.cpp @@ -31,11 +31,8 @@ typedef struct prop { std::string name; bool is_float; bool is_list; - prop(std::string n, bool t, bool l = false){ - name = n; - is_float = t; - is_list = l; - } + prop(const std::string &n, bool t, bool l = false) : + name(n), is_float(t), is_list(l) { } } plyProperty; typedef std::map > plyElementProperties; @@ -45,9 +42,9 @@ template T parseValue(std::istream& istream) { T v; - char space = ' '; istream >> v; if (!istream.eof()) { + char space = ' '; istream >> space >> std::ws; } diff --git a/Mixer.cpp b/Mixer.cpp index 5a80aef..a7229f6 100644 --- a/Mixer.cpp +++ b/Mixer.cpp @@ -736,7 +736,7 @@ SourceList Mixer::findSources (float depth_from, float depth_to) SourceList found; SourceList dsl = session_->getDepthSortedList(); SourceList::iterator it = dsl.begin(); - for (; it != dsl.end(); it++) { + for (; it != dsl.end(); ++it) { if ( (*it)->depth() > depth_to ) break; if ( (*it)->depth() >= depth_from ) @@ -790,7 +790,7 @@ void Mixer::setCurrentNext() if (session_->numSource() > 0) { SourceList::iterator it = current_source_; - it++; + ++it; if (it == session_->end()) { it = session_->begin(); @@ -810,7 +810,7 @@ void Mixer::setCurrentPrevious() it = session_->end(); } - it--; + --it; setCurrentSource( it ); } } @@ -1063,7 +1063,7 @@ void Mixer::merge(SessionSource *source) float next_depth = to_be_moved.front()->depth(); if ( next_depth < target_depth + need_depth) { SourceList::iterator it = to_be_moved.begin(); - for (; it != to_be_moved.end(); it++) { + for (; it != to_be_moved.end(); ++it) { float scale_depth = (MAX_DEPTH-(*it)->depth()) / (MAX_DEPTH-next_depth); (*it)->setDepth( (*it)->depth() + scale_depth ); } diff --git a/MixingView.cpp b/MixingView.cpp index 5e5534d..9c61720 100644 --- a/MixingView.cpp +++ b/MixingView.cpp @@ -162,13 +162,13 @@ void MixingView::draw() // manipulation of sources in Mixing view if (ImGui::Selectable( ICON_FA_CROSSHAIRS " Center" )){ glm::vec2 center = glm::vec2(0.f, 0.f); - for (SourceList::iterator it = Mixer::selection().begin(); it != Mixer::selection().end(); it++) { + for (SourceList::iterator it = Mixer::selection().begin(); it != Mixer::selection().end(); ++it) { // compute barycenter (1) center += glm::vec2((*it)->group(View::MIXING)->translation_); } // compute barycenter (2) center /= Mixer::selection().size(); - for (SourceList::iterator it = Mixer::selection().begin(); it != Mixer::selection().end(); it++) { + for (SourceList::iterator it = Mixer::selection().begin(); it != Mixer::selection().end(); ++it) { (*it)->group(View::MIXING)->translation_ -= glm::vec3(center, 0.f); (*it)->touch(); } @@ -177,7 +177,7 @@ void MixingView::draw() if (ImGui::Selectable( ICON_FA_HAYKAL " Distribute" )){ SourceList list; glm::vec2 center = glm::vec2(0.f, 0.f); - for (SourceList::iterator it = Mixer::selection().begin(); it != Mixer::selection().end(); it++) { + for (SourceList::iterator it = Mixer::selection().begin(); it != Mixer::selection().end(); ++it) { list.push_back(*it); // compute barycenter (1) center += glm::vec2((*it)->group(View::MIXING)->translation_); @@ -188,13 +188,13 @@ void MixingView::draw() list = mixing_sorted( list, center); // average distance float d = 0.f; - for (SourceList::iterator it = list.begin(); it != list.end(); it++) { + for (SourceList::iterator it = list.begin(); it != list.end(); ++it) { d += glm::distance(glm::vec2((*it)->group(View::MIXING)->translation_), center); } d /= list.size(); // distribute with equal angle float angle = 0.f; - for (SourceList::iterator it = list.begin(); it != list.end(); it++) { + for (SourceList::iterator it = list.begin(); it != list.end(); ++it) { glm::vec2 P = center + glm::rotate(glm::vec2(0.f, d), angle); (*it)->group(View::MIXING)->translation_.x = P.x; (*it)->group(View::MIXING)->translation_.y = P.y; @@ -205,14 +205,14 @@ void MixingView::draw() } if (ImGui::Selectable( ICON_FA_CLOUD_SUN " Expand & hide" )){ SourceList::iterator it = Mixer::selection().begin(); - for (; it != Mixer::selection().end(); it++) { + for (; it != Mixer::selection().end(); ++it) { (*it)->setAlpha(0.f); } Action::manager().store(std::string("Selection Mixing Expand & hide.")); } if (ImGui::Selectable( ICON_FA_SUN " Compress & show" )){ SourceList::iterator it = Mixer::selection().begin(); - for (; it != Mixer::selection().end(); it++) { + for (; it != Mixer::selection().end(); ++it) { (*it)->setAlpha(0.99f); } Action::manager().store(std::string("Selection Mixing Compress & show.")); @@ -586,7 +586,7 @@ void MixingView::setAlpha(Source *s) Group *sourceNode = s->group(mode_); glm::vec2 mix_pos = glm::vec2(DEFAULT_MIXING_TRANSLATION); - for(NodeSet::iterator it = scene.ws()->begin(); it != scene.ws()->end(); it++) { + for(NodeSet::iterator it = scene.ws()->begin(); it != scene.ws()->end(); ++it) { // avoid superposing icons: distribute equally if ( glm::distance(glm::vec2((*it)->translation_), mix_pos) < DELTA_ALPHA) { mix_pos += glm::vec2(-0.03f, 0.03f); @@ -635,25 +635,22 @@ uint textureMixingQuadratic() if (texid == 0) { // generate the texture with alpha exactly as computed for sources GLubyte matrix[CIRCLE_PIXELS*CIRCLE_PIXELS * 4]; - GLfloat luminance = 1.f; - GLfloat alpha = 0.f; - GLfloat distance = 0.f; - int l = -CIRCLE_PIXELS / 2 + 1, c = 0; + int l = -CIRCLE_PIXELS / 2 + 1; for (int i = 0; i < CIRCLE_PIXELS ; ++i) { - c = -CIRCLE_PIXELS / 2 + 1; + int c = -CIRCLE_PIXELS / 2 + 1; for (int j = 0; j < CIRCLE_PIXELS ; ++j) { // distance to the center - distance = sin_quad_texture( (float) c , (float) l ); + GLfloat distance = sin_quad_texture( (float) c , (float) l ); // distance = 1.f - (GLfloat) ((c * c) + (l * l)) / CIRCLE_PIXEL_RADIUS; // quadratic // distance = 1.f - (GLfloat) sqrt( (GLfloat) ((c * c) + (l * l))) / (GLfloat) sqrt(CIRCLE_PIXEL_RADIUS); // linear // transparency - alpha = 255.f * CLAMP( distance , 0.f, 1.f); + GLfloat alpha = 255.f * CLAMP( distance , 0.f, 1.f); GLubyte A = static_cast(alpha); // luminance adjustment - luminance = 255.f * CLAMP( 0.2f + 0.75f * distance, 0.f, 1.f); + GLfloat luminance = 255.f * CLAMP( 0.2f + 0.75f * distance, 0.f, 1.f); GLubyte L = static_cast(luminance); // fill pixel RGBA diff --git a/NetworkSource.cpp b/NetworkSource.cpp index 7915e24..7728f75 100644 --- a/NetworkSource.cpp +++ b/NetworkSource.cpp @@ -67,10 +67,10 @@ void StreamerResponseListener::ProcessMessage( const osc::ReceivedMessage& m, } -NetworkStream::NetworkStream(): Stream(), receiver_(nullptr) +NetworkStream::NetworkStream(): Stream(), + receiver_(nullptr), received_config_(false), connected_(false) { - received_config_ = false; - connected_ = false; + } glm::ivec2 NetworkStream::resolution() const @@ -271,7 +271,7 @@ void NetworkStream::update() NetworkSource::NetworkSource() : StreamSource() { // create stream - stream_ = (Stream *) new NetworkStream; + stream_ = static_cast( new NetworkStream ); // set symbol symbol_ = new Symbol(Symbol::SHARE, glm::vec3(0.75f, 0.75f, 0.01f)); diff --git a/NetworkToolkit.cpp b/NetworkToolkit.cpp index 8209d29..9643a31 100644 --- a/NetworkToolkit.cpp +++ b/NetworkToolkit.cpp @@ -95,10 +95,10 @@ std::vector iplongs_; void add_interface(int fd, const char *name) { struct ifreq ifreq; - char host[128]; memset(&ifreq, 0, sizeof ifreq); strncpy(ifreq.ifr_name, name, IFNAMSIZ); if(ioctl(fd, SIOCGIFADDR, &ifreq)==0) { + char host[128]; int family; switch(family=ifreq.ifr_addr.sa_family) { case AF_INET: @@ -122,14 +122,14 @@ void add_interface(int fd, const char *name) { void list_interfaces() { - struct ifreq *ifreq; - struct ifconf ifconf; char buf[16384]; int fd=socket(PF_INET, SOCK_DGRAM, 0); if(fd > -1) { + struct ifconf ifconf; ifconf.ifc_len=sizeof buf; ifconf.ifc_buf=buf; if(ioctl(fd, SIOCGIFCONF, &ifconf)==0) { + struct ifreq *ifreq; ifreq=ifconf.ifc_req; for(int i=0;i( new Pattern ); // set symbol symbol_ = new Symbol(Symbol::PATTERN, glm::vec3(0.75f, 0.75f, 0.01f)); diff --git a/PickingVisitor.cpp b/PickingVisitor.cpp index d01440a..93f85ff 100644 --- a/PickingVisitor.cpp +++ b/PickingVisitor.cpp @@ -11,15 +11,15 @@ #include -PickingVisitor::PickingVisitor(glm::vec3 coordinates, bool force) : Visitor(), force_(force) +PickingVisitor::PickingVisitor(glm::vec3 coordinates, bool force) : Visitor(), + force_(force), modelview_(glm::mat4(1.f)) { - modelview_ = glm::mat4(1.f); points_.push_back( coordinates ); } -PickingVisitor::PickingVisitor(glm::vec3 selectionstart, glm::vec3 selection_end, bool force) : Visitor(), force_(force) +PickingVisitor::PickingVisitor(glm::vec3 selectionstart, glm::vec3 selection_end, bool force) : Visitor(), + force_(force), modelview_(glm::mat4(1.f)) { - modelview_ = glm::mat4(1.f); points_.push_back( selectionstart ); points_.push_back( selection_end ); } @@ -36,7 +36,7 @@ void PickingVisitor::visit(Group &n) return; glm::mat4 mv = modelview_; - for (NodeSet::iterator node = n.begin(); node != n.end(); node++) { + for (NodeSet::iterator node = n.begin(); node != n.end(); ++node) { if ( (*node)->visible_ || force_) (*node)->accept(*this); modelview_ = mv; diff --git a/Primitives.cpp b/Primitives.cpp index f678a79..167795d 100644 --- a/Primitives.cpp +++ b/Primitives.cpp @@ -121,9 +121,8 @@ void ImageSurface::accept(Visitor& v) v.visit(*this); } -MediaSurface::MediaSurface(const std::string& p, Shader *s) : Surface(s) +MediaSurface::MediaSurface(const std::string& p, Shader *s) : Surface(s), path_(p) { - path_ = p; mediaplayer_ = new MediaPlayer; } @@ -419,9 +418,9 @@ void LineSquare::setColor(glm::vec4 c) } -LineStrip::LineStrip(std::vector path, float linewidth) : Primitive(new Shader), arrayBuffer_(0) +LineStrip::LineStrip(const std::vector &path, float linewidth) : Primitive(new Shader), + arrayBuffer_(0), path_(path) { - path_ = path; linewidth_ = 0.002f * linewidth; for(size_t i = 1; i < path_.size(); ++i) @@ -574,7 +573,7 @@ void LineStrip::accept(Visitor& v) } -LineLoop::LineLoop(std::vector path, float linewidth) : LineStrip(path, linewidth) +LineLoop::LineLoop(const std::vector &path, float linewidth) : LineStrip(path, linewidth) { // close linestrip loop glm::vec3 begin = glm::vec3(path_[path_.size()-1], 0.f); diff --git a/Primitives.h b/Primitives.h index f1d69d8..9114154 100644 --- a/Primitives.h +++ b/Primitives.h @@ -180,7 +180,7 @@ public: class LineStrip : public Primitive { public: - LineStrip(std::vector path, float linewidth = 1.f); + LineStrip(const std::vector &path, float linewidth = 1.f); virtual ~LineStrip(); virtual void init () override; @@ -207,7 +207,7 @@ protected: class LineLoop : public LineStrip { public: - LineLoop(std::vector path, float linewidth = 1.f); + LineLoop(const std::vector &path, float linewidth = 1.f); protected: void updatePath() override; diff --git a/RenderingManager.cpp b/RenderingManager.cpp index 65000ec..6fb1f6d 100644 --- a/RenderingManager.cpp +++ b/RenderingManager.cpp @@ -95,10 +95,9 @@ static void WindowEscapeFullscreen( GLFWwindow *w, int key, int, int action, int static void WindowToggleFullscreen( GLFWwindow *w, int button, int action, int) { - static double seconds = 0.f; - if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) { + static double seconds = 0.f; // detect double clic if ( glfwGetTime() - seconds < 0.2f ) { // toggle fullscreen @@ -242,7 +241,7 @@ void Rendering::draw() // Custom draw std::list::iterator iter; - for (iter=draw_callbacks_.begin(); iter != draw_callbacks_.end(); iter++) + for (iter=draw_callbacks_.begin(); iter != draw_callbacks_.end(); ++iter) { (*iter)(); } diff --git a/Resource.cpp b/Resource.cpp index dfd5b63..469dfda 100644 --- a/Resource.cpp +++ b/Resource.cpp @@ -99,7 +99,7 @@ const char *Resource::getData(const std::string& path, size_t* out_file_size){ cmrc::file::iterator it = file.begin(); data = static_cast(it); } - catch (std::system_error e) { + catch (const std::system_error &e) { Log::Error("Could not access ressource %s", std::string(path).c_str()); } @@ -115,7 +115,7 @@ std::string Resource::getText(const std::string& path){ file = fs.open(path.c_str()); file_stream << std::string(file.begin(), file.end()) << std::endl; } - catch (std::system_error e) { + catch (const std::system_error &e) { Log::Error("Could not access ressource %s", std::string(path).c_str()); } @@ -206,11 +206,11 @@ uint Resource::getTextureDDS(const std::string& path, float *aspect_ratio) // load the mipmaps for (uint level = 0; level < mipMapCount && (width || height); ++level) { - uint size = ((width+3)/4)*((height+3)/4)*blockSize; - glCompressedTexImage2D(GL_TEXTURE_2D, level, format, width, height, 0, size, buffer + offset); + uint s = ((width+3)/4)*((height+3)/4)*blockSize; + glCompressedTexImage2D(GL_TEXTURE_2D, level, format, width, height, 0, s, buffer + offset); glGenerateMipmap(GL_TEXTURE_2D); - offset += size; + offset += s; width /= 2; height /= 2; diff --git a/Scene.cpp b/Scene.cpp index f15a51e..4eb8367 100644 --- a/Scene.cpp +++ b/Scene.cpp @@ -18,6 +18,9 @@ #include "Scene.h" +#define DEBUG_SCENE 0 +static int num_nodes_ = 0; + // Node Node::Node() : initialized_(false), visible_(true), refcount_(0) { @@ -29,11 +32,17 @@ Node::Node() : initialized_(false), visible_(true), refcount_(0) rotation_ = glm::vec3(0.f); translation_ = glm::vec3(0.f); crop_ = glm::vec3(1.f); +#if DEBUG_SCENE + num_nodes_++; +#endif } Node::~Node () { clearCallbacks(); +#if DEBUG_SCENE + num_nodes_--; +#endif } void Node::clearCallbacks() @@ -73,7 +82,7 @@ void Node::update( float dt) delete callback; } else { - iter++; + ++iter; } } @@ -274,7 +283,7 @@ void Group::update( float dt ) // update every child node for (NodeSet::iterator node = children_.begin(); - node != children_.end(); node++) { + node != children_.end(); ++node) { (*node)->update ( dt ); } } @@ -291,7 +300,7 @@ void Group::draw(glm::mat4 modelview, glm::mat4 projection) // draw every child node for (NodeSet::iterator node = children_.begin(); - node != children_.end(); node++) { + node != children_.end(); ++node) { (*node)->draw ( ctm, projection ); } } @@ -385,13 +394,13 @@ void Switch::accept(Visitor& v) void Switch::setActive (uint index) { - active_ = CLAMP(index, 0, children_.size() - 1); + active_ = MINI(index, children_.size() - 1); } Node *Switch::child(uint index) const { if (!children_.empty()) { - uint i = CLAMP(index, 0, children_.size() - 1); + uint i = MINI(index, children_.size() - 1); return children_.at(i); } return nullptr; @@ -448,6 +457,9 @@ Scene::~Scene() clear(); // bg and fg are deleted as children of root delete root_; +#if DEBUG_SCENE + Log::Info("Total scene nodes %d", num_nodes_); +#endif } diff --git a/SearchVisitor.cpp b/SearchVisitor.cpp index 584c43b..34702d7 100644 --- a/SearchVisitor.cpp +++ b/SearchVisitor.cpp @@ -25,7 +25,7 @@ void SearchVisitor::visit(Group &n) if (found_) return; - for (NodeSet::iterator node = n.begin(); node != n.end(); node++) { + for (NodeSet::iterator node = n.begin(); node != n.end(); ++node) { (*node)->accept(*this); if (found_) break; @@ -59,7 +59,7 @@ void SearchFileVisitor::visit(Node &n) void SearchFileVisitor::visit(Group &n) { - for (NodeSet::iterator node = n.begin(); node != n.end(); node++) { + for (NodeSet::iterator node = n.begin(); node != n.end(); ++node) { (*node)->accept(*this); } } diff --git a/Session.cpp b/Session.cpp index e05d0e4..04b8790 100644 --- a/Session.cpp +++ b/Session.cpp @@ -11,10 +11,8 @@ #include "Log.h" -Session::Session() : failedSource_(nullptr), active_(true), fading_target_(0.f) +Session::Session() : failedSource_(nullptr), active_(true), fading_target_(0.f), filename_("") { - filename_ = ""; - config_[View::RENDERING] = new Group; config_[View::RENDERING]->scale_ = glm::vec3(0.f); @@ -77,7 +75,7 @@ void Session::update(float dt) // pre-render of all sources failedSource_ = nullptr; - for( SourceList::iterator it = sources_.begin(); it != sources_.end(); it++){ + for( SourceList::iterator it = sources_.begin(); it != sources_.end(); ++it){ // ensure the RenderSource is rendering this session RenderSource *s = dynamic_cast( *it ); @@ -125,13 +123,11 @@ void Session::update(float dt) SourceList::iterator Session::addSource(Source *s) { - SourceList::iterator its = sources_.end(); - // lock before change access_.lock(); // find the source - its = find(s); + SourceList::iterator its = find(s); // ok, its NOT in the list ! if (its == sources_.end()) { @@ -297,7 +293,7 @@ SourceList::iterator Session::at(int index) SourceList::iterator it = sources_.begin(); while ( i < index && it != sources_.end() ){ i++; - it++; + ++it; } return it; } @@ -325,7 +321,7 @@ void Session::move(int current_index, int target_index) SourceList::iterator from = at(current_index); SourceList::iterator to = at(target_index); if ( target_index > current_index ) - to++; + ++to; Source *s = (*from); sources_.erase(from); diff --git a/SessionCreator.cpp b/SessionCreator.cpp index 6d6d273..dd8d93b 100644 --- a/SessionCreator.cpp +++ b/SessionCreator.cpp @@ -573,10 +573,10 @@ void SessionLoader::visit (Source& s) xmlCurrent_ = sourceNode->FirstChildElement("MixingGroup"); if (xmlCurrent_) { SourceIdList idlist; - XMLElement* sourceNode = xmlCurrent_->FirstChildElement("source"); - for ( ; sourceNode ; sourceNode = sourceNode->NextSiblingElement()) { + XMLElement* mixingSourceNode = xmlCurrent_->FirstChildElement("source"); + for ( ; mixingSourceNode ; mixingSourceNode = mixingSourceNode->NextSiblingElement()) { uint64_t id__ = 0; - sourceNode->QueryUnsigned64Attribute("id", &id__); + mixingSourceNode->QueryUnsigned64Attribute("id", &id__); idlist.push_back(id__); } groups_sources_id_.push_back(idlist); diff --git a/SessionSource.cpp b/SessionSource.cpp index cdc0089..a9c8ec9 100644 --- a/SessionSource.cpp +++ b/SessionSource.cpp @@ -17,9 +17,8 @@ #include "Mixer.h" -SessionSource::SessionSource() : Source() +SessionSource::SessionSource() : Source(), failed_(false) { - failed_ = false; session_ = new Session; } @@ -174,7 +173,7 @@ void SessionFileSource::init() // check that every source is ready.. bool ready = true; - for (SourceList::iterator iter = session_->begin(); iter != session_->end(); iter++) + for (SourceList::iterator iter = session_->begin(); iter != session_->end(); ++iter) { // interrupt if any source is NOT ready if ( !(*iter)->ready() ){ diff --git a/SessionVisitor.cpp b/SessionVisitor.cpp index 7e1b812..ae1206e 100644 --- a/SessionVisitor.cpp +++ b/SessionVisitor.cpp @@ -134,7 +134,7 @@ void SessionVisitor::visit(Group &n) if (recursive_) { // loop over members of a group XMLElement *group = xmlCurrent_; - for (NodeSet::iterator node = n.begin(); node != n.end(); node++) { + for (NodeSet::iterator node = n.begin(); node != n.end(); ++node) { (*node)->accept(*this); // revert to group as current xmlCurrent_ = group; diff --git a/Settings.cpp b/Settings.cpp index a6370fe..5bfe47c 100644 --- a/Settings.cpp +++ b/Settings.cpp @@ -144,19 +144,19 @@ void Settings::Save() viewsNode->SetAttribute("workspace", application.current_workspace); map::iterator iter; - for (iter=application.views.begin(); iter != application.views.end(); iter++) + for (iter=application.views.begin(); iter != application.views.end(); ++iter) { - const Settings::ViewConfig& v = iter->second; + const Settings::ViewConfig& view_config = iter->second; XMLElement *view = xmlDoc.NewElement( "View" ); - view->SetAttribute("name", v.name.c_str()); + view->SetAttribute("name", view_config.name.c_str()); view->SetAttribute("id", iter->first); XMLElement *scale = xmlDoc.NewElement("default_scale"); - scale->InsertEndChild( XMLElementFromGLM(&xmlDoc, v.default_scale) ); + scale->InsertEndChild( XMLElementFromGLM(&xmlDoc, view_config.default_scale) ); view->InsertEndChild(scale); XMLElement *translation = xmlDoc.NewElement("default_translation"); - translation->InsertEndChild( XMLElementFromGLM(&xmlDoc, v.default_translation) ); + translation->InsertEndChild( XMLElementFromGLM(&xmlDoc, view_config.default_translation) ); view->InsertEndChild(translation); viewsNode->InsertEndChild(view); diff --git a/Shader.cpp b/Shader.cpp index 6362128..2a4d9ee 100644 --- a/Shader.cpp +++ b/Shader.cpp @@ -52,10 +52,9 @@ GLenum blending_destination_function[9] = {GL_ONE_MINUS_SRC_ALPHA,// normal GL_ONE, // lighten only GL_ZERO}; -ShadingProgram::ShadingProgram(const std::string& vertex_file, const std::string& fragment_file) : vertex_id_(0), fragment_id_(0), id_(0) +ShadingProgram::ShadingProgram(const std::string& vertex_file, const std::string& fragment_file) : + vertex_id_(0), fragment_id_(0), id_(0), vertex_file_(vertex_file), fragment_file_(fragment_file) { - vertex_file_ = vertex_file; - fragment_file_ = fragment_file; } void ShadingProgram::init() @@ -189,10 +188,10 @@ void ShadingProgram::checkCompileErr() void ShadingProgram::checkLinkingErr() { - int success; - char infoLog[1024]; + int success; glGetProgramiv(id_, GL_LINK_STATUS, &success); if (!success) { + char infoLog[1024]; glGetProgramInfoLog(id_, 1024, NULL, infoLog); Log::Warning("Error linking ShadingProgram:\n%s", infoLog); } diff --git a/Source.cpp b/Source.cpp index 0e73b9b..f6f4c45 100644 --- a/Source.cpp +++ b/Source.cpp @@ -209,7 +209,7 @@ Source::Source() : initialized_(false), symbol_(nullptr), active_(true), locked_ // filtered image shader (with texturing and processing) for rendering processingshader_ = new ImageProcessingShader; // default rendering with image processing enabled - renderingshader_ = (Shader *) processingshader_; + renderingshader_ = static_cast(processingshader_); // for drawing in mixing view mixingshader_ = new ImageShader; @@ -305,7 +305,7 @@ void Source::setMode(Source::Mode m) // show overlay if current bool current = m >= Source::CURRENT; for (auto o = overlays_.begin(); o != overlays_.end(); o++) - (*o).second->visible_ = current & !locked_; + (*o).second->visible_ = (current && !locked_); // the lock icon locker_->setActive( locked_ ? 0 : 1); @@ -331,7 +331,7 @@ void Source::setImageProcessingEnabled (bool on) if (on) { // set the current rendering shader to be the // (previously prepared) processing shader - renderingshader_ = (Shader *) processingshader_; + renderingshader_ = static_cast(processingshader_); } else { // clone the current Image processing shader @@ -343,7 +343,7 @@ void Source::setImageProcessingEnabled (bool on) // and keep it for later processingshader_ = tmp; // set the current rendering shader to a simple one - renderingshader_ = (Shader *) new ImageShader; + renderingshader_ = static_cast(new ImageShader); } // apply to nodes in subclasses @@ -432,7 +432,7 @@ void Source::attach(FrameBuffer *renderbuffer) for (int v = View::MIXING; v < View::INVALID; v++) { NodeSet::iterator node; for (node = groups_[(View::Mode) v]->begin(); - node != groups_[(View::Mode) v]->end(); node++) { + node != groups_[(View::Mode) v]->end(); ++node) { (*node)->scale_.x = renderbuffer_->aspectRatio(); } } diff --git a/SourceList.cpp b/SourceList.cpp index 77007e5..a579669 100644 --- a/SourceList.cpp +++ b/SourceList.cpp @@ -12,7 +12,7 @@ bool compare_depth (Source * first, Source * second) return ( first->depth() < second->depth() ); } -SourceList depth_sorted(SourceList list) +SourceList depth_sorted(const SourceList &list) { SourceList sl = list; sl.sort(compare_depth); @@ -23,7 +23,7 @@ SourceList depth_sorted(SourceList list) // utility to sort Sources in MixingView in a clockwise order // in reference to a center point struct clockwise_centered { - clockwise_centered(glm::vec2 c) : center(c) { } + explicit clockwise_centered(glm::vec2 c) : center(c) { } bool operator() (Source * first, Source * second) { glm::vec2 pos_first = glm::vec2(first->group(View::MIXING)->translation_)-center; float angle_first = glm::orientedAngle( glm::normalize(pos_first), glm::vec2(1.f, 0.f) ); @@ -34,7 +34,7 @@ struct clockwise_centered { glm::vec2 center; }; -SourceList mixing_sorted(SourceList list, glm::vec2 center) +SourceList mixing_sorted(const SourceList &list, glm::vec2 center) { SourceList sl = list; sl.sort(clockwise_centered(center)); @@ -43,7 +43,7 @@ SourceList mixing_sorted(SourceList list, glm::vec2 center) } -SourceIdList ids (SourceList list) +SourceIdList ids (const SourceList &list) { SourceIdList idlist; @@ -57,10 +57,10 @@ SourceIdList ids (SourceList list) } -SourceListCompare compare (SourceList first, SourceList second) +SourceListCompare compare (const SourceList &first, const SourceList &second) { SourceListCompare ret = SOURCELIST_DISTINCT; - if (first.empty() || first.empty()) + if (first.empty() || second.empty()) return ret; // a new test list: start with the second list and remove all commons with first list @@ -93,7 +93,7 @@ SourceListCompare compare (SourceList first, SourceList second) } -SourceList intersect (SourceList first, SourceList second) +SourceList intersect (const SourceList &first, const SourceList &second) { // take second list and remove all elements also in first list // -> builds the list of what remains in second list @@ -109,7 +109,7 @@ SourceList intersect (SourceList first, SourceList second) } -SourceList join (SourceList first, SourceList second) +SourceList join (const SourceList &first, const SourceList &second) { SourceList l = second; for (auto it = first.begin(); it != first.end(); it++) diff --git a/SourceList.h b/SourceList.h index 52ea72a..be2dcd3 100644 --- a/SourceList.h +++ b/SourceList.h @@ -8,10 +8,10 @@ class Source; typedef std::list SourceList; -SourceList depth_sorted (SourceList list); -SourceList mixing_sorted (SourceList list, glm::vec2 center = glm::vec2(0.f, 0.f)); -SourceList intersect (SourceList first, SourceList second); -SourceList join (SourceList first, SourceList second); +SourceList depth_sorted (const SourceList &list); +SourceList mixing_sorted (const SourceList &list, glm::vec2 center = glm::vec2(0.f, 0.f)); +SourceList intersect (const SourceList &first, const SourceList &second); +SourceList join (const SourceList &first, const SourceList &second); typedef enum { SOURCELIST_DISTINCT = 0, @@ -20,9 +20,9 @@ typedef enum { SOURCELIST_FIRST_IN_SECOND = 3, SOURCELIST_SECOND_IN_FIRST = 4 } SourceListCompare; -SourceListCompare compare (SourceList first, SourceList second); +SourceListCompare compare (const SourceList &first, const SourceList &second); typedef std::list SourceIdList; -SourceIdList ids (SourceList list); +SourceIdList ids (const SourceList &list); #endif // SOURCELIST_H diff --git a/Stream.cpp b/Stream.cpp index e9d7f57..b94c76b 100644 --- a/Stream.cpp +++ b/Stream.cpp @@ -626,7 +626,7 @@ bool Stream::fill_frame(GstBuffer *buf, FrameStatus status) void Stream::callback_end_of_stream (GstAppSink *, gpointer p) { - Stream *m = (Stream *)p; + Stream *m = static_cast(p); if (m && m->ready_) { m->fill_frame(NULL, Stream::EOS); } @@ -642,7 +642,7 @@ GstFlowReturn Stream::callback_new_preroll (GstAppSink *sink, gpointer p) // if got a valid sample if (sample != NULL) { // send frames to media player only if ready - Stream *m = (Stream *)p; + Stream *m = static_cast(p); if (m && m->ready_) { // get buffer from sample @@ -676,7 +676,7 @@ GstFlowReturn Stream::callback_new_sample (GstAppSink *sink, gpointer p) if (sample != NULL && !gst_app_sink_is_eos (sink)) { // send frames to media player only if ready - Stream *m = (Stream *)p; + Stream *m = static_cast(p); if (m && m->ready_) { // get buffer from sample (valid until sample is released) diff --git a/Streamer.cpp b/Streamer.cpp index e3ff263..9b0dab3 100644 --- a/Streamer.cpp +++ b/Streamer.cpp @@ -100,7 +100,7 @@ bool Streaming::busy() streamers_lock_.lock(); std::vector::const_iterator sit = streamers_.begin(); - for (; sit != streamers_.end() && !b; sit++) + for (; sit != streamers_.end() && !b; ++sit) b = (*sit)->busy() ; streamers_lock_.unlock(); @@ -114,7 +114,7 @@ std::vector Streaming::listStreams() streamers_lock_.lock(); std::vector::const_iterator sit = streamers_.begin(); - for (; sit != streamers_.end(); sit++) + for (; sit != streamers_.end(); ++sit) ls.push_back( (*sit)->info() ); streamers_lock_.unlock(); @@ -148,7 +148,7 @@ void Streaming::removeStream(const std::string &sender, int port) // parse the list for a streamers matching IP and port streamers_lock_.lock(); std::vector::const_iterator sit = streamers_.begin(); - for (; sit != streamers_.end(); sit++){ + for (; sit != streamers_.end(); ++sit){ NetworkToolkit::StreamConfig config = (*sit)->config_; if (config.client_address.compare(sender_ip) == 0 && config.port == port ) { #ifdef STREAMER_DEBUG @@ -182,7 +182,7 @@ void Streaming::removeStreams(const std::string &clientname) sit = streamers_.erase(sit); } else - sit++; + ++sit; } streamers_lock_.unlock(); } @@ -203,7 +203,7 @@ void Streaming::removeStream(const VideoStreamer *vs) break; } else - sit++; + ++sit; } streamers_lock_.unlock(); } @@ -285,7 +285,7 @@ void Streaming::addStream(const std::string &sender, int reply_to, const std::st } -VideoStreamer::VideoStreamer(NetworkToolkit::StreamConfig conf): FrameGrabber(), config_(conf), stopped_(false) +VideoStreamer::VideoStreamer(const NetworkToolkit::StreamConfig &conf): FrameGrabber(), config_(conf), stopped_(false) { } diff --git a/Streamer.h b/Streamer.h index 2975135..46b3d57 100644 --- a/Streamer.h +++ b/Streamer.h @@ -79,7 +79,7 @@ class VideoStreamer : public FrameGrabber public: - VideoStreamer(NetworkToolkit::StreamConfig conf); + VideoStreamer(const NetworkToolkit::StreamConfig &conf); virtual ~VideoStreamer() {} std::string info() const override; diff --git a/SystemToolkit.cpp b/SystemToolkit.cpp index d4f4373..c495eec 100644 --- a/SystemToolkit.cpp +++ b/SystemToolkit.cpp @@ -55,11 +55,11 @@ long SystemToolkit::memory_usage() FILE *file = fopen("/proc/self/statm", "r"); if (file) { unsigned long m = 0; - int ret = 0; + int ret = 0, ret2 = 0; ret = fscanf (file, "%lu", &m); // virtual mem program size, - ret = fscanf (file, "%lu", &m); // resident set size, + ret2 = fscanf (file, "%lu", &m); // resident set size, fclose (file); - if (ret>0) + if (ret>0 && ret2>0) size = (size_t)m * getpagesize(); } return (long)size; @@ -102,7 +102,7 @@ string SystemToolkit::byte_to_string(long b) while(numbytes >= 1024.0 && i != list.end()) { - i++; + ++i; numbytes /= 1024.0; } oss << std::fixed << std::setprecision(2) << numbytes << *i; @@ -119,7 +119,7 @@ string SystemToolkit::bits_to_string(long b) while(numbytes >= 1000.0 && i != list.end()) { - i++; + ++i; numbytes /= 1000.0; } oss << std::fixed << std::setprecision(2) << numbytes << *i; @@ -189,18 +189,17 @@ string SystemToolkit::extension_filename(const string& filename) std::string SystemToolkit::home_path() { - // 1. find home - char *mHomePath; + string homePath; // try the system user info // NB: avoids depending on changes of the $HOME env. variable struct passwd* pwd = getpwuid(getuid()); if (pwd) - mHomePath = pwd->pw_dir; + homePath = std::string(pwd->pw_dir); else // try the $HOME environment variable - mHomePath = getenv("HOME"); + homePath = std::string(getenv("HOME")); - return string(mHomePath) + PATH_SEP; + return homePath + PATH_SEP; } @@ -216,17 +215,16 @@ std::string SystemToolkit::cwd_path() std::string SystemToolkit::username() { - // 1. find home - char *user; + string userName; // try the system user info struct passwd* pwd = getpwuid(getuid()); if (pwd) - user = pwd->pw_name; + userName = std::string(pwd->pw_name); else // try the $USER environment variable - user = getenv("USER"); + userName = std::string(getenv("USER")); - return string(user); + return userName; } bool SystemToolkit::create_directory(const string& path) @@ -307,7 +305,7 @@ bool SystemToolkit::file_exists(const string& path) return access(path.c_str(), R_OK) == 0; - // TODO : WIN32 implementation + // TODO : WIN32 implementation (see tinyfd) } @@ -330,18 +328,18 @@ list SystemToolkit::list_directory(const string& path, const string& fil list ls; DIR *dir; - struct dirent *ent; if ((dir = opendir (path.c_str())) != NULL) { - // list all the files and directories within directory - while ((ent = readdir (dir)) != NULL) { - if ( ent->d_type == DT_REG) - { - string filename = string(ent->d_name); - if ( extension_filename(filename) == filter) - ls.push_back( full_filename(path, filename) ); - } - } - closedir (dir); + // list all the files and directories within directory + struct dirent *ent; + while ((ent = readdir (dir)) != NULL) { + if ( ent->d_type == DT_REG) + { + string filename = string(ent->d_name); + if ( extension_filename(filename) == filter) + ls.push_back( full_filename(path, filename) ); + } + } + closedir (dir); } return ls; @@ -354,11 +352,11 @@ void SystemToolkit::open(const string& url) #elif defined APPLE char buf[2048]; sprintf( buf, "open '%s'", url.c_str() ); - system( buf ); + (void) system( buf ); #else char buf[2048]; sprintf( buf, "xdg-open '%s'", url.c_str() ); - int r = system( buf ); + (void) system( buf ); #endif } @@ -367,9 +365,9 @@ void SystemToolkit::execute(const string& command) #ifdef WIN32 ShellExecuteA( nullptr, nullptr, url.c_str(), nullptr, nullptr, 0 ); #elif defined APPLE - int r = system( command.c_str() ); + (void) system( command.c_str() ); #else - int r = system( command.c_str() ); + (void) system( command.c_str() ); #endif } // example : @@ -388,15 +386,15 @@ std::string SystemToolkit::transliterate(std::string input) icu::Transliterator *firstTrans = icu::Transliterator::createInstance( "any-NFKD ; [:Nonspacing Mark:] Remove; NFKC; Latin", UTRANS_FORWARD, status); firstTrans->transliterate(ucs); + delete firstTrans; icu::Transliterator *secondTrans = icu::Transliterator::createInstance( "any-NFKD ; [:Nonspacing Mark:] Remove; [@!#$*%~] Remove; NFKC", UTRANS_FORWARD, status); secondTrans->transliterate(ucs); - delete secondTrans; - delete firstTrans; std::ostringstream output; output << ucs; + return output.str(); } diff --git a/TextureView.cpp b/TextureView.cpp index 9de5bf7..d026fe6 100644 --- a/TextureView.cpp +++ b/TextureView.cpp @@ -258,7 +258,7 @@ void TextureView::select(glm::vec2 A, glm::vec2 B) // create a list of source matching the list of picked nodes SourceList selection; // loop over the nodes and add all sources found. - for(std::vector< std::pair >::const_reverse_iterator p = pv.rbegin(); p != pv.rend(); p++){ + for(std::vector< std::pair >::const_reverse_iterator p = pv.rbegin(); p != pv.rend(); ++p){ Source *s = Mixer::manager().findSource( p->first ); if (canSelect(s)) selection.push_back( s ); @@ -1191,9 +1191,9 @@ View::Cursor TextureView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pa overlay_rotation_clock_->visible_ = false; // rotation center to center of source (disregarding scale) - glm::mat4 T = glm::translate(glm::identity(), s->stored_status_->translation_); - source_from = glm::inverse(T) * glm::vec4( scene_from, 1.f ); - source_to = glm::inverse(T) * glm::vec4( scene_to, 1.f ); + glm::mat4 M = glm::translate(glm::identity(), s->stored_status_->translation_); + source_from = glm::inverse(M) * glm::vec4( scene_from, 1.f ); + source_to = glm::inverse(M) * glm::vec4( scene_to, 1.f ); // compute rotation angle float angle = glm::orientedAngle( glm::normalize(glm::vec2(source_from)), glm::normalize(glm::vec2(source_to))); // apply rotation on Z axis diff --git a/Timeline.cpp b/Timeline.cpp index 77ed801..205bef5 100644 --- a/Timeline.cpp +++ b/Timeline.cpp @@ -13,7 +13,7 @@ struct includesTime: public std::unary_function return s.includes(_t); } - includesTime(GstClockTime t) : _t(t) { } + explicit includesTime(GstClockTime t) : _t(t) { } private: GstClockTime _t; @@ -143,7 +143,7 @@ bool Timeline::addGap(TimeInterval s) return false; } -void Timeline::setGaps(TimeIntervalSet g) +void Timeline::setGaps(const TimeIntervalSet &g) { gaps_array_need_update_ = true; gaps_ = g; @@ -205,8 +205,8 @@ float Timeline::fadingAt(const GstClockTime t) double true_index = (static_cast(MAX_TIMELINE_ARRAY) * static_cast(t)) / static_cast(timing_.end); double previous_index = floor(true_index); float percent = static_cast(true_index - previous_index); - size_t keyframe_index = CLAMP( static_cast(previous_index), 0, MAX_TIMELINE_ARRAY-1); - size_t keyframe_next_index = CLAMP( keyframe_index+1, 0, MAX_TIMELINE_ARRAY-1); + size_t keyframe_index = MINI( static_cast(previous_index), MAX_TIMELINE_ARRAY-1); + size_t keyframe_next_index = MINI( keyframe_index+1, MAX_TIMELINE_ARRAY-1); float v = fadingArray_[keyframe_index]; v += percent * (fadingArray_[keyframe_next_index] - fadingArray_[keyframe_index]); diff --git a/Timeline.h b/Timeline.h index 22e379d..d13b41d 100644 --- a/Timeline.h +++ b/Timeline.h @@ -111,7 +111,7 @@ public: inline size_t numGaps() const { return gaps_.size(); } float *gapsArray(); void clearGaps(); - void setGaps(TimeIntervalSet g); + void setGaps(const TimeIntervalSet &g); bool addGap(TimeInterval s); bool addGap(GstClockTime begin, GstClockTime end); bool removeGaptAt(GstClockTime t); diff --git a/TransitionView.cpp b/TransitionView.cpp index 47d5cab..3b19be2 100644 --- a/TransitionView.cpp +++ b/TransitionView.cpp @@ -87,7 +87,7 @@ void TransitionView::update(float dt) FrameBuffer *output = Mixer::manager().session()->frame(); if (output){ float aspect_ratio = output->aspectRatio(); - for (NodeSet::iterator node = scene.bg()->begin(); node != scene.bg()->end(); node++) { + for (NodeSet::iterator node = scene.bg()->begin(); node != scene.bg()->end(); ++node) { (*node)->scale_.x = aspect_ratio; } output_surface_->setTextureIndex( output->texture() ); diff --git a/UpdateCallback.cpp b/UpdateCallback.cpp index 3fbaec4..c14c188 100644 --- a/UpdateCallback.cpp +++ b/UpdateCallback.cpp @@ -40,7 +40,7 @@ void MoveToCallback::update(Node *n, float dt) } RotateToCallback::RotateToCallback(float target, float duration) : UpdateCallback(), - duration_(duration), progress_(0.f), initialized_(false), target_(target) + duration_(duration), progress_(0.f), initialized_(false), startingangle_(0.f), target_(target) { } diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index fede8b7..7b38a23 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -168,7 +168,7 @@ bool UserInterface::Init() void UserInterface::handleKeyboard() { - ImGuiIO& io = ImGui::GetIO(); + const ImGuiIO& io = ImGui::GetIO(); alt_modifier_active = io.KeyAlt; shift_modifier_active = io.KeyShift; bool ctrl = io.ConfigMacOSXBehaviors ? io.KeySuper : io.KeyCtrl; @@ -1370,7 +1370,7 @@ int UserInterface::RenderViewNavigator(int *shift) int target_index = ( (Settings::application.current_view -1)+ (*shift -1) )%4 + 1; // prepare rendering of centered, fixed-size, semi-transparent window; - ImGuiIO& io = ImGui::GetIO(); + const ImGuiIO& io = ImGui::GetIO(); ImVec2 window_pos = ImVec2(io.DisplaySize.x / 2.f, io.DisplaySize.y / 2.f); ImVec2 window_pos_pivot = ImVec2(0.5f, 0.5f); ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot); @@ -1529,7 +1529,7 @@ void MediaController::Render() ImGui::SetNextWindowSize(ImVec2(400, 400), ImGuiCond_FirstUseEver); // estimate window size - ImGuiContext& g = *GImGui; + const ImGuiContext& g = *GImGui; const float _spacing = 6.0f; const float _height = g.FontSize + g.Style.FramePadding.y * 2.0f ; const float _timeline_height = (g.FontSize + g.Style.FramePadding.y) * 2.0f ; // double line for each timeline @@ -1855,7 +1855,7 @@ void MediaController::Render() ImGui::End(); } -void UserInterface::fillShaderEditor(std::string text) +void UserInterface::fillShaderEditor(const std::string &text) { static bool initialized = false; if (!initialized) { @@ -1889,6 +1889,7 @@ void UserInterface::fillShaderEditor(std::string text) } // init editor editor.SetLanguageDefinition(lang); + initialized = true; } // remember text @@ -2045,8 +2046,8 @@ void Navigator::Render() std::string tooltip_ = ""; static uint timer_tooltip_ = 0; - ImGuiIO& io = ImGui::GetIO(); - ImGuiStyle& style = ImGui::GetStyle(); + const ImGuiIO& io = ImGui::GetIO(); + const ImGuiStyle& style = ImGui::GetStyle(); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0); ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(COLOR_NAVIGATOR, 1.f)); @@ -2084,7 +2085,7 @@ void Navigator::Render() // the list of INITIALS for sources int index = 0; SourceList::iterator iter; - for (iter = Mixer::manager().session()->begin(); iter != Mixer::manager().session()->end(); iter++, index++) + for (iter = Mixer::manager().session()->begin(); iter != Mixer::manager().session()->end(); ++iter, ++index) { Source *s = (*iter); // draw an indicator for current source @@ -2325,7 +2326,7 @@ SourcePreview::SourcePreview() : source_(nullptr), label_("") } -void SourcePreview::setSource(Source *s, std::string label) +void SourcePreview::setSource(Source *s, const string &label) { if(source_) delete source_; @@ -2466,7 +2467,7 @@ void Navigator::RenderNewPannel() if (ImGui::BeginCombo("##RecentImport", IMGUI_LABEL_RECENT_FILES)) { std::list recent = Settings::application.recentImport.filenames; - for (std::list::iterator path = recent.begin(); path != recent.end(); path++ ) + for (std::list::iterator path = recent.begin(); path != recent.end(); ++path ) { std::string recentpath(*path); if ( SystemToolkit::file_exists(recentpath)) { @@ -2494,7 +2495,7 @@ void Navigator::RenderNewPannel() new_source_preview_.setSource( Mixer::manager().createSourceRender(), label); } SourceList::iterator iter; - for (iter = Mixer::manager().session()->begin(); iter != Mixer::manager().session()->end(); iter++) + for (iter = Mixer::manager().session()->begin(); iter != Mixer::manager().session()->end(); ++iter) { label = std::string("Source ") + (*iter)->name(); if (ImGui::Selectable( label.c_str() )) { @@ -2763,8 +2764,8 @@ void Navigator::RenderMainPannel() ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.7); bool reset = false; if ( selection_session_mode == 1) { - const char *tooltip[2] = {"Discard folder", "Discard folder"}; - if (ImGuiToolkit::IconToggle(12,14,11,14, &reset, tooltip)) { + const char *tooltip_[2] = {"Discard folder", "Discard folder"}; + if (ImGuiToolkit::IconToggle(12,14,11,14, &reset, tooltip_)) { Settings::application.recentFolders.filenames.remove(Settings::application.recentFolders.path); if (Settings::application.recentFolders.filenames.empty()) { Settings::application.recentFolders.path.assign(IMGUI_LABEL_RECENT_FILES); @@ -2777,8 +2778,8 @@ void Navigator::RenderMainPannel() } } else { - const char *tooltip[2] = {"Clear history", "Clear history"}; - if (ImGuiToolkit::IconToggle(12,14,11,14, &reset, tooltip)) { + const char *tooltip__[2] = {"Clear history", "Clear history"}; + if (ImGuiToolkit::IconToggle(12,14,11,14, &reset, tooltip__)) { Settings::application.recentSessions.filenames.clear(); Settings::application.recentSessions.front_is_valid = false; // reload the list next time @@ -2943,39 +2944,39 @@ void Navigator::RenderMainPannel() } -namespace ImGui -{ +//namespace ImGui +//{ -int hover(const char *label) -{ - const ImGuiStyle& Style = GetStyle(); - ImGuiWindow* Window = GetCurrentWindow(); - if (Window->SkipItems) - return 0; +//int hover(const char *label) +//{ +// const ImGuiStyle& Style = GetStyle(); +// ImGuiWindow* Window = GetCurrentWindow(); +// if (Window->SkipItems) +// return 0; - int hovered = IsItemActive() || IsItemHovered(); - Dummy(ImVec2(0,3)); +// int hovered = IsItemActive() || IsItemHovered(); +// Dummy(ImVec2(0,3)); - // prepare canvas - const float avail = GetContentRegionAvailWidth(); - const float dim = ImMin(avail, 128.f); - ImVec2 Canvas(dim, dim); +// // prepare canvas +// const float avail = GetContentRegionAvailWidth(); +// const float dim = ImMin(avail, 128.f); +// ImVec2 Canvas(dim, dim); - ImRect bb(Window->DC.CursorPos, Window->DC.CursorPos + Canvas); - const ImGuiID id = Window->GetID(label); - ItemSize(bb); - if (!ItemAdd(bb, id)) - return 0; +// ImRect bb(Window->DC.CursorPos, Window->DC.CursorPos + Canvas); +// const ImGuiID id = Window->GetID(label); +// ItemSize(bb); +// if (!ItemAdd(bb, id)) +// return 0; - hovered |= 0 != IsItemClicked(); +// hovered |= 0 != IsItemClicked(); - RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg, 1), true, Style.FrameRounding); +// RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg, 1), true, Style.FrameRounding); - return 1; -} +// return 1; +//} -} +//} #define SEGMENT_ARRAY_MAX 1000 @@ -3008,8 +3009,19 @@ void ShowSandbox(bool* p_open) SystemToolkit::execute(str); if (ImGui::Button("Message test")) { - Log::Error("Testing dialog"); + + for(int i=0; i<10; i++) { + Log::Notify("Testing notification %d", i); + } + + for(int i=0; i<10; i++) { + Log::Warning("Testing Warning %d", i); + } + } + + + // const guint64 duration = GST_SECOND * 6; // const guint64 step = GST_MSECOND * 20; // static guint64 t = 0; diff --git a/UserInterfaceManager.h b/UserInterfaceManager.h index 9a67723..41b8b3c 100644 --- a/UserInterfaceManager.h +++ b/UserInterfaceManager.h @@ -22,7 +22,7 @@ class SourcePreview { public: SourcePreview(); - void setSource(Source *s = nullptr, std::string label = ""); + void setSource(Source *s = nullptr, const std::string &label = ""); Source *getSource(); void Render(float width, bool controlbutton = false); @@ -157,7 +157,7 @@ public: // TODO implement the shader editor std::string currentTextEdit; - void fillShaderEditor(std::string text); + void fillShaderEditor(const std::string &text); protected: diff --git a/View.cpp b/View.cpp index 5ebbf16..b01695c 100644 --- a/View.cpp +++ b/View.cpp @@ -215,7 +215,7 @@ void View::select(glm::vec2 A, glm::vec2 B) // create a list of source matching the list of picked nodes SourceList selection; // loop over the nodes and add all sources found. - for(std::vector< std::pair >::const_reverse_iterator p = pv.rbegin(); p != pv.rend(); p++){ + for(std::vector< std::pair >::const_reverse_iterator p = pv.rbegin(); p != pv.rend(); ++p){ Source *s = Mixer::manager().findSource( p->first ); if (canSelect(s)) selection.push_back( s ); diff --git a/ext/OSCPack/ip/posix/UdpSocket.cpp b/ext/OSCPack/ip/posix/UdpSocket.cpp index d099494..539051d 100644 --- a/ext/OSCPack/ip/posix/UdpSocket.cpp +++ b/ext/OSCPack/ip/posix/UdpSocket.cpp @@ -350,7 +350,7 @@ class SocketReceiveMultiplexer::Implementation{ } public: - Implementation() + Implementation(): break_(false) { if( pipe(breakPipe_) != 0 ) throw std::runtime_error( "creation of asynchronous break pipes failed\n" ); diff --git a/ext/OSCPack/osc/OscPrintReceivedElements.cpp b/ext/OSCPack/osc/OscPrintReceivedElements.cpp index 72e0bc5..395da57 100644 --- a/ext/OSCPack/osc/OscPrintReceivedElements.cpp +++ b/ext/OSCPack/osc/OscPrintReceivedElements.cpp @@ -225,8 +225,8 @@ std::ostream& operator<<( std::ostream & os, const ReceivedBundle& b ) for( ReceivedBundle::const_iterator i = b.ElementsBegin(); i != b.ElementsEnd(); ++i ){ if( i->IsBundle() ){ - ReceivedBundle b(*i); - os << b << "\n"; + ReceivedBundle rb(*i); + os << rb << "\n"; }else{ ReceivedMessage m(*i); for( int j=0; j < indent; ++j )