Ignore:
Timestamp:
Aug 27, 2014 1:08:53 PM (7 years ago)
Author:
ldelgass
Message:

Add some Makefile flags for sleep throttling settings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • geovis/trunk/RendererCmd.cpp

    r4575 r4628  
    666666
    667667static int
     668FilePutOp(ClientData clientData, Tcl_Interp *interp, int objc,
     669          Tcl_Obj *const *objv)
     670{
     671    long size;
     672    const char *path = Tcl_GetString(objv[2]);
     673    if (Tcl_GetLongFromObj(interp, objv[4], &size) != TCL_OK ||
     674        size < 1) {
     675        return TCL_ERROR;
     676    }
     677    char *data = (char *)malloc((size_t)size);
     678    if (!SocketRead(data, size)) {
     679        free(data);
     680        return TCL_ERROR;
     681    }
     682    std::ostringstream fullPath;
     683    //fullPath << "/tmp/" << path;
     684    fullPath << path;
     685    FILE *fp = fopen(fullPath.str().c_str(), "wb");
     686    if (fp == NULL) {
     687        free(data);
     688        return TCL_ERROR;
     689    }
     690    int bytesWritten = fwrite(data, 1, (size_t)size, fp);
     691    fclose(fp);
     692    free(data);
     693    return (bytesWritten == size) ? TCL_OK : TCL_ERROR;
     694}
     695
     696static CmdSpec fileOps[] = {
     697    {"put",    1, FilePutOp, 5, 5, "name type size"}
     698};
     699static int nFileOps = NumCmdSpecs(fileOps);
     700
     701static int
     702FileCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     703          Tcl_Obj *const *objv)
     704{
     705    Tcl_ObjCmdProc *proc;
     706
     707    proc = GetOpFromObj(interp, nFileOps, fileOps,
     708                        CMDSPEC_ARG1, objc, objv, 0);
     709    if (proc == NULL) {
     710        return TCL_ERROR;
     711    }
     712    return (*proc) (clientData, interp, objc, objv);
     713}
     714
     715static int
    668716ImageFlushCmd(ClientData clientData, Tcl_Interp *interp, int objc,
    669717              Tcl_Obj *const *objv)
     
    804852    char *type = Tcl_GetString(objv[3]);
    805853    if (type[0] == 'i' && strcmp(type, "image") == 0) {
     854        bool ret;
     855        char *name;
    806856        char *driver = Tcl_GetString(objv[4]);
    807857        std::string url;
     
    817867        if (driver[0] == 'd' && strcmp(driver, "debug") == 0) {
    818868            osgEarth::Drivers::DebugOptions opts;
    819             char *name = Tcl_GetString(objv[5]);
    820             g_renderer->addImageLayer(name, opts);
     869            name = Tcl_GetString(objv[5]);
     870            ret = g_renderer->addImageLayer(name, opts);
    821871        } else if (driver[0] == 'g' && strcmp(driver, "gdal") == 0) {
    822872            osgEarth::Drivers::GDALOptions opts;
    823873            opts.url() = url;
    824             char *name = Tcl_GetString(objv[6]);
    825             g_renderer->addImageLayer(name, opts);
     874            name = Tcl_GetString(objv[6]);
     875            ret = g_renderer->addImageLayer(name, opts);
    826876        } else if (driver[0] == 't' && strcmp(driver, "tms") == 0) {
    827877            osgEarth::Drivers::TMSOptions opts;
     
    831881            //opts.tmsType() = tmsType;
    832882            //opts.format() = format;
    833             char *name = Tcl_GetString(objv[6]);
    834             g_renderer->addImageLayer(name, opts);
     883            name = Tcl_GetString(objv[6]);
     884            ret = g_renderer->addImageLayer(name, opts);
    835885        } else if (driver[0] == 'w' && strcmp(driver, "wms") == 0) {
    836886            osgEarth::Drivers::WMSOptions opts;
     
    846896            opts.transparent() = transparent;
    847897
    848             char *name = Tcl_GetString(objv[9]);
    849             g_renderer->addImageLayer(name, opts);
     898            name = Tcl_GetString(objv[9]);
     899            ret = g_renderer->addImageLayer(name, opts);
    850900        } else if (driver[0] == 'x' && strcmp(driver, "xyz") == 0) {
    851901            osgEarth::Drivers::XYZOptions opts;
     
    855905            //opts.invertY() = invertY;
    856906            //opts.format() = Tcl_GetString(objv[6]);
    857             char *name = Tcl_GetString(objv[6]);
    858             g_renderer->addImageLayer(name, opts);
     907            name = Tcl_GetString(objv[6]);
     908            ret = g_renderer->addImageLayer(name, opts);
    859909        } else {
    860910            Tcl_AppendResult(interp, "unknown image driver \"", driver,
    861911                             "\": should be 'debug', 'gdal', 'tms', 'wms' or 'xyz'", (char*)NULL);
     912            return TCL_ERROR;
     913        }
     914        if (!ret) {
     915            Tcl_AppendResult(interp, "Failed to add image layer \"", name, "\"", (char*)NULL);
    862916            return TCL_ERROR;
    863917        }
     
    19812035    Tcl_CreateObjCommand(interp, "clientinfo",     ClientInfoCmd,     clientData, NULL);
    19822036    Tcl_CreateObjCommand(interp, "colormap",       ColorMapCmd,       clientData, NULL);
     2037    Tcl_CreateObjCommand(interp, "file",           FileCmd,           clientData, NULL);
    19832038    Tcl_CreateObjCommand(interp, "imgflush",       ImageFlushCmd,     clientData, NULL);
    19842039    Tcl_CreateObjCommand(interp, "key",            KeyCmd,            clientData, NULL);
     
    19972052    Tcl_DeleteCommand(interp, "clientinfo");
    19982053    Tcl_DeleteCommand(interp, "colormap");
     2054    Tcl_DeleteCommand(interp, "file");
    19992055    Tcl_DeleteCommand(interp, "imgflush");
    20002056    Tcl_DeleteCommand(interp, "key");
Note: See TracChangeset for help on using the changeset viewer.