libyui
3.0.10
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YGraph.h 00020 00021 Author: Arvin Schnell <aschnell@suse.de> 00022 00023 /-*/ 00024 00025 #ifndef YGraph_h 00026 #define YGraph_h 00027 00028 #include "YWidget.h" 00029 00030 /* 00031 * Do not include graphviz/types.h here since it conflicts with ncurses 00032 * headers. People should finally start to use C++ and namespaces! 00033 * 00034 * The previous workaround of inserting the graph_t definition here does not 00035 * work with graphviz >= 2.30.0 since it depends on the define WITH_CGRAPH. 00036 * 00037 * For that reason a lot of functions simply take a void* instead of graph_t*. 00038 */ 00039 00040 class YGraphPrivate; 00041 00042 00043 class YGraph : public YWidget 00044 { 00045 protected: 00046 00047 /** 00048 * Constructor. 00049 * 00050 * Loads a graph in DOT format from filename and uses the layout algorithm 00051 * layoutAlgorithm to layout and then render the graph. The layout 00052 * algorithm can be any string accepted by the function gvLayout from 00053 * graphviz, e.g. "dot" or "neato". 00054 **/ 00055 YGraph( YWidget * parent, const std::string & filename, const std::string & layoutAlgorithm ); 00056 00057 /** 00058 * Constructor. 00059 * 00060 * Renders the graph. The graph must already contain layout information. 00061 **/ 00062 YGraph( YWidget * parent, /* graph_t */ void * graph ); 00063 00064 public: 00065 00066 /** 00067 * Destructor. 00068 **/ 00069 virtual ~YGraph(); 00070 00071 /** 00072 * Returns a descriptive name of this widget class for logging, 00073 * debugging etc. 00074 **/ 00075 virtual const char * widgetClass() const { return "YGraph"; } 00076 00077 /** 00078 * Set a property. 00079 * Reimplemented from YWidget. 00080 * 00081 * This function may throw YUIPropertyExceptions. 00082 * 00083 * This function returns 'true' if the value was successfully set and 00084 * 'false' if that value requires special handling (not in error cases: 00085 * those are covered by exceptions). 00086 **/ 00087 virtual bool setProperty( const std::string & propertyName, 00088 const YPropertyValue & val ); 00089 00090 /** 00091 * Get a property. 00092 * Reimplemented from YWidget. 00093 * 00094 * This method may throw YUIPropertyExceptions. 00095 **/ 00096 virtual YPropertyValue getProperty( const std::string & propertyName ); 00097 00098 /** 00099 * Return this class's property set. 00100 * This also initializes the property upon the first call. 00101 * 00102 * Reimplemented from YWidget. 00103 **/ 00104 virtual const YPropertySet & propertySet(); 00105 00106 /** 00107 * Return the filename that describes the graph. 00108 **/ 00109 std::string filename() const; 00110 00111 /** 00112 * Set the filename that describes the graph and render the graph. 00113 * Derived classes can reimplent this, but they should call this base 00114 * class method in the new implementation. Most derived classes only need 00115 * to implement renderGraph(). 00116 **/ 00117 virtual void setFilename( const std::string & filename ); 00118 00119 /** 00120 * Return the layout-algorithm used for the graph. 00121 **/ 00122 std::string layoutAlgorithm() const; 00123 00124 /** 00125 * Set the layout-algorithm used for the graph. Derived classes can 00126 * reimplent this, but they should call this base class method in the new 00127 * implementation. 00128 **/ 00129 virtual void setLayoutAlgorithm( const std::string & filename ); 00130 00131 /** 00132 * Render the graph. Derived classes can reimplent this, but they should 00133 * call this base class method in the new implementation. Most derived 00134 * classes only need to implement renderGraph(). 00135 **/ 00136 virtual void setGraph( /* graph_t */ void * graph ); 00137 00138 /** 00139 * Return name of activated node. Activation can happen due to e.g. single 00140 * right mouse click (context menu) or double left mouse click. 00141 */ 00142 virtual std::string activatedNode() const; 00143 00144 protected: 00145 00146 /** 00147 * Render the graph from the filename. Derived classes are required to 00148 * implement this. 00149 **/ 00150 virtual void renderGraph( const std::string & filename, const std::string & layoutAlgorithm ) = 0; 00151 00152 /** 00153 * Render the graph. Derived classes are required to implement this. 00154 **/ 00155 virtual void renderGraph( /* graph_t */ void * graph ) = 0; 00156 00157 private: 00158 00159 ImplPtr<YGraphPrivate> priv; 00160 00161 }; 00162 00163 00164 #endif // YGraph_h