const char *Circle::toXmlElement() { char *element = new char[MAX_SHAPE_LEN]; element[0] = '\0'; strcat(element, "<"); strcat(element, Circle::simpleClassName); strcat(element, " "); /* Write properties */ strcat(element, toPropertyValue("radius=\"", radius)); strcat(element, " "); strcat(element, toPropertyValue("cx=\"", cx)); strcat(element, " "); strcat(element, toPropertyValue("cy=\"", cy)); strcat(element, " "); strcat(element, toPropertyValue("stroke-width=\"", getStrokeWidth())); strcat(element, " "); strcat(element, toPropertyValue("stroke=\"", getStroke())); strcat(element, " "); strcat(element, toPropertyValue("fill=\"", getFill())); strcat(element, "/>"); return element; }
void GUIPolygon::performTesselation(SUMOReal lineWidth) const { if (getFill()) { // draw the tesselated shape double* points = new double[myShape.size() * 3]; GLUtesselator* tobj = gluNewTess(); gluTessCallback(tobj, GLU_TESS_VERTEX, (GLvoid(APIENTRY*)()) &glVertex3dv); gluTessCallback(tobj, GLU_TESS_BEGIN, (GLvoid(APIENTRY*)()) &beginCallback); gluTessCallback(tobj, GLU_TESS_END, (GLvoid(APIENTRY*)()) &endCallback); //gluTessCallback(tobj, GLU_TESS_ERROR, (GLvoid (APIENTRY*) ()) &errorCallback); gluTessCallback(tobj, GLU_TESS_COMBINE, (GLvoid(APIENTRY*)()) &combineCallback); gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD); gluTessBeginPolygon(tobj, NULL); gluTessBeginContour(tobj); for (size_t i = 0; i != myShape.size(); ++i) { points[3 * i] = myShape[(int) i].x(); points[3 * i + 1] = myShape[(int) i].y(); points[3 * i + 2] = 0; gluTessVertex(tobj, points + 3 * i, points + 3 * i); } gluTessEndContour(tobj); gluTessEndPolygon(tobj); gluDeleteTess(tobj); delete[] points; } else { myLineWidth = lineWidth; GLHelper::drawLine(myShape); GLHelper::drawBoxLines(myShape, myLineWidth); } //std::cout << "OpenGL says: '" << gluErrorString(glGetError()) << "'\n"; }
void NexusZone::render() const { #ifndef ZAP_DEDICATED GameType *gameType = getGame() ? getGame()->getGameType() : NULL; NexusGameType *nexusGameType = NULL; if(gameType && gameType->getGameTypeId() == NexusGame) nexusGameType = static_cast<NexusGameType *>(gameType); bool isOpen = nexusGameType && nexusGameType->isNexusOpen(); F32 glowFraction = gameType ? gameType->mZoneGlowTimer.getFraction() : 0; GameObjectRender::renderNexus(getOutline(), getFill(), getCentroid(), getLabelAngle(), isOpen, glowFraction); #endif }
/* The QInfoFrame constructor is very simply due to the other two classes provided in this file. It is a QTabWidget and its two tabs are one MapEdit and then one ProjectionEdit. After those two tabs are added, all that is left for the constructor to do is connect the QPushButtons in those tabs to slots in this QInfoFrame. The name QInfoFrame implies that this is a class subclassed from a QFrame. It origionally was but has since been updated to a QTabWidget. Whether or not it needs to be renamed is currently undecided. */ QInfoFrame::QInfoFrame( QWidget* parent, const char* name) : QTabWidget( parent ) { mapTab = new MapEdit( this ); gctpTab = new ProjectionEdit( this ); addTab( mapTab, "Map" ); addTab( gctpTab, "Projection" ); connect(mapTab, SIGNAL( copyButtonClicked() ), this, SLOT(copy())); connect(gctpTab, SIGNAL( copyButtonClicked() ), this, SLOT(copy())); connect(mapTab->lockButton, SIGNAL(toggled(bool)), this, SLOT(lock(bool)) ); connect(gctpTab->lockButton, SIGNAL(toggled(bool)), this, SLOT(lock(bool)) ); connect(mapTab, SIGNAL( frameButtonClicked() ), this, SLOT(frame())); connect(mapTab, SIGNAL( fillButtonClicked() ), this, SLOT(getFill()) ); locking = false; reset(); }
void GUIPolygon::storeTesselation() const { if (myDisplayList > 0) { glDeleteLists(myDisplayList, 1); } myDisplayList = glGenLists(1); if (myDisplayList == 0) { throw ProcessError("GUIPolygon::storeTesselation() could not create display list"); } glNewList(myDisplayList, GL_COMPILE); if (getFill()) { // draw the tesselated shape double* points = new double[myShape.size() * 3]; GLUtesselator* tobj = gluNewTess(); gluTessCallback(tobj, GLU_TESS_VERTEX, (GLvoid(APIENTRY*)()) &glVertex3dv); gluTessCallback(tobj, GLU_TESS_BEGIN, (GLvoid(APIENTRY*)()) &beginCallback); gluTessCallback(tobj, GLU_TESS_END, (GLvoid(APIENTRY*)()) &endCallback); //gluTessCallback(tobj, GLU_TESS_ERROR, (GLvoid (APIENTRY*) ()) &errorCallback); gluTessCallback(tobj, GLU_TESS_COMBINE, (GLvoid(APIENTRY*)()) &combineCallback); gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD); gluTessBeginPolygon(tobj, NULL); gluTessBeginContour(tobj); for (size_t i = 0; i != myShape.size(); ++i) { points[3 * i] = myShape[(int) i].x(); points[3 * i + 1] = myShape[(int) i].y(); points[3 * i + 2] = 0; gluTessVertex(tobj, points + 3 * i, points + 3 * i); } gluTessEndContour(tobj); gluTessEndPolygon(tobj); gluDeleteTess(tobj); delete[] points; } else { GLHelper::drawLine(myShape); GLHelper::drawBoxLines(myShape, 1.); } //std::cout << "OpenGL says: '" << gluErrorString(glGetError()) << "'\n"; glEndList(); }
fxBool ModemConfig::parseItem(const char* tag, const char* value) { int i; for (i = (sizeof ( atcmds ) / sizeof ( atcmds [0])) -1; i >= 0; i--) if ((strcasecmp( tag , atcmds[i].name )==0) ) { (*this).*atcmds[i].p = parseATCmd(value); return (((fxBool)1) ); } for (i = (sizeof ( fillorders ) / sizeof ( fillorders [0])) -1; i >= 0 ; i--) if ((strcasecmp( tag , fillorders[i].name )==0) ) { (*this).*fillorders[i].p = getFill(value); return (((fxBool)1) ); } for (i = (sizeof ( numbers ) / sizeof ( numbers [0])) -1; i >= 0 ; i--) if ((strcasecmp( tag , numbers[i].name )==0) ) { (*this).*numbers[i].p = atoi(value); return (((fxBool)1) ); } fxBool recognized = ((fxBool)1) ; if ((strcasecmp( tag , "ModemType" )==0) ) type = value; else if ((strcasecmp( tag , "ModemSetVolumeCmd" )==0) ) setVolumeCmds(value); else if ((strcasecmp( tag , "ModemFlowControl" )==0) ) flowControl = getFlow(value); else if ((strcasecmp( tag , "ModemMaxRate" )==0) || (strcasecmp( tag , "ModemRate" )==0) ) maxRate = getRate(value); else if ((strcasecmp( tag , "ModemWaitForConnect" )==0) ) waitForConnect = getBoolean(value); else if ((strcasecmp( tag , "Class2RecvDataTrigger" )==0) ) class2RecvDataTrigger = value; else if ((strcasecmp( tag , "Class2XmitWaitForXON" )==0) ) class2XmitWaitForXON = getBoolean(value); else recognized = ((fxBool)0) ; return (recognized); }
void NexusZone::renderDock(const Color &color) const { #ifndef ZAP_DEDICATED GameObjectRender::renderNexus(getOutline(), getFill(), false, 0); #endif }
void GUIPolygon::drawGL(const GUIVisualizationSettings& s) const { Boundary boundary = myShape.getBoxBoundary(); if (s.scale * MAX2(boundary.getWidth(), boundary.getHeight()) < s.minPolySize) { return; } if (getFill()) { if (myShape.size() < 3) { return; } } else { if (myShape.size() < 2) { return; } } AbstractMutex::ScopedLocker locker(myLock); //if (myDisplayList == 0 || (!getFill() && myLineWidth != s.polyExaggeration)) { // storeTesselation(s.polyExaggeration); //} glPushName(getGlID()); glPushMatrix(); glTranslated(0, 0, getLayer()); // XXX shape should be rotated around its center when initializing the polygon. do we even need this? //glRotated(getAngle(), 0, 0, 1); GLHelper::setColor(getColor()); int textureID = -1; if (getFill()) { const std::string& file = getImgFile(); if (file != "") { textureID = GUITexturesHelper::getTextureID(file); } } // init generation of texture coordinates if (textureID >= 0) { glEnable(GL_TEXTURE_2D); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); // without DEPTH_TEST vehicles may be drawn below roads glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); glDisable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBindTexture(GL_TEXTURE_2D, textureID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // http://www.gamedev.net/topic/133564-glutesselation-and-texture-mapping/ glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv(GL_S, GL_OBJECT_PLANE, xPlane); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv(GL_T, GL_OBJECT_PLANE, yPlane); } // recall tesselation //glCallList(myDisplayList); performTesselation(s.polyExaggeration); // de-init generation of texture coordinates if (textureID >= 0) { glEnable(GL_DEPTH_TEST); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); } glPopMatrix(); drawName(myShape.getPolygonCenter(), s.scale, s.polyName); glPopName(); }
bool PolygonObject::overlapsPoint(const Point &point) const { return triangulatedFillContains(getFill(), point); }
std::string CQIllustratorShape:: getSVGStroke() const { std::string str = "style=\""; const CQIllustratorShapeStroke &stroke = getStroke(); const CRGBA &scolor = stroke.getColor(); double sopacity = stroke.getOpacity(); double width = getStrokeWidth(); const CLineDash &dash = stroke.getLineDash(); CLineCapType cap = stroke.getLineCap(); CLineJoinType join = stroke.getLineJoin(); if (sopacity > 0.0) { str += CStrUtil::strprintf("stroke: rgb(%d,%d,%d);", scolor.getRedI(), scolor.getGreenI(), scolor.getBlueI()); if (sopacity < 1.0) str += CStrUtil::strprintf(" stroke-opacity: %g;", sopacity); } else str += "stroke: none;"; if (width != 1.0) str += CStrUtil::strprintf(" stroke-width: %g;", width); if (! dash.isSolid()) str += CStrUtil::strprintf("stroke-dasharray: %s", dash.toString().c_str()); if (cap == LINE_CAP_TYPE_ROUND) str += CStrUtil::strprintf(" stroke-linecap: round;"); else if (cap == LINE_CAP_TYPE_SQUARE) str += CStrUtil::strprintf(" stroke-linecap: square;"); if (join == LINE_JOIN_TYPE_ROUND) str += CStrUtil::strprintf(" stroke-linejoin: round;"); else if (join == LINE_JOIN_TYPE_BEVEL) str += CStrUtil::strprintf(" stroke-linejoin: bevel;"); const CQIllustratorShapeFill &fill = getFill(); if (fill.hasGradient()) { // TODO } else { const CRGBA &fcolor = fill.getColor(); double fopacity = fill.getOpacity(); if (fopacity > 0.0) { str += CStrUtil::strprintf(" fill: rgb(%d,%d,%d);", fcolor.getRedI(), fcolor.getGreenI(), fcolor.getBlueI()); if (fopacity < 1.0) str += CStrUtil::strprintf(" fill-opacity: %g;", fopacity); } else str += "fill: none;"; } str += "\""; return str; }
void CQIllustratorShape:: getControlPoints(ControlPointList &points, ControlType type) const { if (type == ControlType::GEOMETRY) { } else if (type == ControlType::LGRADIENT) { const CQIllustratorShapeFill &fill = getFill(); const CGenGradient *g = fill.getGradient(); const CLinearGradient *lg = dynamic_cast<const CLinearGradient *>(g); if (! lg) return; //CBBox2D bbox = getFlatBBox(); //double x1 = lg->getX1()*(bbox.getXMax() - bbox.getXMin()) + bbox.getXMin(); //double y1 = lg->getY1()*(bbox.getYMax() - bbox.getYMin()) + bbox.getYMin(); //double x2 = lg->getX2()*(bbox.getXMax() - bbox.getXMin()) + bbox.getXMin(); //double y2 = lg->getY2()*(bbox.getYMax() - bbox.getYMin()) + bbox.getYMin(); CPoint2D p1(lg->getX1(), lg->getY1()); CPoint2D p2(lg->getX2(), lg->getY2()); CQIllustratorShapeLGradientControlPoint *start = new CQIllustratorShapeLGradientControlPoint( CQIllustratorShapeLGradientControlPoint::Position::START, p1); CQIllustratorShapeLGradientControlPoint *end = new CQIllustratorShapeLGradientControlPoint( CQIllustratorShapeLGradientControlPoint::Position::END , p2); points.push_back(start); points.push_back(end); } else if (type == ControlType::RGRADIENT) { const CQIllustratorShapeFill &fill = getFill(); const CGenGradient *g = fill.getGradient(); const CRadialGradient *rg = dynamic_cast<const CRadialGradient *>(g); if (! rg) return; //CBBox2D bbox = getFlatBBox(); //double x1 = rg->getX1()*(bbox.getXMax() - bbox.getXMin()) + bbox.getXMin(); //double y1 = rg->getY1()*(bbox.getYMax() - bbox.getYMin()) + bbox.getYMin(); //double x2 = rg->getX2()*(bbox.getXMax() - bbox.getXMin()) + bbox.getXMin(); //double y2 = rg->getY2()*(bbox.getYMax() - bbox.getYMin()) + bbox.getYMin(); CPoint2D c(rg->getCenterX(), rg->getCenterY()); CPoint2D f(rg->getFocusX (), rg->getFocusY ()); double r1 = rg->getRadius()/sqrt(2); CPoint2D rp(c.x + r1, c.y + r1); CQIllustratorShapeRGradientControlPoint *center = new CQIllustratorShapeRGradientControlPoint( CQIllustratorShapeRGradientControlPoint::Position::CENTER, c); CQIllustratorShapeRGradientControlPoint *focus = new CQIllustratorShapeRGradientControlPoint( CQIllustratorShapeRGradientControlPoint::Position::FOCUS , f); CQIllustratorShapeRGradientControlPoint *radius = new CQIllustratorShapeRGradientControlPoint( CQIllustratorShapeRGradientControlPoint::Position::RADIUS, rp); points.push_back(center); points.push_back(focus); points.push_back(radius); } }
void GUIPolygon::drawGL(const GUIVisualizationSettings& s) const { if (s.polySize.getExaggeration(s) == 0) { return; } Boundary boundary = myShape.getBoxBoundary(); if (s.scale * MAX2(boundary.getWidth(), boundary.getHeight()) < s.polySize.minSize) { return; } if (getFill()) { if (myShape.size() < 3) { return; } } else { if (myShape.size() < 2) { return; } } AbstractMutex::ScopedLocker locker(myLock); //if (myDisplayList == 0 || (!getFill() && myLineWidth != s.polySize.getExaggeration(s))) { // storeTesselation(s.polySize.getExaggeration(s)); //} glPushName(getGlID()); glPushMatrix(); glTranslated(0, 0, getLayer()); glRotated(-getNaviDegree(), 0, 0, 1); GLHelper::setColor(getColor()); int textureID = -1; if (getFill()) { const std::string& file = getImgFile(); if (file != "") { textureID = GUITexturesHelper::getTextureID(file, true); } } // init generation of texture coordinates if (textureID >= 0) { glEnable(GL_TEXTURE_2D); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); // without DEPTH_TEST vehicles may be drawn below roads glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); glDisable(GL_ALPHA_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBindTexture(GL_TEXTURE_2D, textureID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // http://www.gamedev.net/topic/133564-glutesselation-and-texture-mapping/ glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv(GL_S, GL_OBJECT_PLANE, xPlane); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv(GL_T, GL_OBJECT_PLANE, yPlane); } // recall tesselation //glCallList(myDisplayList); performTesselation(myLineWidth * s.polySize.getExaggeration(s)); // de-init generation of texture coordinates if (textureID >= 0) { glEnable(GL_DEPTH_TEST); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); } #ifdef GUIPolygon_DEBUG_DRAW_VERTICES GLHelper::debugVertices(myShape, 80 / s.scale); #endif glPopMatrix(); const Position namePos = myShape.getPolygonCenter(); drawName(namePos, s.scale, s.polyName); if (s.polyType.show) { GLHelper::drawText(myType, namePos + Position(0, -0.6 * s.polyType.size / s.scale), GLO_MAX, s.polyType.size / s.scale, s.polyType.color); } glPopName(); }
void Circle::print() { std::cout << "circle " << cx << " " << cy << " " << getFill() << " " << getStroke() << " " << getStrokeWidth() << '\n'; }