diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp index c2fd5f390b9..c039393b1e4 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp @@ -62,7 +62,8 @@ Scene_polyhedron_item::Scene_polyhedron_item() poly(new Polyhedron), show_only_feature_edges_m(false), facet_picking_m(false), - erase_next_picked_facet_m(false) + erase_next_picked_facet_m(false), + plugin_has_set_color_vector_m(false) { //init(); } @@ -72,7 +73,8 @@ Scene_polyhedron_item::Scene_polyhedron_item(Polyhedron* const p) poly(p), show_only_feature_edges_m(false), facet_picking_m(false), - erase_next_picked_facet_m(false) + erase_next_picked_facet_m(false), + plugin_has_set_color_vector_m(false) { init(); } @@ -82,7 +84,8 @@ Scene_polyhedron_item::Scene_polyhedron_item(const Polyhedron& p) poly(new Polyhedron(p)), show_only_feature_edges_m(false), facet_picking_m(false), - erase_next_picked_facet_m(false) + erase_next_picked_facet_m(false), + plugin_has_set_color_vector_m(false) { init(); } @@ -108,17 +111,20 @@ init() { typedef Polyhedron::Facet_iterator Facet_iterator; - // Fill indices map and get max subdomain value - int max = 0; - for(Facet_iterator fit = poly->facets_begin(), end = poly->facets_end() ; - fit != end; ++fit) + if ( !plugin_has_set_color_vector_m ) { - max = (std::max)(max, fit->patch_id()); + // Fill indices map and get max subdomain value + int max = 0; + for(Facet_iterator fit = poly->facets_begin(), end = poly->facets_end() ; + fit != end; ++fit) + { + max = (std::max)(max, fit->patch_id()); + } + + colors_.clear(); + compute_color_map(this->color(), max + 1, + std::back_inserter(colors_)); } - - colors_.clear(); - compute_color_map(this->color(), max + 1, - std::back_inserter(colors_)); } diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h index 6785166c772..be73578f0e3 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h @@ -51,7 +51,8 @@ public: bool isEmpty() const; Bbox bbox() const; std::vector& color_vector() {return colors_;} - + void set_color_vector_read_only(bool on_off) {plugin_has_set_color_vector_m=on_off;} + public slots: virtual void changed(); void show_only_feature_edges(bool); @@ -85,6 +86,8 @@ private: bool show_only_feature_edges_m; bool facet_picking_m; bool erase_next_picked_facet_m; + //the following variable is used to indicate if the color vector must not be automatically updated. + bool plugin_has_set_color_vector_m; }; // end class Scene_polyhedron_item #endif // SCENE_POLYHEDRON_ITEM_H