void tglDraw(const TVectorRenderData &rd, const TStroke *s) { assert(s); if (!s) return; const TStroke &stroke = *s; // initialize information for aaliasing glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); // it's necessary to do line function of pixel size ? glLineWidth((float)1.0); assert(rd.m_palette); TStrokeProp *prop = stroke.getProp(/*rd.m_palette*/); /////questo codice stava dentro tstroke::getprop///////// TColorStyle *style = rd.m_palette->getStyle(stroke->getStyle() /*m_imp->m_styleId*/); if (!style->isStrokeStyle() || style->isEnabled() == false) { prop = 0; } else { if (!prop || style != prop->getColorStyle()) { stroke->setProp(style->makeStrokeProp(stroke)); prop = stroke->getProp(); } } /// //--------------------- if (prop) prop->draw(rd); //--------------------- tglColor(TPixel32::White); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); }
void tglDraw(const TVectorRenderData &rd, const TStroke *s, bool pushAttribs) { assert(s); if (!s) return; TStrokeProp *prop = 0; bool pushedAttribs = false; try { TColorStyleP style; TStroke *stroke = const_cast<TStroke *>(s); if (rd.m_inkCheckEnabled && s->getStyle() == rd.m_colorCheckIndex) { static TSolidColorStyle *redColor = new TSolidColorStyle(); redColor->addRef(); redColor->setMainColor(TPixel::Red); style = redColor; } else if (rd.m_tcheckEnabled) { static TSolidColorStyle *color = new TSolidColorStyle(); color->addRef(); color->setMainColor(rd.m_tCheckInk); style = color; } else style = rd.m_palette->getStyle(stroke->getStyle()); if (!rd.m_show0ThickStrokes && isOThick(s) && dynamic_cast<TSolidColorStyle *>( style.getPointer()) // This is probably to exclude // TCenterlineStrokeStyle-like styles && !rd.m_tcheckEnabled) // I wonder why this? return; // const TStroke& stroke = *s; //serve??? assert(rd.m_palette); prop = s->getProp(/*rd.m_palette*/); /////questo codice stava dentro tstroke::getprop///////// if (prop) prop->getMutex()->lock(); if (!style->isStrokeStyle() || style->isEnabled() == false) { if (prop) prop->getMutex()->unlock(); prop = 0; } else { // Warning: the following pointers check is conceptually wrong - we // keep it because the props maintain SMART POINTER-like reference to // the associated style. This prevents the style from being destroyed // while still referenced by the prop. if (!prop || style.getPointer() != prop->getColorStyle()) { if (prop) prop->getMutex()->unlock(); stroke->setProp(style->makeStrokeProp(stroke)); prop = stroke->getProp(); if (prop) prop->getMutex()->lock(); } } //--------- draw ------------ if (!prop) return; if (pushAttribs) glPushAttrib(GL_ALL_ATTRIB_BITS), pushedAttribs = true; bool alphaChannel = rd.m_alphaChannel, antialias = rd.m_antiAliasing; TVectorImagePatternStrokeProp *aux = dynamic_cast<TVectorImagePatternStrokeProp *>(prop); if (aux) // gli image pattern vettoriali tornano in questa funzione....non // facendo il corpo dell'else'si evita di disegnarli due volte! prop->draw(rd); else { if (antialias) tglEnableLineSmooth(true); else tglEnableLineSmooth(false); if (alphaChannel) { GLboolean red, green, blue, alpha; tglGetColorMask(red, green, blue, alpha); // Draw RGB channels tglEnableBlending(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColorMask(red, green, blue, GL_FALSE); prop->draw(rd); // Draw Matte channel tglEnableBlending(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, alpha); prop->draw(rd); glColorMask(red, green, blue, alpha); } else { tglEnableBlending(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); prop->draw(rd); } } if (pushAttribs) glPopAttrib(), pushedAttribs = false; prop->getMutex()->unlock(); //--------------------- } catch (...) { if (prop) prop->getMutex()->unlock(); if (pushedAttribs) glPopAttrib(); } }