static int ColorControlPointList_print(PyObject *v, FILE *fp, int flags) { ColorControlPointListObject *obj = (ColorControlPointListObject *)v; fprintf(fp, "%s", PyColorControlPointList_ToString(obj->data, "").c_str()); return 0; }
std::string PyColorControlPointList_GetLogString() { std::string s("ColorControlPointList = ColorControlPointList()\n"); if(currentAtts != 0) s += PyColorControlPointList_ToString(currentAtts, "ColorControlPointList."); return s; }
static void PyColorControlPointList_CallLogRoutine(Subject *subj, void *data) { typedef void (*logCallback)(const std::string &); logCallback cb = (logCallback)data; if(cb != 0) { std::string s("ColorControlPointList = ColorControlPointList()\n"); s += PyColorControlPointList_ToString(currentAtts, "ColorControlPointList."); cb(s); } }
std::string PyColorTableAttributes_ToString(const ColorTableAttributes *atts, const char *prefix) { std::string str; char tmpStr[1000]; { const stringVector &names = atts->GetNames(); SNPRINTF(tmpStr, 1000, "%snames = (", prefix); str += tmpStr; for(size_t i = 0; i < names.size(); ++i) { SNPRINTF(tmpStr, 1000, "\"%s\"", names[i].c_str()); str += tmpStr; if(i < names.size() - 1) { SNPRINTF(tmpStr, 1000, ", "); str += tmpStr; } } SNPRINTF(tmpStr, 1000, ")\n"); str += tmpStr; } { // new scope int index = 0; // Create string representation of colorTables from atts. for(AttributeGroupVector::const_iterator pos = atts->GetColorTables().begin(); pos != atts->GetColorTables().end(); ++pos, ++index) { const ColorControlPointList *current = (const ColorControlPointList *)(*pos); SNPRINTF(tmpStr, 1000, "GetColorTables(%d).", index); std::string objPrefix(prefix + std::string(tmpStr)); str += PyColorControlPointList_ToString(current, objPrefix.c_str()); } if(index == 0) str += "#colorTables does not contain any ColorControlPointList objects.\n"; } SNPRINTF(tmpStr, 1000, "%sactiveContinuous = \"%s\"\n", prefix, atts->GetActiveContinuous().c_str()); str += tmpStr; SNPRINTF(tmpStr, 1000, "%sactiveDiscrete = \"%s\"\n", prefix, atts->GetActiveDiscrete().c_str()); str += tmpStr; if(atts->GetGroupingFlag()) SNPRINTF(tmpStr, 1000, "%sgroupingFlag = 1\n", prefix); else SNPRINTF(tmpStr, 1000, "%sgroupingFlag = 0\n", prefix); str += tmpStr; return str; }
PyObject * ColorControlPointList_str(PyObject *v) { ColorControlPointListObject *obj = (ColorControlPointListObject *)v; return PyString_FromString(PyColorControlPointList_ToString(obj->data,"").c_str()); }
std::string PyMultiCurveAttributes_ToString(const MultiCurveAttributes *atts, const char *prefix) { std::string str; char tmpStr[1000]; { // new scope std::string objPrefix(prefix); objPrefix += "defaultPalette."; str += PyColorControlPointList_ToString(&atts->GetDefaultPalette(), objPrefix.c_str()); } { const unsignedCharVector &changedColors = atts->GetChangedColors(); SNPRINTF(tmpStr, 1000, "%schangedColors = (", prefix); str += tmpStr; for(size_t i = 0; i < changedColors.size(); ++i) { SNPRINTF(tmpStr, 1000, "%d", int(changedColors[i])); str += tmpStr; if(i < changedColors.size() - 1) { SNPRINTF(tmpStr, 1000, ", "); str += tmpStr; } } SNPRINTF(tmpStr, 1000, ")\n"); str += tmpStr; } const char *colorType_names = "ColorBySingleColor, ColorByMultipleColors"; switch (atts->GetColorType()) { case MultiCurveAttributes::ColorBySingleColor: SNPRINTF(tmpStr, 1000, "%scolorType = %sColorBySingleColor # %s\n", prefix, prefix, colorType_names); str += tmpStr; break; case MultiCurveAttributes::ColorByMultipleColors: SNPRINTF(tmpStr, 1000, "%scolorType = %sColorByMultipleColors # %s\n", prefix, prefix, colorType_names); str += tmpStr; break; default: break; } const unsigned char *singleColor = atts->GetSingleColor().GetColor(); SNPRINTF(tmpStr, 1000, "%ssingleColor = (%d, %d, %d, %d)\n", prefix, int(singleColor[0]), int(singleColor[1]), int(singleColor[2]), int(singleColor[3])); str += tmpStr; { const ColorAttributeList &cL = atts->GetMultiColor(); const char *comment = (prefix==0 || strcmp(prefix,"")==0) ? "# " : ""; for(int i = 0; i < cL.GetNumColors(); ++i) { const unsigned char *c = cL[i].GetColor(); SNPRINTF(tmpStr, 1000, "%s%sSetMultiColor(%d, (%d, %d, %d, %d))\n", comment, prefix, i, int(c[0]), int(c[1]), int(c[2]), int(c[3])); str += tmpStr; } } const char *lineStyle_values[] = {"SOLID", "DASH", "DOT", "DOTDASH"}; SNPRINTF(tmpStr, 1000, "%slineStyle = %s%s # SOLID, DASH, DOT, DOTDASH\n", prefix, prefix, lineStyle_values[atts->GetLineStyle()]); str += tmpStr; SNPRINTF(tmpStr, 1000, "%slineWidth = %d\n", prefix, atts->GetLineWidth()); str += tmpStr; SNPRINTF(tmpStr, 1000, "%syAxisTitleFormat = \"%s\"\n", prefix, atts->GetYAxisTitleFormat().c_str()); str += tmpStr; if(atts->GetUseYAxisTickSpacing()) SNPRINTF(tmpStr, 1000, "%suseYAxisTickSpacing = 1\n", prefix); else SNPRINTF(tmpStr, 1000, "%suseYAxisTickSpacing = 0\n", prefix); str += tmpStr; SNPRINTF(tmpStr, 1000, "%syAxisTickSpacing = %g\n", prefix, atts->GetYAxisTickSpacing()); str += tmpStr; if(atts->GetDisplayMarkers()) SNPRINTF(tmpStr, 1000, "%sdisplayMarkers = 1\n", prefix); else SNPRINTF(tmpStr, 1000, "%sdisplayMarkers = 0\n", prefix); str += tmpStr; SNPRINTF(tmpStr, 1000, "%smarkerVariable = \"%s\"\n", prefix, atts->GetMarkerVariable().c_str()); str += tmpStr; if(atts->GetDisplayIds()) SNPRINTF(tmpStr, 1000, "%sdisplayIds = 1\n", prefix); else SNPRINTF(tmpStr, 1000, "%sdisplayIds = 0\n", prefix); str += tmpStr; SNPRINTF(tmpStr, 1000, "%sidVariable = \"%s\"\n", prefix, atts->GetIdVariable().c_str()); str += tmpStr; if(atts->GetLegendFlag()) SNPRINTF(tmpStr, 1000, "%slegendFlag = 1\n", prefix); else SNPRINTF(tmpStr, 1000, "%slegendFlag = 0\n", prefix); str += tmpStr; return str; }