Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members Related Pages Search
fgccreator.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "fgccreator.h"
00019
00020 #include <qimage.h>
00021
00022
00023
00024 #include "functiongraph.h"
00025 #include "polargraph.h"
00026 #include "parametricgraph.h"
00027 #include "densityplot.h"
00028 #include "statplotgraph.h"
00029 #include "glfunctiongraph.h"
00030 #include "glpolargraph.h"
00031 #include "glcylindricalgraph.h"
00032
00033 #include "loader.h"
00034
00035 extern "C"
00036 {
00037 ThumbCreator *new_creator()
00038 {
00039 return new FGCCreator;
00040 }
00041 };
00042
00043 bool FGCCreator::create(const QString &path, int width, int height, QImage &img)
00044 {
00045 std::ifstream fileInput(path);
00046 if (fileInput.bad())
00047 return false;
00048
00049 CommonGraph *graph = 0;
00050
00051 char str[256];
00052 while ((fileInput>>str) != 0)
00053 {
00054 if (strcmp(str,"[FunctionGraph]") == 0)
00055 {
00056 qDebug("Loading Function Graph");
00057 graph = new FunctionGraph;
00058 }
00059 if (strcmp(str,"[PolarGraph]") == 0)
00060 {
00061 qDebug("Loading Polar Graph");
00062 graph = new PolarGraph;
00063 }
00064 if (strcmp(str,"[ParametricGraph]") == 0)
00065 {
00066 qDebug("Loading Parametric Graph");
00067 graph = new ParametricGraph;
00068 }
00069 if (strcmp(str,"[StatPlotGraph]") == 0)
00070 {
00071 qDebug("Loading Stat Plot Graph");
00072 graph = new StatPlotGraph;
00073 }
00074 if (strcmp(str,"[DensityPlot]") == 0)
00075 {
00076 qDebug("Loading Density Plot");
00077 graph = new DensityPlot;
00078 }
00079 #ifdef GLGRAPH
00080 if (strcmp(str,"[3DFunctionGraph]") == 0)
00081 {
00082 qDebug("Loading 3D Function Graph");
00083 graph = new GLFunctionGraph;
00084 }
00085 if (strcmp(str,"[3DPolarGraph]") == 0)
00086 {
00087 qDebug("Loading 3D Polar Graph");
00088 graph = new GLPolarGraph;
00089 }
00090 if (strcmp(str,"[3DCylindricalGraph]") == 0)
00091 {
00092 qDebug("Loading 3D Cylindrical Graph");
00093 graph = new GLCylindricalGraph;
00094 }
00095 #endif //GLGRAPH
00096
00097 if ( graph )
00098 {
00099 graph->load(fileInput);
00100 break;
00101 }
00102 }
00103
00104 if (!graph)
00105 return false;
00106
00107 if (dynamic_cast<Animator*>(graph))
00108 dynamic_cast<Animator*>(graph)->setDisplayAnimatorValue(false);
00109
00110 graph->setScale(false);
00111
00112 ExpressionGraph* e_graph;
00113 GLExpressionGraph* gle_graph;
00114 if ( (e_graph = dynamic_cast<ExpressionGraph*>(graph)) )
00115 {
00116 e_graph->setDisplayExpressionText(false);
00117 e_graph->offscreenResize(width,height);
00118 }
00119 else if ( (gle_graph = dynamic_cast<GLExpressionGraph*>(graph)) )
00120 {
00121 gle_graph->resize(width,height);
00122 }
00123
00124 QPixmap pm(width,height);
00125 graph->getPixmap(pm);
00126 delete graph;
00127
00128 img = pm.convertToImage();
00129
00130 return true;
00131 }
00132
00133 ThumbCreator::Flags FGCCreator::flags() const
00134 {
00135 return static_cast<Flags>(DrawFrame|BlendIcon);
00136 }
|