/* reinit a subwindow (but don't change position) */ static void reinitSubWin(int iSubWinUID) { int visible = 0; int firstPlot = 0; int axisLocation = 0; int iLabelUID = 0; int iChildrenCount = 0; int *piChildrenCount = &iChildrenCount; int i = 0; int* piChildrenUID = NULL; /* Deletes the Axes' children */ getGraphicObjectProperty(iSubWinUID, __GO_CHILDREN_COUNT__, jni_int, (void **) &piChildrenCount); if (iChildrenCount != 0) { getGraphicObjectProperty(iSubWinUID, __GO_CHILDREN__, jni_int_vector, (void **) &piChildrenUID); for (i = 0 ; i < iChildrenCount ; ++i) { deleteGraphicObject(piChildrenUID[i]); } } initSubWinBounds(iSubWinUID); iLabelUID = initLabel(iSubWinUID); setGraphicObjectProperty(iSubWinUID, __GO_TITLE__, &iLabelUID, jni_int, 1); iLabelUID = initLabel(iSubWinUID); setGraphicObjectProperty(iSubWinUID, __GO_X_AXIS_LABEL__, &iLabelUID, jni_int, 1); iLabelUID = initLabel(iSubWinUID); setGraphicObjectProperty(iSubWinUID, __GO_Y_AXIS_LABEL__, &iLabelUID, jni_int, 1); iLabelUID = initLabel(iSubWinUID); setGraphicObjectProperty(iSubWinUID, __GO_Z_AXIS_LABEL__, &iLabelUID, jni_int, 1); /* bottom */ axisLocation = 0; setGraphicObjectProperty(iSubWinUID, __GO_X_AXIS_LOCATION__, &axisLocation, jni_int, 1); /* left */ axisLocation = 4; setGraphicObjectProperty(iSubWinUID, __GO_Y_AXIS_LOCATION__, &axisLocation, jni_int, 1); visible = 1; setGraphicObjectProperty(iSubWinUID, __GO_VISIBLE__, &visible, jni_bool, 1); firstPlot = 1; setGraphicObjectProperty(iSubWinUID, __GO_FIRST_PLOT__, &firstPlot, jni_bool, 1); initSubWinAngles(iSubWinUID); }
/** * Constructor. */ RS_Line::RS_Line(RS_EntityContainer* parent, const RS_LineData& d) :RS_AtomicEntity(parent), data(d), division(1), point_set(false) { calculateBorders(); initLabel(); }
LinkLabel::LinkLabel(const QString &title, const QString &icon, LinkLook *look, int hAlign, int vAlign, QWidget *parent, Qt::WFlags f) : QFrame(parent, f), m_isSelected(false), m_isHovered(false), m_look(0) { initLabel(hAlign, vAlign); setLink(title, icon, look); }
/* generate code for an if/elseif statement */ void genIf(node *stmt, codelabel *endif) { node *expr = stmt->internal.child[0]; node *thenstmts = stmt->internal.child[1]; /* stmtlist */ node *elsestmt = stmt->internal.child[2]; /* Nelseif/Nelse */ codelabel elselabel; if(elsestmt) { //make sure there is an else initLabel(&elselabel, "else"); genCondExpr(expr, FALSE, &elselabel); } else { genCondExpr(expr, FALSE, endif); } genStmtList(thenstmts, endif); if(elsestmt) { outputCmd("jmp", 0); outputLabel(endif); placeLabel(&elselabel); genStmt(elsestmt, endif); } }
// on "init" you need to initialize your instance bool OptionScene::init() { ////////////////////////////// // 1. super init first if ( !Layer::init() ) { return false; } // 화면 사이즈 SizeW = Director::getInstance()->getWinSize().width; SizeH = Director::getInstance()->getWinSize().height; iMusic = SimpleAudioEngine::getInstance()->isBackgroundMusicPlaying(); // 메뉴 배경화면 초기화 initBackGround(); // 메뉴 초기화 initMenu(); // 라벨 초기화 initLabel(); menuView(); return true; }
/** * Constructor. * * @para parent Parent Entity Container. * @para d Common dimension geometrical data. * @para ed Extended geometrical data for angular dimension. */ RS_DimAngular::RS_DimAngular(RS_EntityContainer* parent, const RS_DimensionData& d, const RS_DimAngularData& ed) : RS_Dimension(parent, d), edata(ed) { calculateBorders(); initLabel(); }
/* generate code for a while statement */ void genWhile(node *stmt, codelabel *endwhile) { codelabel loop; initLabel(&loop, "while"); loop.referenced = TRUE; //do this because we place the label before we output here placeLabel(&loop); genCondExpr(stmt->internal.child[0], FALSE, endwhile); genStmtList(stmt->internal.child[1], &loop); outputCmd("jmp", 0); outputLabel(&loop); }
//============================================================================== // Constructors/Deconstructors //============================================================================== Galaxy::Galaxy(dirnode *r, list<filenode*> *f, cluster_type m, string n, list<string>* t) { cout << "making a galaxy...\n"; if (r != NULL) setDirectory(r); else { root = NULL; files = f; } if (root != NULL && n == "") name = root->path + root->name; else name = n; xPos = 0; yPos = 0; side = 0; diameter = 64.0 * pow((3.0*(double)files->size())/(4.0*M_PI),(1.0/3.0)); radius = diameter/2; thickness = pow(radius*2.0,.5); setRotation(0,0); setRotationSpeed(0.02); rotZ = 0; tags = t; if (tags == NULL) rebuildTags(); cluster_mode = m; sectors = NULL; selected = NULL; buildSectors(); tex_data = NULL; initTexture(); refreshTex(); label = NULL; initLabel(); starSelectionLabel = new DrawText(" Star Selection Mode"); starSelectionLabel->setAlignment(LEFT); starSelectionLabel->setTextColor(0,0,0,1); starSelectionLabel->refreshTexture(); cout << "galaxy built\n"; }
/** * @param parent The graphic this block belongs to. */ RS_Insert::RS_Insert(RS_EntityContainer* parent, const RS_InsertData& d) : RS_EntityContainer(parent), data(d) { block = NULL; if (data.updateMode!=RS2::NoUpdate) { update(); //calculateBorders(); } initLabel(); }
/* Generate code for function */ void genFun(node *funnode) { node *funname = funnode->internal.child[1]; node *funstmts = funnode->internal.child[3]; placeFunLabel(funname->ident.STentry->lexptr); currentfundesc = funname->ident.decl; initLabel(&funend, "funend"); createFrame(TRUE, funname->ident.STentry->lexptr); genStmtList(funstmts, &funend); placeLabel(&funend); removeFrame(TRUE, funname->ident.STentry->lexptr); }
/* Generate code for a statement list */ void genStmtList(node *stmtlist, codelabel *next) { if (stmtlist != NULL) { codelabel nextstmt; while (stmtlist->internal.child[1] != NULL){ initLabel(&nextstmt,"stmt"); genStmt(stmtlist->internal.child[0], &nextstmt); placeLabel(&nextstmt); stmtlist = stmtlist->internal.child[1]; } // do the last statement genStmt(stmtlist->internal.child[0], next); } }
int main(int argc, char **argv) { if (argc != 3) { printf("Usage: %s <input> <output>\n", argv[0]); exit(EXIT_FAILURE); } // Initialize alias, label list initAlias(); initLabel(); // Parse the input ISA file and write to output parseFile(argv[1], argv[2]); // Free alias, label list clearAlias(); clearLabel(); exit(EXIT_SUCCESS); }
int msAddLabel(mapObj *map, labelObj *label, int layerindex, int classindex, shapeObj *shape, pointObj *point, labelPathObj *labelpath, double featuresize) { int i; labelCacheSlotObj *cacheslot; labelCacheMemberObj *cachePtr=NULL; layerObj *layerPtr=NULL; classObj *classPtr=NULL; if(!label) return(MS_FAILURE); // RFC 77 TODO: set a proper message if(label->status == MS_OFF) return(MS_SUCCESS); /* not an error */ if(!label->annotext) { /* check if we have a labelpnt style */ for(i=0; i<label->numstyles; i++) { if(label->styles[i]->_geomtransform.type == MS_GEOMTRANSFORM_LABELPOINT) break; } if(i==label->numstyles) { /* label has no text or marker symbols */ return MS_SUCCESS; } } layerPtr = (GET_LAYER(map, layerindex)); /* set up a few pointers for clarity */ classPtr = GET_LAYER(map, layerindex)->class[classindex]; if(classPtr->leader.maxdistance) { if (layerPtr->type == MS_LAYER_ANNOTATION) { msSetError(MS_MISCERR, "LEADERs are not supported on annotation layers", "msAddLabel()"); return MS_FAILURE; } if(labelpath) { msSetError(MS_MISCERR, "LEADERs are not supported on ANGLE FOLLOW labels", "msAddLabel()"); return MS_FAILURE; } } /* check that the label intersects the layer mask */ if (layerPtr->mask) { int maskLayerIdx = msGetLayerIndex(map, layerPtr->mask); layerObj *maskLayer = GET_LAYER(map, maskLayerIdx); unsigned char *alphapixptr; if (maskLayer->maskimage && MS_IMAGE_RENDERER(maskLayer->maskimage)->supports_pixel_buffer) { rasterBufferObj rb; memset(&rb, 0, sizeof (rasterBufferObj)); MS_IMAGE_RENDERER(maskLayer->maskimage)->getRasterBufferHandle(maskLayer->maskimage, &rb); if (point) { int x = MS_NINT(point->x); int y = MS_NINT(point->y); /* Using label repeatdistance, we might have a point with x/y below 0. See #4764 */ if (x >= 0 && x < rb.width && y >= 0 && y < rb.height) { #ifdef USE_GD if(rb.type == MS_BUFFER_BYTE_RGBA) { alphapixptr = rb.data.rgba.a+rb.data.rgba.row_step*y + rb.data.rgba.pixel_step*x; if(!*alphapixptr) { /* label point does not intersect mask */ return MS_SUCCESS; } } else { if(!gdImageGetPixel(rb.data.gd_img,x,y)) { return MS_SUCCESS; } } #else assert(rb.type == MS_BUFFER_BYTE_RGBA); alphapixptr = rb.data.rgba.a+rb.data.rgba.row_step*y + rb.data.rgba.pixel_step*x; if(!*alphapixptr) { /* label point does not intersect mask */ return MS_SUCCESS; } #endif } } else if (labelpath) { int i = 0; for (i = 0; i < labelpath->path.numpoints; i++) { int x = MS_NINT(labelpath->path.point[i].x); int y = MS_NINT(labelpath->path.point[i].y); /* Using label repeatdistance, we might have a point with x/y below 0. See #4764 */ if (x >= 0 && x < rb.width && y >= 0 && y < rb.height) { #ifdef USE_GD if (rb.type == MS_BUFFER_BYTE_RGBA) { alphapixptr = rb.data.rgba.a + rb.data.rgba.row_step * y + rb.data.rgba.pixel_step*x; if (!*alphapixptr) { /* label point does not intersect mask */ msFreeLabelPathObj(labelpath); return MS_SUCCESS; } } else { if (!gdImageGetPixel(rb.data.gd_img, x, y)) { msFreeLabelPathObj(labelpath); return MS_SUCCESS; } } #else assert(rb.type == MS_BUFFER_BYTE_RGBA); alphapixptr = rb.data.rgba.a + rb.data.rgba.row_step * y + rb.data.rgba.pixel_step*x; if (!*alphapixptr) { /* label point does not intersect mask */ msFreeLabelPathObj(labelpath); return MS_SUCCESS; } #endif } } } } else { msSetError(MS_MISCERR, "Layer (%s) references references a mask layer, but the selected renderer does not support them", "msAddLabel()", layerPtr->name); return (MS_FAILURE); } } /* Validate label priority value and get ref on label cache for it */ if (label->priority < 1) label->priority = 1; else if (label->priority > MS_MAX_LABEL_PRIORITY) label->priority = MS_MAX_LABEL_PRIORITY; cacheslot = &(map->labelcache.slots[label->priority-1]); if(cacheslot->numlabels == cacheslot->cachesize) { /* just add it to the end */ cacheslot->labels = (labelCacheMemberObj *) realloc(cacheslot->labels, sizeof(labelCacheMemberObj)*(cacheslot->cachesize+MS_LABELCACHEINCREMENT)); MS_CHECK_ALLOC(cacheslot->labels, sizeof(labelCacheMemberObj)*(cacheslot->cachesize+MS_LABELCACHEINCREMENT), MS_FAILURE); cacheslot->cachesize += MS_LABELCACHEINCREMENT; } cachePtr = &(cacheslot->labels[cacheslot->numlabels]); cachePtr->layerindex = layerindex; /* so we can get back to this *raw* data if necessary */ cachePtr->classindex = classindex; if(shape) { cachePtr->shapetype = shape->type; } else { cachePtr->shapetype = MS_SHAPE_POINT; } cachePtr->leaderline = NULL; cachePtr->leaderbbox = NULL; /* Store the label point or the label path (Bug #1620) */ if ( point ) { cachePtr->point = *point; /* the actual label point */ cachePtr->labelpath = NULL; } else { assert(labelpath); cachePtr->labelpath = labelpath; /* Use the middle point of the labelpath for mindistance calculations */ cachePtr->point = labelpath->path.point[labelpath->path.numpoints / 2]; } /* TODO: perhaps we can get rid of this next section and just store a marker size? Why do we cache the styles for a point layer? */ /* copy the styles (only if there is an accompanying marker) * We cannot simply keeep refs because the rendering code alters some members of the style objects */ cachePtr->styles = NULL; cachePtr->numstyles = 0; if(layerPtr->type == MS_LAYER_ANNOTATION && classPtr->numstyles > 0) { cachePtr->numstyles = classPtr->numstyles; cachePtr->styles = (styleObj *) msSmallMalloc(sizeof(styleObj)*classPtr->numstyles); if (classPtr->numstyles > 0) { for(i=0; i<classPtr->numstyles; i++) { initStyle(&(cachePtr->styles[i])); msCopyStyle(&(cachePtr->styles[i]), classPtr->styles[i]); } } } /* copy the label */ cachePtr->numlabels = 1; cachePtr->labels = (labelObj *) msSmallMalloc(sizeof(labelObj)); initLabel(cachePtr->labels); msCopyLabel(cachePtr->labels, label); cachePtr->markerid = -1; cachePtr->featuresize = featuresize; //cachePtr->poly = (shapeObj *) msSmallMalloc(sizeof(shapeObj)); //msInitShape(cachePtr->poly); cachePtr->poly = NULL; cachePtr->status = MS_FALSE; if(layerPtr->type == MS_LAYER_POINT && classPtr->numstyles > 0) { /* cache the marker placement, it's already on the map */ rectObj rect; double w, h; if(cacheslot->nummarkers == cacheslot->markercachesize) { /* just add it to the end */ cacheslot->markers = (markerCacheMemberObj *) realloc(cacheslot->markers, sizeof(markerCacheMemberObj)*(cacheslot->cachesize+MS_LABELCACHEINCREMENT)); MS_CHECK_ALLOC(cacheslot->markers, sizeof(markerCacheMemberObj)*(cacheslot->cachesize+MS_LABELCACHEINCREMENT), MS_FAILURE); cacheslot->markercachesize+=MS_LABELCACHEINCREMENT; } i = cacheslot->nummarkers; cacheslot->markers[i].poly = (shapeObj *) msSmallMalloc(sizeof(shapeObj)); msInitShape(cacheslot->markers[i].poly); /* TO DO: at the moment only checks the bottom style, perhaps should check all of them */ /* #2347: after RFC-24 classPtr->styles could be NULL so we check it */ if(classPtr->styles != NULL) { if(msGetMarkerSize(&map->symbolset, classPtr->styles[0], &w, &h, layerPtr->scalefactor) != MS_SUCCESS) return(MS_FAILURE); rect.minx = point->x - .5 * w; rect.miny = point->y - .5 * h; rect.maxx = rect.minx + (w-1); rect.maxy = rect.miny + (h-1); msRectToPolygon(rect, cacheslot->markers[i].poly); cacheslot->markers[i].id = cacheslot->numlabels; cachePtr->markerid = i; cacheslot->nummarkers++; } } cacheslot->numlabels++; /* Maintain main labelCacheObj.numlabels only for backwards compatibility */ map->labelcache.numlabels++; return(MS_SUCCESS); }
void NodeCom::initWithMap(rapidjson::Value& value) { auto visibleSize=Director::getInstance()->getVisibleSize(); node=cocos2d::Node::create(); if (value.HasMember("contentSize")) { auto size=cocos2d::SizeFromString(value["contentSize"].GetString()); if (size.width<0) size.width=visibleSize.width; if (size.height<0) size.height=visibleSize.height; node->setContentSize(size); } else { node->setContentSize(visibleSize); } if (value.HasMember("anchorPoint")) { node->setAnchorPoint(cocos2d::PointFromString(value["anchorPoint"].GetString())); } cocos2d::Point position=value.HasMember("position")?cocos2d::PointFromString(value["position"].GetString()):cocos2d::Point::ZERO; if (value.HasMember("anchor")) { node->setPosition(getRealPosition(cocos2d::Director::getInstance()->getVisibleSize(), position, cocos2d::PointFromString(value["anchor"].GetString()))); } else if (value.HasMember("position")) { node->setPosition(cocos2d::PointFromString(value["position"].GetString())); } if (value.HasMember("Node")) { int count=value["Node"].Size(); for (int i=0; i<count; i++) { rapidjson::Value& nodeValue=value["Node"][i]; if (!nodeValue.IsNull()&&nodeValue.HasMember("type")) { const char* type=nodeValue["type"].GetString(); cocos2d::Node* child=nullptr; if (strcmp("Label", type)==0) { child=initLabel(nodeValue); } else if (strcmp("Sprite", type)==0) { child=initSprite(nodeValue); } else if (strcmp("Layer", type)==0) { child=initLayer(nodeValue); } else if (strcmp("Button", type)==0) { child=initButton(nodeValue); } else if (strcmp("TableView", type)==0){ child=initTable(nodeValue); } else if (strcmp("ProgressTimer", type)==0){ child=initTimer(nodeValue); } if (child!=nullptr) { node->addChild(child); if (nodeValue.HasMember("name")) { const char* name= nodeValue["name"].GetString(); __nodeNames.insert(std::make_pair(name, child)); } if (nodeValue.HasMember("scale")) { cocos2d::Point point=cocos2d::PointFromString(nodeValue["scale"].GetString()); child->setScale(point.x, point.y); } if (nodeValue.HasMember("position")) { child->setPosition(cocos2d::PointFromString(nodeValue["position"].GetString())); } if (nodeValue.HasMember("anchorPoint")) { child->setAnchorPoint(cocos2d::PointFromString(nodeValue["anchorPoint"].GetString())); } if (nodeValue.HasMember("localZOrder")) { child->setLocalZOrder(nodeValue["localZOrder"].GetInt()); } if (nodeValue.HasMember("globalOrder")) { child->setGlobalZOrder(nodeValue["globalOrder"].GetInt()); } if (nodeValue.HasMember("visible")) { child->setVisible(nodeValue["visible"].GetBool()); } if (nodeValue.HasMember("tag")) { child->setTag(nodeValue["tag"].GetInt()); } //如果声明了anchor,则按照新的规则布局 cocos2d::Point position1=nodeValue.HasMember("position")? cocos2d::PointFromString(nodeValue["position"].GetString()):cocos2d::Point::ZERO; if (nodeValue.HasMember("anchor")) { child->setPosition(getRealPosition(node->getContentSize(), position1, cocos2d::PointFromString(nodeValue["anchor"].GetString()))); } else if (nodeValue.HasMember("position")) { child->setPosition(position1); } } } } } }
// --------------------------------------------------------------------------------- void KDurationStatusUpdater::onCurrentlySelectedDaysDurationChanged ( int duration ) { if(statusBar()->statusBar()== 0){return;} if(label() == 0) {initLabel();} label()->setText(duration_formatter().format(duration)); }
// --------------------------------------------------------------------------------- void KDurationStatusUpdater::onCurrentProjectChanged ( QString const& project_description ) { if(statusBar()->statusBar()== 0){return;} if(label() == 0) {initLabel();} label()->setToolTip(project_description); }
int32_t main() { int32_t x; x = 1; int32_t y; int32_t temp_0 = 2 * x; int32_t temp_1 = temp_0 + 1; y = temp_1; int32_t z; char* label; char* temp_2 = initLabel(); char *temp_3 = (char *)malloc(5 + strlen(temp_2)); *((int*) temp_3) = strlen(temp_2); temp_3 += 4; strcpy(temp_3, temp_2); label = temp_3; int32_t* p; printf ("%d\n", globalInt); int32_t temp_4 = x * y; int32_t temp_5 = y + temp_4; int32_t* temp_6 = &globalInt; p = temp_6; int32_t temp_7 = fact(y, p); printf ("%d\n", temp_7); int32_t temp_8 = temp_5 + temp_7; z = temp_8; char *temp_9 = (char *)malloc(5 + strlen(" = ")); *((int*) temp_9) = strlen(" = "); temp_9 += 4; strcpy(temp_9, " = "); char* temp_10 = string_add(label, temp_9); char *temp_11 = (char *)malloc(5 + strlen(temp_10)); *((int*) temp_11) = strlen(temp_10); temp_11 += 4; strcpy(temp_11, temp_10); label = temp_11; char *temp_12 = (char *)malloc(5 + strlen("%s %d\n")); *((int*) temp_12) = strlen("%s %d\n"); temp_12 += 4; strcpy(temp_12, "%s %d\n"); char *temp_13 = (char *)malloc(5 + strlen(label)); *((int*) temp_13) = strlen(label); temp_13 += 4; strcpy(temp_13, label); int32_t temp_14 = printf(temp_12, temp_13, z); char *temp_15 = (char *)malloc(5 + strlen("The label '%s' has length %d\n")); *((int*) temp_15) = strlen("The label '%s' has length %d\n"); temp_15 += 4; strcpy(temp_15, "The label '%s' has length %d\n"); int32_t temp_16 = nstrlen(label); char *temp_17 = (char *)malloc(5 + strlen(label)); *((int*) temp_17) = strlen(label); temp_17 += 4; strcpy(temp_17, label); int32_t temp_18 = printf(temp_15, temp_17, temp_16); char *temp_19 = (char *)malloc(5 + strlen("globalInt = %d\n")); *((int*) temp_19) = strlen("globalInt = %d\n"); temp_19 += 4; strcpy(temp_19, "globalInt = %d\n"); int32_t temp_20 = printf(temp_19, *p); return 0; }
int msAddLabelGroup(mapObj *map, int layerindex, int classindex, shapeObj *shape, pointObj *point, double featuresize) { int i, priority, numactivelabels=0; labelCacheSlotObj *cacheslot; labelCacheMemberObj *cachePtr=NULL; layerObj *layerPtr=NULL; classObj *classPtr=NULL; layerPtr = (GET_LAYER(map, layerindex)); /* set up a few pointers for clarity */ classPtr = GET_LAYER(map, layerindex)->class[classindex]; if(classPtr->numlabels == 0) return MS_SUCCESS; /* not an error just nothing to do */ for(i=0; i<classPtr->numlabels; i++) { if(classPtr->labels[i]->status == MS_ON) { numactivelabels++; } } if(numactivelabels == 0) return MS_SUCCESS; /* if the number of labels is 1 then call msAddLabel() accordingly */ if(numactivelabels == 1) { for(i=0; i<classPtr->numlabels; i++) { if(classPtr->labels[i]->status == MS_ON) return msAddLabel(map, classPtr->labels[i], layerindex, classindex, shape, point, NULL, featuresize); } } if (layerPtr->type == MS_LAYER_ANNOTATION && (classPtr->numlabels > 1 || classPtr->leader.maxdistance)) { msSetError(MS_MISCERR, "Multiple Labels and/or LEADERs are not supported with annotation layers", "msAddLabelGroup()"); return MS_FAILURE; } /* check that the label intersects the layer mask */ if(layerPtr->mask) { int maskLayerIdx = msGetLayerIndex(map,layerPtr->mask); layerObj *maskLayer = GET_LAYER(map,maskLayerIdx); unsigned char *alphapixptr; if(maskLayer->maskimage && MS_IMAGE_RENDERER(maskLayer->maskimage)->supports_pixel_buffer) { rasterBufferObj rb; int x,y; memset(&rb,0,sizeof(rasterBufferObj)); MS_IMAGE_RENDERER(maskLayer->maskimage)->getRasterBufferHandle(maskLayer->maskimage,&rb); x = MS_NINT(point->x); y = MS_NINT(point->y); /* Using label repeatdistance, we might have a point with x/y below 0. See #4764 */ if (x >= 0 && x < rb.width && y >= 0 && y < rb.height) { #ifdef USE_GD if(rb.type == MS_BUFFER_BYTE_RGBA) { alphapixptr = rb.data.rgba.a+rb.data.rgba.row_step*y + rb.data.rgba.pixel_step*x; if(!*alphapixptr) { /* label point does not intersect mask */ return MS_SUCCESS; } } else { if(!gdImageGetPixel(rb.data.gd_img,x,y)) return MS_SUCCESS; } #else assert(rb.type == MS_BUFFER_BYTE_RGBA); alphapixptr = rb.data.rgba.a+rb.data.rgba.row_step*y + rb.data.rgba.pixel_step*x; if(!*alphapixptr) { /* label point does not intersect mask */ return MS_SUCCESS; } #endif } } else { msSetError(MS_MISCERR, "Layer (%s) references references a mask layer, but the selected renderer does not support them", "msAddLabelGroup()", layerPtr->name); return (MS_FAILURE); } } /* Validate label priority value and get ref on label cache for it */ priority = classPtr->labels[0]->priority; /* take priority from the first label */ if (priority < 1) priority = 1; else if (priority > MS_MAX_LABEL_PRIORITY) priority = MS_MAX_LABEL_PRIORITY; cacheslot = &(map->labelcache.slots[priority-1]); if(cacheslot->numlabels == cacheslot->cachesize) { /* just add it to the end */ cacheslot->labels = (labelCacheMemberObj *) realloc(cacheslot->labels, sizeof(labelCacheMemberObj)*(cacheslot->cachesize+MS_LABELCACHEINCREMENT)); MS_CHECK_ALLOC(cacheslot->labels, sizeof(labelCacheMemberObj)*(cacheslot->cachesize+MS_LABELCACHEINCREMENT), MS_FAILURE); cacheslot->cachesize += MS_LABELCACHEINCREMENT; } cachePtr = &(cacheslot->labels[cacheslot->numlabels]); cachePtr->layerindex = layerindex; /* so we can get back to this *raw* data if necessary */ cachePtr->classindex = classindex; if(shape) { cachePtr->shapetype = shape->type; } else { cachePtr->shapetype = MS_SHAPE_POINT; } cachePtr->point = *point; /* the actual label point */ cachePtr->labelpath = NULL; cachePtr->leaderline = NULL; cachePtr->leaderbbox = NULL; // cachePtr->text = msStrdup(string); /* the actual text */ /* TODO: perhaps we can get rid of this next section and just store a marker size? Why do we cache the styles for a point layer? */ /* copy the styles (only if there is an accompanying marker) * We cannot simply keep refs because the rendering code might alters some members of the style objects */ cachePtr->styles = NULL; cachePtr->numstyles = 0; if(layerPtr->type == MS_LAYER_ANNOTATION && classPtr->numstyles > 0) { cachePtr->numstyles = classPtr->numstyles; cachePtr->styles = (styleObj *) msSmallMalloc(sizeof(styleObj)*classPtr->numstyles); if (classPtr->numstyles > 0) { for(i=0; i<classPtr->numstyles; i++) { initStyle(&(cachePtr->styles[i])); msCopyStyle(&(cachePtr->styles[i]), classPtr->styles[i]); } } } /* ** copy the labels (we are guaranteed to have more than one): ** we cannot simply keep refs because the rendering code alters some members of the style objects */ cachePtr->numlabels = 0; cachePtr->labels = (labelObj *) msSmallMalloc(sizeof(labelObj)*numactivelabels); for(i=0; i<classPtr->numlabels; i++) { if(classPtr->labels[i]->status == MS_OFF) continue; initLabel(&(cachePtr->labels[cachePtr->numlabels])); msCopyLabel(&(cachePtr->labels[cachePtr->numlabels]), classPtr->labels[i]); cachePtr->numlabels++; } assert(cachePtr->numlabels == numactivelabels); cachePtr->markerid = -1; cachePtr->featuresize = featuresize; //cachePtr->poly = (shapeObj *) msSmallMalloc(sizeof(shapeObj)); //msInitShape(cachePtr->poly); cachePtr->poly = NULL; cachePtr->status = MS_FALSE; if(layerPtr->type == MS_LAYER_POINT && classPtr->numstyles > 0) { /* cache the marker placement, it's already on the map */ /* TO DO: at the moment only checks the bottom style, perhaps should check all of them */ /* #2347: after RFC-24 classPtr->styles could be NULL so we check it */ rectObj rect; double w, h; if(msGetMarkerSize(&map->symbolset, classPtr->styles[0], &w, &h, layerPtr->scalefactor) != MS_SUCCESS) return(MS_FAILURE); if(cacheslot->nummarkers == cacheslot->markercachesize) { /* just add it to the end */ cacheslot->markers = (markerCacheMemberObj *) realloc(cacheslot->markers, sizeof(markerCacheMemberObj)*(cacheslot->cachesize+MS_LABELCACHEINCREMENT)); MS_CHECK_ALLOC(cacheslot->markers, sizeof(markerCacheMemberObj)*(cacheslot->cachesize+MS_LABELCACHEINCREMENT), MS_FAILURE); cacheslot->markercachesize+=MS_LABELCACHEINCREMENT; } i = cacheslot->nummarkers; cacheslot->markers[i].poly = (shapeObj *) msSmallMalloc(sizeof(shapeObj)); msInitShape(cacheslot->markers[i].poly); rect.minx = (point->x - .5 * w); rect.miny = (point->y - .5 * h); rect.maxx = rect.minx + (w-1); rect.maxy = rect.miny + (h-1); msRectToPolygon(rect, cacheslot->markers[i].poly); cacheslot->markers[i].id = cacheslot->numlabels; cachePtr->markerid = i; cacheslot->nummarkers++; } cacheslot->numlabels++; /* Maintain main labelCacheObj.numlabels only for backwards compatibility */ map->labelcache.numlabels++; return(MS_SUCCESS); }
int InitAxesModel() { int cubeScaling = 0; int logFlag = 0; int ticksColor = 0; int axisLocation = 0; int boxType = 0; int filled = 0; int gridColor = 0; int gridPosition = 0; int view = 0; int axisReverse = 0; int axisVisible = 0; int defaultNumberTicks = 0; int autoTicks = 0; int autoSubticks = 0; int nbSubticks = 0; int hiddenAxisColor = 0; int hiddenColor = 0; int isoview = 0; int visible = 0; int *piVisible = &visible; int clipState = 0; int tightLimits = 0; int arcDrawingMethod = 0; int labelsFontStyle = 6; int labelsFontColor = -1; int i = 0; double labelsFontSize = 1; double axesBounds[4]; double dataBounds[6]; double rotationAngles[2]; double tab[] = { 0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. }; /* graduations init. tmptab */ /* z-axis initial ticks locations */ double tabZTicksLocations[] = { -1.0, -0.8, -0.6, -0.4, -0.2, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }; char labelBuffer[LABEL_BUFFER_LENGTH]; char **stringVector = NULL; int lineColor = -1; int background = -2; int foreground = -1; double lineWidth = 1.0; /* 0: solid */ int lineStyle = 0; int markMode = 0; int lineMode = 1; int fillMode = 1; int markStyle = 0; int markSize = 0; /* 0: point, 1: tabulated */ int markSizeUnit = 1; int iLabelUID = 0; int iFiguremdlUID = getFigureModel(); int iAxesmdlUID = getAxesModel(); sciInitGraphicMode(iAxesmdlUID); setGraphicObjectProperty(iAxesmdlUID, __GO_BACKGROUND__, &background, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_LINE_COLOR__, &foreground, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_FONT_SIZE__, &labelsFontSize, jni_double, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_FONT_COLOR__, &labelsFontColor, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_FONT_STYLE__, &labelsFontStyle, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_LINE_THICKNESS__, &lineWidth, jni_double, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_LINE_STYLE__, &lineStyle, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_MARK_MODE__, &markMode, jni_bool, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_LINE_MODE__, &lineMode, jni_bool, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_FILL_MODE__, &fillMode, jni_bool, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_MARK_STYLE__, &markStyle, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_MARK_SIZE__, &markSize, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_MARK_SIZE_UNIT__, &markSizeUnit, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_MARK_BACKGROUND__, &background, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_MARK_FOREGROUND__, &foreground, jni_int, 1); cubeScaling = 0; setGraphicObjectProperty(iAxesmdlUID, __GO_CUBE_SCALING__, &cubeScaling, jni_bool, 1); /* Log flags set to linear for the 3 axes */ logFlag = 0; setGraphicObjectProperty(iAxesmdlUID, __GO_X_AXIS_LOG_FLAG__, &logFlag, jni_bool, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Y_AXIS_LOG_FLAG__, &logFlag, jni_bool, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Z_AXIS_LOG_FLAG__, &logFlag, jni_bool, 1); ticksColor = -1; setGraphicObjectProperty(iAxesmdlUID, __GO_TICKS_COLOR__, &ticksColor, jni_int, 1); nbSubticks = 1; setGraphicObjectProperty(iAxesmdlUID, __GO_X_AXIS_SUBTICKS__, &nbSubticks, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Y_AXIS_SUBTICKS__, &nbSubticks, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Z_AXIS_SUBTICKS__, &nbSubticks, jni_int, 1); /* 0 corresponds to bottom position */ axisLocation = 0; setGraphicObjectProperty(iAxesmdlUID, __GO_X_AXIS_LOCATION__, &axisLocation, jni_int, 1); /* 4 corresponds to left position */ axisLocation = 4; setGraphicObjectProperty(iAxesmdlUID, __GO_Y_AXIS_LOCATION__, &axisLocation, jni_int, 1); /* 0 corresponds to OFF */ boxType = 0; setGraphicObjectProperty(iAxesmdlUID, __GO_BOX_TYPE__, &boxType, jni_int, 1); filled = 1; setGraphicObjectProperty(iAxesmdlUID, __GO_FILLED__, &filled, jni_bool, 1); gridColor = -1; setGraphicObjectProperty(iAxesmdlUID, __GO_X_AXIS_GRID_COLOR__, &gridColor, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Y_AXIS_GRID_COLOR__, &gridColor, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Z_AXIS_GRID_COLOR__, &gridColor, jni_int, 1); /* 0: background */ setGraphicObjectProperty(iAxesmdlUID, __GO_LINE_COLOR__, &lineColor, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_BACKGROUND__, &background, jni_int, 1); gridPosition = 0; setGraphicObjectProperty(iAxesmdlUID, __GO_GRID_POSITION__, &gridPosition, jni_int, 1); rotationAngles[0] = 0.0; rotationAngles[1] = 270.0; setGraphicObjectProperty(iAxesmdlUID, __GO_ROTATION_ANGLES__, rotationAngles, jni_double_vector, 2); /* 0: 2D view */ view = 0; setGraphicObjectProperty(iAxesmdlUID, __GO_VIEW__, &view, jni_int, 1); /* Must be set after VIEW, since setting VIEW to 2D overwrites the 3D rotation angles */ rotationAngles[0] = 45.0; rotationAngles[1] = 215.0; setGraphicObjectProperty(iAxesmdlUID, __GO_ROTATION_ANGLES_3D__, rotationAngles, jni_double_vector, 2); axisVisible = 0; setGraphicObjectProperty(iAxesmdlUID, __GO_X_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Y_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Z_AXIS_VISIBLE__, &axisVisible, jni_bool, 1); axisReverse = 0; setGraphicObjectProperty(iAxesmdlUID, __GO_X_AXIS_REVERSE__, &axisReverse, jni_bool, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Y_AXIS_REVERSE__, &axisReverse, jni_bool, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Z_AXIS_REVERSE__, &axisReverse, jni_bool, 1); /* Corresponds to the MVC AUTO_SUBTICKS property (!flagNax is equivalent to AUTO_SUBTICKS) */ #if 0 ppaxesmdl->flagNax = FALSE; #endif autoSubticks = 1; setGraphicObjectProperty(iAxesmdlUID, __GO_AUTO_SUBTICKS__, &autoSubticks, jni_bool, 1); /* To be corrected when the equivalent of flagnax is implemented within the MVC */ nbSubticks = 1; setGraphicObjectProperty(iAxesmdlUID, __GO_X_AXIS_SUBTICKS__, &nbSubticks, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Y_AXIS_SUBTICKS__, &nbSubticks, jni_int, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Z_AXIS_SUBTICKS__, &nbSubticks, jni_int, 1); /* * The code creating default ticks labels and positions should be put * into the Model. Ticks positions and locations should be computed using the default data bounds * instead of using pre-defined values. * Note that the pre-MVC ticks labels creation code is implemented in the C++ Renderer module * and should be moved to the Java Model's relevant parts (TicksProperty). */ /* * Automatic ticks computation must be activated for the 3 axes before setting ticks values to * ensure that the ticks values set are the automatic ticks' ones. */ autoTicks = 1; setGraphicObjectProperty(iAxesmdlUID, __GO_X_AXIS_AUTO_TICKS__, &autoTicks, jni_bool, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Y_AXIS_AUTO_TICKS__, &autoTicks, jni_bool, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Z_AXIS_AUTO_TICKS__, &autoTicks, jni_bool, 1); defaultNumberTicks = 11; setGraphicObjectProperty(iAxesmdlUID, __GO_X_AXIS_TICKS_LOCATIONS__, tab, jni_double_vector, defaultNumberTicks); setGraphicObjectProperty(iAxesmdlUID, __GO_Y_AXIS_TICKS_LOCATIONS__, tab, jni_double_vector, defaultNumberTicks); stringVector = createStringArray(defaultNumberTicks); if (stringVector == NULL) { return -1; } /* * A proper format should be used (ChoixFormatE function) */ for (i = 0; i < defaultNumberTicks; i++) { sprintf(labelBuffer, "%.1f", tab[i]); stringVector[i] = os_strdup(labelBuffer); if (stringVector[i] == NULL) { return -1; } } setGraphicObjectProperty(iAxesmdlUID, __GO_X_AXIS_TICKS_LABELS__, stringVector, jni_string_vector, defaultNumberTicks); setGraphicObjectProperty(iAxesmdlUID, __GO_Y_AXIS_TICKS_LABELS__, stringVector, jni_string_vector, defaultNumberTicks); /* * The same number of ticks is used now for the x,y and z axes. * Previously, the z-axis contained only 3 ticks (-1, 0, 1). However, the renderer module was * overriding this default number (3) by creating an 11-tick z-axis when required (3D view). * Ticks locations and labels are however different for the z-axis (from -1 to +1 instead of 0 to 1). */ setGraphicObjectProperty(iAxesmdlUID, __GO_Z_AXIS_TICKS_LOCATIONS__, tabZTicksLocations, jni_double_vector, defaultNumberTicks); /* ChoixFormatE should be used */ for (i = 0; i < defaultNumberTicks; i++) { FREE(stringVector[i]); sprintf(labelBuffer, "%.1f", tabZTicksLocations[i]); stringVector[i] = os_strdup(labelBuffer); if (stringVector[i] == NULL) { return -1; } } setGraphicObjectProperty(iAxesmdlUID, __GO_Z_AXIS_TICKS_LABELS__, stringVector, jni_string_vector, defaultNumberTicks); destroyStringArray(stringVector, defaultNumberTicks); /* * Indicates the direction of projection (0 for the axis corresponding to the direction, * 1 for the others). * To be implemented within the MVC if determined to be useful. */ #if 0 ppaxesmdl->project[0] = 1; ppaxesmdl->project[1] = 1; ppaxesmdl->project[2] = 0; #endif hiddenAxisColor = 4; setGraphicObjectProperty(iAxesmdlUID, __GO_HIDDEN_AXIS_COLOR__, &hiddenAxisColor, jni_int, 1); hiddenColor = 4; setGraphicObjectProperty(iAxesmdlUID, __GO_HIDDEN_COLOR__, &hiddenColor, jni_int, 1); isoview = 0; setGraphicObjectProperty(iAxesmdlUID, __GO_ISOVIEW__, &isoview, jni_bool, 1); /* Axes bounds set to fill the whole drawing area */ axesBounds[0] = 0.0; axesBounds[1] = 0.0; axesBounds[2] = 1.0; axesBounds[3] = 1.0; setGraphicObjectProperty(iAxesmdlUID, __GO_AXES_BOUNDS__, axesBounds, jni_double_vector, 4); /* xmin, xmax */ dataBounds[0] = 0.0; dataBounds[1] = 1.0; /* ymin, ymax */ dataBounds[2] = 0.0; dataBounds[3] = 1.0; /* zmin, zmax */ dataBounds[4] = -1.0; dataBounds[5] = 1.0; setGraphicObjectProperty(iAxesmdlUID, __GO_DATA_BOUNDS__, dataBounds, jni_double_vector, 6); /* visible */ getGraphicObjectProperty(iFiguremdlUID, __GO_VISIBLE__, jni_bool, (void**)&piVisible); setGraphicObjectProperty(iAxesmdlUID, __GO_VISIBLE__, &visible, jni_bool, 1); /* 0: clipping off */ clipState = 0; setGraphicObjectProperty(iAxesmdlUID, __GO_CLIP_STATE__, &clipState, jni_int, 1); /* "real data bounds" and "data bounds" are initially the same */ setGraphicObjectProperty(iAxesmdlUID, __GO_REAL_DATA_BOUNDS__, dataBounds, jni_double_vector, 6); tightLimits = 0; setGraphicObjectProperty(iAxesmdlUID, __GO_X_TIGHT_LIMITS__, &tightLimits, jni_bool, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Y_TIGHT_LIMITS__, &tightLimits, jni_bool, 1); setGraphicObjectProperty(iAxesmdlUID, __GO_Z_TIGHT_LIMITS__, &tightLimits, jni_bool, 1); /* Sets the default arc drawing method to lines (1), which is faster */ arcDrawingMethod = 1; setGraphicObjectProperty(iAxesmdlUID, __GO_ARC_DRAWING_METHOD__, &arcDrawingMethod, jni_int, 1); /* Creates the Axes model's labels and sets the model as their parent */ iLabelUID = initLabel(iAxesmdlUID); setGraphicObjectProperty(iAxesmdlUID, __GO_TITLE__, &iLabelUID, jni_int, 1); iLabelUID = initLabel(iAxesmdlUID); setGraphicObjectProperty(iAxesmdlUID, __GO_X_AXIS_LABEL__, &iLabelUID, jni_int, 1); iLabelUID = initLabel(iAxesmdlUID); setGraphicObjectProperty(iAxesmdlUID, __GO_Y_AXIS_LABEL__, &iLabelUID, jni_int, 1); iLabelUID = initLabel(iAxesmdlUID); setGraphicObjectProperty(iAxesmdlUID, __GO_Z_AXIS_LABEL__, &iLabelUID, jni_int, 1); return 0; }
LinkLabel::LinkLabel(int hAlign, int vAlign, QWidget *parent, Qt::WFlags f) : QFrame(parent, f), m_isSelected(false), m_isHovered(false), m_look(0) { initLabel(hAlign, vAlign); }