Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Display.cpp

Go to the documentation of this file.
00001 /* ImLib3D
00002  * Copyright (c) 2001, ULP-IPB Strasbourg.
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or (at
00007  * your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00020 #include<ImLib3D/ImLib3D.hpp>
00021 #include<ImLib3D/Display.hpp>
00022 
00023 //  void 
00024 //  ImLib3DDisplay::Show(const Image3Df &ima){imLib3D.display->ShowImage(ima);}
00025 
00026 void 
00027 ImLib3DDisplay::Set(ImLib3DDisplay *newDisp)
00028 {
00029     if(imLib3D.display)
00030     {
00031         delete imLib3D.display;
00032     }
00033     imLib3D.display=newDisp;
00034 }
00035 
00036 void 
00037 TextDisplay::ShowImage(const Image3Df &ima)
00038 {
00039     mprintf("TextDisplay:Image:Size:%3d %3d %3d\n",ima.Width(),ima.Height(),ima.Depth());
00040 //      mprintf("      properties:support:%x:",(uint)ima.properties.support);
00041 //      if(ima.properties.support)
00042 //      {
00043 //          ima.properties.support->GetP0().Show("P0:"," ");
00044 //          ima.properties.support->GetP1().Show("P1:"," ");
00045 //      }
00046     mprintf("\n");
00047     mprintf("      properties:mask:%x:",(uint)ima.properties.mask);
00048     if(ima.properties.mask)
00049     {
00050         mprintf("Size:%3d %3d %3d\n",
00051                ima.properties.mask->Width(),
00052                ima.properties.mask->Height(),
00053                ima.properties.mask->Depth());
00054     }
00055     mprintf("\n");
00056     if(ima.properties.iCenter)
00057     {
00058         ima.properties.iCenter->Show("iCenter:","\n");
00059     }
00060 }   
00061 
00062 void
00063 TextDisplay::ShowImages(Image3DSet<Image3Df>& images)
00064 {
00065     for (int i=0; i<images.Size(); i++)
00066     {
00067         ShowImage(images.GetImage(i));
00068     }
00069 }
00070 
00071 void
00072 ViewerDisplay::ShowImage(const Image3Df &ima)
00073 {
00074     string fname =WriteTmpFile("empty");
00075     ima.WriteToFile(fname);
00076     string cmd=prgPath+" "+fname;
00077     if(system(cmd.c_str()))
00078     {
00079         mprintf("WARNING: had trouble while executing command:\"%s\"",cmd.c_str());
00080 #ifdef __GNUC__
00081         ThrowError("ViewerDisplay::ShowImage");
00082 #endif
00083     }
00084     RemoveFile(fname);
00085 }
00086 
00087 // Not very nice - some duplicate code with above...
00088 void 
00089 ViewerDisplay::ShowImages(Image3DSet<Image3Df> &images)
00090 {
00091     vector<string> flist;
00092     string cmd=prgPath;
00093     for (int i=0; i<images.Size(); i++)
00094     {
00095         string fname = WriteTmpFile("empty");
00096         flist.push_back(fname);
00097 //      cmd += " "+fname;
00098 
00099         Image3Df imaf = images.GetImage(i);
00100         imaf.WriteToFile(fname);
00101     }
00102     if (!flist.size())
00103         return;
00104     if (flist.size() ==1)
00105         cmd += " " + flist[0];
00106     else 
00107     {
00108         uint i;
00109         for (i=0;i<flist.size()-1;i++)
00110         {
00111             cmd += " " + flist[i] + " -d";
00112         }
00113         cmd += " " + flist[i];
00114     }
00115     if(system(cmd.c_str()))
00116     {
00117         mprintf("WARNING: had trouble while executing command:\"%s\"",cmd.c_str());
00118 #ifdef __GNUC__
00119         ThrowError("ViewerDisplay::ShowImages");
00120 #endif
00121     }
00122     RemoveFiles(flist);
00123 }
00124 
00125 
00126 ViewerDisplay::ViewerDisplay()
00127 {
00128     prgPath="imlib3dview";
00129 //      prgPath=IMLIB3DVIEW;
00130 //      FILE *F;
00131 //      if(!(F=fopen(prgPath.c_str(),"r")))
00132 //      {
00133 //          mprintf("WARNING: could not find viewer at:\"%s\",using your current PATH",IMLIB3DVIEW);
00134 //          prgPath="imlib3dview";
00135 //      }
00136 //      else
00137 //      {
00138 //          fclose(F);
00139 //      }
00140 }

Generated on Fri Jun 17 13:36:00 2005 for ImLib3D by  doxygen 1.4.2