r5231: Auto commit for Debian build
[ctsim.git] / libctsim / trace.cpp
index dced2c66cd9dd4d3bdb40b145730f804b6c5fa54..73636ed30cd87f328713c0ce143f5c92144f4255 100644 (file)
@@ -8,7 +8,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: trace.cpp,v 1.2 2000/08/25 15:59:13 kevin Exp $
+**  $Id: trace.cpp,v 1.4 2003/07/04 21:39:40 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
 
 #include "ct.h"
 
-const char TraceLevel::TRACE_NONE_STR[]=     "none";
-const char TraceLevel::TRACE_TEXT_STR[]=     "text";
-const char TraceLevel::TRACE_PHM_STR[]=      "phm";
-const char TraceLevel::TRACE_RAYS_STR[]=     "rays";
-const char TraceLevel::TRACE_PLOT_STR[]=     "plot";
-const char TraceLevel::TRACE_CLIPPING_STR[]= "clipping";
+const int Trace::TRACE_INVALID = -1;
+const int Trace::TRACE_NONE = 0;
+const int Trace::TRACE_CONSOLE = 1;
+const int Trace::TRACE_PHANTOM = 2;
+const int Trace::TRACE_PROJECTIONS = 3;
+const int Trace::TRACE_PLOT = 4;
+const int Trace::TRACE_CLIPPING = 5;
 
+const int Trace::BIT_CONSOLE = 0x0001;
+const int Trace::BIT_PHANTOM = 0x0002;
+const int Trace::BIT_PROJECTIONS = 0x0004;
+const int Trace::BIT_PLOT = 0x0008;
+const int Trace::BIT_CLIPPING = 0x0010;
 
-int
-TraceLevel::convertTraceNameToID (const char *traceString)
+const char* Trace::s_aszTraceName[] = 
+{
+  "none",
+  "console",
+  "phantom",
+  "proj",
+  "plot",
+  "clipping",
+};
+
+const char* Trace::s_aszTraceTitle[] = 
+{
+  "None",
+  "Console",
+  "Phantom",
+  "Projections",
+  "Plot",
+  "Clipping",
+};
+
+const int Trace::s_iTraceCount = sizeof(s_aszTraceName) / sizeof(const char*);
+
+
+const char*
+Trace::convertTraceIDToName (const int idTrace)
+{
+  const char *name = "";
+
+  if (idTrace >= 0 && idTrace < s_iTraceCount)
+      return (s_aszTraceName[idTrace]);
+
+  return (name);
+}
+
+const char*
+Trace::convertTraceIDToTitle (const int idTrace)
 {
-  int traceID = TRACE_INVALID;
-
-  if (strcasecmp (traceString, TRACE_NONE_STR) == 0)
-    traceID = TRACE_NONE;
-  else if (strcasecmp (traceString, TRACE_TEXT_STR) == 0)
-    traceID = TRACE_TEXT;
-  else if (strcasecmp (traceString, TRACE_PHM_STR) == 0)
-    traceID = TRACE_PHM;
-  else if (strcasecmp (traceString, TRACE_PLOT_STR) == 0)
-    traceID = TRACE_PLOT;
-  else if (strcasecmp (traceString, TRACE_CLIPPING_STR) == 0)
-    traceID = TRACE_CLIPPING;
-  else if (strcasecmp (traceString, TRACE_RAYS_STR) == 0)
-    traceID = TRACE_RAYS;
-
-  return (traceID);
+  const char *title = "";
+
+  if (idTrace >= 0 && idTrace < s_iTraceCount)
+      return (s_aszTraceName[idTrace]);
+
+  return (title);
 }
+      
+int
+Trace::convertTraceNameToID (const char* const traceName) 
+{
+  int id = Trace::TRACE_INVALID;
 
+  for (int i = 0; i < s_iTraceCount; i++)
+      if (strcasecmp (traceName, s_aszTraceName[i]) == 0) {
+         id = i;
+         break;
+      }
+
+  return (id);
+}