Changeset 3568 for trunk/packages/vizservers/nanovis/Command.cpp
- Timestamp:
- Mar 24, 2013 11:39:16 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Command.cpp
r3567 r3568 56 56 #include "CmdProc.h" 57 57 #include "Trace.h" 58 #ifdef PLANE_CMD59 #include "PlaneRenderer.h"60 #endif61 58 #ifdef USE_POINTSET_RENDERER 62 59 #include "PointSet.h" … … 118 115 static Tcl_ObjCmdProc GridCmd; 119 116 static Tcl_ObjCmdProc LegendCmd; 120 #ifdef PLANE_CMD121 static Tcl_ObjCmdProc PlaneCmd;122 #endif123 117 static Tcl_ObjCmdProc ScreenCmd; 124 118 static Tcl_ObjCmdProc SnapshotCmd; … … 1618 1612 } 1619 1613 std::vector<Volume *>::iterator iter; 1620 for (iter = ivol.begin(); iter != ivol.end(); iter++) {1614 for (iter = ivol.begin(); iter != ivol.end(); ++iter) { 1621 1615 TRACE("setting %s with transfer function %s", (*iter)->name(), 1622 1616 tf->name()); … … 2152 2146 return TCL_OK; 2153 2147 } 2154 2155 #ifdef PLANE_CMD2156 static int2157 PlaneAddOp(ClientData clientData, Tcl_Interp *interp, int objc,2158 Tcl_Obj *const *objv)2159 {2160 TRACE("load plane for 2D visualization command");2161 2162 int index, w, h;2163 if (objc != 4) {2164 Tcl_AppendResult(interp, "wrong # args: should be \"",2165 Tcl_GetString(objv[0]), " plane_index w h \"", (char*)NULL);2166 return TCL_ERROR;2167 }2168 if (Tcl_GetIntFromObj(interp, objv[1], &index) != TCL_OK) {2169 return TCL_ERROR;2170 }2171 if (index >= NanoVis::numPlanes) {2172 Tcl_AppendResult(interp, "Invalid plane_index", (char*)NULL);2173 return TCL_ERROR;2174 }2175 if (Tcl_GetIntFromObj(interp, objv[2], &w) != TCL_OK) {2176 return TCL_ERROR;2177 }2178 if (Tcl_GetIntFromObj(interp, objv[3], &h) != TCL_OK) {2179 return TCL_ERROR;2180 }2181 2182 //Now read w*h*4 bytes. The server expects the plane to be a stream of2183 //floats2184 char *tmp = new char[int(w*h*sizeof(float))];2185 if (tmp == NULL) {2186 Tcl_AppendResult(interp, "can't allocate stream data", (char *)NULL);2187 return TCL_ERROR;2188 }2189 bzero(tmp, w*h*4);2190 int status = read(fileno(NanoVis::stdin), tmp, w*h*sizeof(float));2191 if (status <= 0) {2192 delete[] tmp;2193 Tcl_AppendResult(interp, "Failed to read image data for plane", (char*)NULL);2194 return TCL_ERROR;2195 }2196 NanoVis::plane[index] = new Texture2D(w, h, GL_FLOAT, GL_LINEAR, 1, (float*)tmp);2197 delete[] tmp;2198 return TCL_OK;2199 }2200 2201 static int2202 PlaneLinkOp(ClientData clientData, Tcl_Interp *interp, int objc,2203 Tcl_Obj *const *objv)2204 {2205 TRACE("link the plane to the 2D renderer command");2206 2207 int plane_index;2208 2209 if (objc != 3) {2210 Tcl_AppendResult(interp, "wrong # args: should be \"",2211 Tcl_GetString(objv[0]), " plane_index transfunc_name \"", (char*)NULL);2212 return TCL_ERROR;2213 }2214 if (Tcl_GetIntFromObj(interp, objv[1], &plane_index) != TCL_OK) {2215 return TCL_ERROR;2216 }2217 if (plane_index >= NanoVis::numPlanes) {2218 Tcl_AppendResult(interp, "Invalid plane_index", (char*)NULL);2219 return TCL_ERROR;2220 }2221 NanoVis::planeRenderer->addPlane(NanoVis::plane[plane_index],2222 NanoVis::getTransfunc(Tcl_GetString(objv[2])));2223 return TCL_OK;2224 }2225 2226 //Enable a 2D plane for render2227 //The plane_index is the index mantained in the 2D plane renderer2228 static int2229 PlaneEnableOp(ClientData clientData, Tcl_Interp *interp, int objc,2230 Tcl_Obj *const *objv)2231 {2232 TRACE("enable a plane so the 2D renderer can render it command");2233 2234 if (objc != 3) {2235 Tcl_AppendResult(interp, "wrong # args: should be \"",2236 Tcl_GetString(objv[0]), " plane_index mode \"", (char*)NULL);2237 return TCL_ERROR;2238 }2239 int plane_index;2240 if (Tcl_GetIntFromObj(interp, objv[1], &plane_index) != TCL_OK) {2241 return TCL_ERROR;2242 }2243 if (plane_index >= NanoVis::numPlanes) {2244 Tcl_AppendResult(interp, "Invalid plane_index", (char*)NULL);2245 return TCL_ERROR;2246 } else if (plane_index < 0) {2247 plane_index = -1;2248 }2249 2250 NanoVis::planeRenderer->setActivePlane(plane_index);2251 return TCL_OK;2252 }2253 2254 static Rappture::CmdSpec planeOps[] = {2255 {"active", 2, PlaneEnableOp, 3, 3, "planeIdx",},2256 {"add", 2, PlaneAddOp, 5, 5, "planeIdx width height",},2257 {"link", 1, PlaneLinkOp, 4, 4, "planeIdx transfunc_name",},2258 };2259 static int nPlaneOps = NumCmdSpecs(planeOps);2260 2261 static int2262 PlaneCmd(ClientData clientData, Tcl_Interp *interp, int objc,2263 Tcl_Obj *const *objv)2264 {2265 Tcl_ObjCmdProc *proc;2266 2267 proc = Rappture::GetOpFromObj(interp, nPlaneOps, planeOps,2268 Rappture::CMDSPEC_ARG1, objc, objv, 0);2269 if (proc == NULL) {2270 return TCL_ERROR;2271 }2272 return (*proc) (clientData, interp, objc, objv);2273 }2274 2275 #endif /*PLANE_CMD*/2276 2148 2277 2149 /* … … 2341 2213 Tcl_CreateObjCommand(interp, "heightmap", HeightMapCmd, NULL, NULL); 2342 2214 Tcl_CreateObjCommand(interp, "legend", LegendCmd, NULL, NULL); 2343 #ifdef PLANE_CMD2344 Tcl_CreateObjCommand(interp, "plane", PlaneCmd, NULL, NULL);2345 #endif2346 2215 Tcl_CreateObjCommand(interp, "screen", ScreenCmd, NULL, NULL); 2347 2216 Tcl_CreateObjCommand(interp, "snapshot", SnapshotCmd, NULL, NULL);
Note: See TracChangeset
for help on using the changeset viewer.