// Don't actually remove the stroke: exchange it with the last stroke // in _array that is currently in use, and decrement the count of // strokes used. This places the "removed" stroke in the slot at the // beginning of the unused portion of the memory pool. int BStrokePool::remove_stroke(OutlineStroke* s) { int i = get_index(s); assert(i != BAD_IND); assert(i < _num_strokes_used); OutlineStroke *ss = get_selected_stroke(); if (s == ss) { ss = NULL; } internal_deselect(); OutlineStroke* tmp = _array[i]; assert(tmp); tmp->clear(); _array[i] = _array[_num_strokes_used-1]; _array[_num_strokes_used-1] = tmp; _num_strokes_used--; if (ss) { i = get_index(ss); assert(i != BAD_IND); assert(i < _num_strokes_used); internal_select(i); } assert (_num_strokes_used <= _num); return 1; }
int BStrokePool::set_prototype(OutlineStroke* p) { assert(p); //XXX - Enforce multiprototype issue here?! //i.e. all protos have the period and mesh //size of the 1st proto. Okay, let a virtual //function handle this... int retval = set_prototype_internal(p); if(_edit_proto == get_active_proto()) apply_active_proto(); OutlineStroke* s = _prototypes[0]; _cur_mesh_size = s->get_original_mesh_size(); _cur_period = (s->get_offsets())? (s->get_offsets()->get_pix_len()): ((double)max(1.0f,(s->get_angle()))); return retval; }
///////////////////////////////////// // get_stroke() ///////////////////////////////////// void BStrokePool::get_stroke(TAGformat &d) { // cerr << "BStrokePool::get_stroke()\n"; str_ptr str; *d >> str; DATA_ITEM *data_item = DATA_ITEM::lookup(str); if (!data_item) { cerr << "BStrokePool::get_stroke() - Class name " << str << " could not be found!!!!!!!" << endl; return; } else if (!OutlineStroke::isa(data_item)) { cerr << "BStrokePool::get_stroke() - Class name " << str << " not a OutlineStroke or a derived class!!!!!!" << endl; return; } // else { // cerr << "BStrokePool::get_stroke() - Loaded class name " << str << "\n"; } // OutlineStroke *s = (OutlineStroke*)data_item->dup(); assert(s); s->decode(*d); add(s); }
void BStrokePool::draw_flat(CVIEWptr& v) { OutlineStroke *proto = get_active_prototype(); int i; if (_hide) return; if (!proto) return; // XXX - This pool assumes all stroke can be drawn with the // monolithic prototype. Unlike crease and decal pools, // these is no mix of 'effective' prototypes... proto->draw_start(); for (i = 0; i < _num_strokes_used; i++) _array[i]->draw(v); proto->draw_end(); }
void BStrokePool::add_prototype() { //Subclass this is you don't like it... Generally, //its assumed we have OutlineStrokes... If more //subclassed stroke issues are req'd, a subclass pool //can handle it. By the way, this outght to be called //an OStrokePool... assert(_prototypes[_edit_proto]); assert(_prototypes[_edit_proto]->class_name() == OutlineStroke::static_name()); OutlineStroke *s = (OutlineStroke *)_prototypes[_edit_proto]->dup(); assert(s); s->set_propagate_offsets(true); s->set_propagate_patch(true); assert(_prototypes[_edit_proto]->get_patch() == s->get_patch()); _prototypes += s; }
void EdgeStrokePool::draw_flat(CVIEWptr& v) { //This really fails with noise... so... assert(get_num_protos()==1); if (_hide) return; OutlineStroke *prot = get_active_prototype(); if (!prot) return; // A OutlineStroke::draw_start() call has a different effect depending // on whether or not the stroke has texture. So textured and // untextured strokes must be rendered in different passes. // Check whether we have textured or untextured strokes, or both // kinds of strokes. bool have_textured_strokes = false; bool have_untextured_strokes = false; int i; for (i = 0; i < _num_strokes_used; i++) { if (_array[i]->get_texture()) have_textured_strokes = true; else have_untextured_strokes = true; } if (have_untextured_strokes) { // If proto has a texture, temporarily unset the texture so it // calls draw_start() appropriately for untextured strokes. TEXTUREptr proto_tex = prot->get_texture(); Cstr_ptr proto_tex_file = prot->get_texture_file(); if (prot->get_texture()) prot->set_texture(NULL, NULL_STR); prot->draw_start(); glDepthFunc(GL_ALWAYS); for (i = 0; i < _num_strokes_used; i++) if (!_array[i]->get_texture()) _array[i]->draw(v); glDepthFunc(GL_LESS); prot->draw_end(); // If we saved the proto's texture, reset it now. if (proto_tex) prot->set_texture(proto_tex, proto_tex_file); } if (have_textured_strokes) { // Have each textured stroke call its own draw_begin(). // XXX -- this is a little inefficient. for (int j = 0; j < _num_strokes_used; j++) { if (_array[j]->get_texture()) { _array[j]->draw_start(); glDepthFunc(GL_ALWAYS); _array[j]->draw(v); glDepthFunc(GL_LESS); _array[j]->draw_end(); } } } }