Author: aschnell Date: Thu Jan 15 14:22:47 2009 New Revision: 54643 URL: http://svn.opensuse.org/viewcvs/yast?rev=54643&view=rev Log: - backup Modified: branches/tmp/aschnell/graph/libyui/src/YGraph.cc branches/tmp/aschnell/graph/libyui/src/YGraph.h branches/tmp/aschnell/graph/libyui/src/YOptionalWidgetFactory.cc branches/tmp/aschnell/graph/libyui/src/YOptionalWidgetFactory.h branches/tmp/aschnell/graph/qt-graph/src/YQGraph.cc branches/tmp/aschnell/graph/qt-graph/src/YQGraph.h branches/tmp/aschnell/graph/qt-graph/src/YQGraphPluginImpl.cc branches/tmp/aschnell/graph/qt-graph/src/YQGraphPluginImpl.h branches/tmp/aschnell/graph/qt/src/YQGraphPluginIf.h branches/tmp/aschnell/graph/qt/src/YQGraphPluginStub.cc branches/tmp/aschnell/graph/qt/src/YQGraphPluginStub.h branches/tmp/aschnell/graph/qt/src/YQOptionalWidgetFactory.cc branches/tmp/aschnell/graph/qt/src/YQOptionalWidgetFactory.h Modified: branches/tmp/aschnell/graph/libyui/src/YGraph.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/libyui/src/... ============================================================================== --- branches/tmp/aschnell/graph/libyui/src/YGraph.cc (original) +++ branches/tmp/aschnell/graph/libyui/src/YGraph.cc Thu Jan 15 14:22:47 2009 @@ -44,6 +44,15 @@ } +YGraph::YGraph( YWidget * parent, graph_t * graph ) + : YWidget( parent ) + , priv( new YGraphPrivate( "", "" ) ) +{ + setDefaultStretchable( YD_HORIZ, true ); + setDefaultStretchable( YD_VERT, true ); +} + + YGraph::~YGraph() { // NOP @@ -61,7 +70,14 @@ YGraph::setFilename( const string & filename ) { priv->filename = filename; - rebuildGraph(); + renderGraph( filename ); +} + + +void +YGraph::setGraph( graph_t * graph ) +{ + renderGraph( graph ); } Modified: branches/tmp/aschnell/graph/libyui/src/YGraph.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/libyui/src/... ============================================================================== --- branches/tmp/aschnell/graph/libyui/src/YGraph.h (original) +++ branches/tmp/aschnell/graph/libyui/src/YGraph.h Thu Jan 15 14:22:47 2009 @@ -21,6 +21,12 @@ #include "YWidget.h" +extern "C" +{ + struct Agraph_t; + typedef struct Agraph_t graph_t; +} + class YGraphPrivate; @@ -33,6 +39,11 @@ **/ YGraph( YWidget * parent, const string & filename, const string & layoutAlgorithm ); + /** + * Constructor. + **/ + YGraph( YWidget * parent, graph_t * graph ); + public: /** @@ -88,6 +99,9 @@ **/ virtual void setFilename( const string & filename ); + + virtual void setGraph( graph_t * graph ); + /** * Alias for filename() **/ @@ -116,7 +130,9 @@ * Build the graph from the internally stored filename. * Derived classes are required to implement this. **/ - virtual void rebuildGraph() = 0; + virtual void renderGraph( const string & filename ) = 0; + + virtual void renderGraph( graph_t * graph ) = 0; private: Modified: branches/tmp/aschnell/graph/libyui/src/YOptionalWidgetFactory.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/libyui/src/... ============================================================================== --- branches/tmp/aschnell/graph/libyui/src/YOptionalWidgetFactory.cc (original) +++ branches/tmp/aschnell/graph/libyui/src/YOptionalWidgetFactory.cc Thu Jan 15 14:22:47 2009 @@ -255,3 +255,10 @@ { THROW_UNSUPPORTED( "YGraph" ); } + + +YGraph * +YOptionalWidgetFactory::createGraph( YWidget * parent, graph_t * graph ) +{ + THROW_UNSUPPORTED( "YGraph" ); +} Modified: branches/tmp/aschnell/graph/libyui/src/YOptionalWidgetFactory.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/libyui/src/... ============================================================================== --- branches/tmp/aschnell/graph/libyui/src/YOptionalWidgetFactory.h (original) +++ branches/tmp/aschnell/graph/libyui/src/YOptionalWidgetFactory.h Thu Jan 15 14:22:47 2009 @@ -43,6 +43,12 @@ class YTimezoneSelector; class YGraph; +extern "C" +{ + struct Agraph_t; + typedef struct Agraph_t graph_t; +} + /** * Abstract widget factory for optional ("special") widgets. * @@ -126,6 +132,7 @@ virtual bool hasGraph(); virtual YGraph * createGraph( YWidget * parent, const string & filename, const string & layoutAlgorithm ); + virtual YGraph * createGraph( YWidget * parent, graph_t * graph ); protected: Modified: branches/tmp/aschnell/graph/qt-graph/src/YQGraph.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/qt-graph/sr... ============================================================================== --- branches/tmp/aschnell/graph/qt-graph/src/YQGraph.cc (original) +++ branches/tmp/aschnell/graph/qt-graph/src/YQGraph.cc Thu Jan 15 14:22:47 2009 @@ -21,26 +21,6 @@ #include <math.h> -#include <fstream> -#include <boost/bind.hpp> - -#include <QHBoxLayout> -#include <QVBoxLayout> -#include <QAction> -#include <QShortcut> -#include <QApplication> -#include <QCheckBox> -#include <QDialog> -#include <QFileDialog> -#include <QLabel> -#include <QMap> -#include <QMenuBar> -#include <QMessageBox> -#include <QPushButton> -#include <QSplitter> -#include <QTabWidget> -#include <QTimer> -#include <QMenu> #include <QGraphicsScene> #include <QGraphicsPathItem> #include <QKeyEvent> @@ -71,8 +51,30 @@ setResizeAnchor(AnchorUnderMouse); setDragMode(ScrollHandDrag); - QGraphicsScene* scene = new QGraphicsScene(this); - populateScene(scene); + scene = new QGraphicsScene(this); + scene->setItemIndexMethod(QGraphicsScene::BspTreeIndex); + renderGraph(filename); + setScene(scene); + + yuiMilestone() << "Graph init done" << endl; +} + + +YQGraph::YQGraph( YWidget * parent, graph_t* graph ) + : QGraphicsView( (QWidget *) parent->widgetRep() ), + YGraph( parent, graph ) +{ + setWidgetRep( this ); + + setRenderHint(QPainter::Antialiasing); + setRenderHint(QPainter::TextAntialiasing); + setTransformationAnchor(AnchorUnderMouse); + setResizeAnchor(AnchorUnderMouse); + setDragMode(ScrollHandDrag); + + scene = new QGraphicsScene(this); + scene->setItemIndexMethod(QGraphicsScene::BspTreeIndex); + renderGraph(graph); setScene(scene); yuiMilestone() << "Graph init done" << endl; @@ -183,26 +185,31 @@ void -YQGraph::rebuildGraph() +YQGraph::renderGraph(const string & filename) { -} + GVC_t* gvc = gvContext(); + FILE* fp = fopen(filename.c_str(), "r"); + graph_t* graph = agread(fp); -void -YQGraph::populateScene(QGraphicsScene* scene) -{ - GVC_t* gvc = gvContext(); + gvLayout(gvc, graph, "dot"); - FILE* fp = fopen(filename().c_str(), "r"); - graph_t* g = agread(fp); + renderGraph(graph); - gvLayout(gvc, g, "dot"); + gvFreeLayout(gvc, graph); + agclose(graph); + gvFreeContext(gvc); +} + +void +YQGraph::renderGraph(graph_t* graph) +{ const int border = 20; - QRectF size(gToQ(GD_bb(g).LL), gToQ(GD_bb(g).UR)); + QRectF size(gToQ(GD_bb(graph).LL), gToQ(GD_bb(graph).UR)); size.adjust(-border, -border, border, border); - scene->setItemIndexMethod(QGraphicsScene::BspTreeIndex); + scene->setSceneRect(size); @@ -213,7 +220,7 @@ pen2.setWidthF(1); - for (Agnode_t* node = agfstnode(g); node != NULL; node = agnxtnode(g, node)) + for (Agnode_t* node = agfstnode(graph); node != NULL; node = agnxtnode(graph, node)) { qreal w = 72*ND_width(node); qreal h = 72*ND_height(node); @@ -247,7 +254,7 @@ QGraphicsSimpleTextItem* text = new QGraphicsSimpleTextItem(ND_label(node)->text, item); text->translate(x, y); // ??? - for (Agedge_t* edge = agfstedge(g, node); edge != NULL; edge = agnxtedge(g, edge, node)) + for (Agedge_t* edge = agfstedge(graph, node); edge != NULL; edge = agnxtedge(graph, edge, node)) { const splines* spl = ED_spl(edge); @@ -274,11 +281,6 @@ } } } - - - gvFreeLayout(gvc, g); - agclose(g); - gvFreeContext(gvc); } Modified: branches/tmp/aschnell/graph/qt-graph/src/YQGraph.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/qt-graph/sr... ============================================================================== --- branches/tmp/aschnell/graph/qt-graph/src/YQGraph.h (original) +++ branches/tmp/aschnell/graph/qt-graph/src/YQGraph.h Thu Jan 15 14:22:47 2009 @@ -43,7 +43,9 @@ public: - YQGraph( YWidget * parent, const string & filename, const string & layoutAlgorithm ); + YQGraph(YWidget * parent, const string & filename, const string & layoutAlgorithm); + + YQGraph(YWidget * parent, graph_t* graph); /** * Preferred width of the widget. @@ -66,7 +68,8 @@ **/ virtual void setSize( int newWidth, int newHeight ); - void rebuildGraph(); + void renderGraph(const string& filename); + void renderGraph(graph_t* graph); protected: @@ -78,8 +81,8 @@ private: - void populateScene(QGraphicsScene* scene); - + QGraphicsScene* scene; + void arrow(QPainterPath& path, const QLineF& line, const QString& type); }; Modified: branches/tmp/aschnell/graph/qt-graph/src/YQGraphPluginImpl.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/qt-graph/sr... ============================================================================== --- branches/tmp/aschnell/graph/qt-graph/src/YQGraphPluginImpl.cc (original) +++ branches/tmp/aschnell/graph/qt-graph/src/YQGraphPluginImpl.cc Thu Jan 15 14:22:47 2009 @@ -43,9 +43,22 @@ /* if ( error() ) return 0; */ - YQGraph * graph = new YQGraph( parent, filename, layoutAlgorithm ); + YQGraph * yqgraph = new YQGraph( parent, filename, layoutAlgorithm ); - YUI_CHECK_NEW( graph ); + YUI_CHECK_NEW( yqgraph ); - return graph; + return yqgraph; +} + + +YGraph * YQGraphPluginImpl::createGraph( YWidget * parent, graph_t * graph ) +{ + /* if ( error() ) + return 0; */ + + YQGraph * yqgraph = new YQGraph( parent, graph ); + + YUI_CHECK_NEW( yqgraph ); + + return yqgraph; } Modified: branches/tmp/aschnell/graph/qt-graph/src/YQGraphPluginImpl.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/qt-graph/sr... ============================================================================== --- branches/tmp/aschnell/graph/qt-graph/src/YQGraphPluginImpl.h (original) +++ branches/tmp/aschnell/graph/qt-graph/src/YQGraphPluginImpl.h Thu Jan 15 14:22:47 2009 @@ -30,6 +30,8 @@ virtual YGraph * createGraph( YWidget * parent, const string & filename, const string & layoutAlgorithm ); + + virtual YGraph * createGraph( YWidget * parent, graph_t * graph ); }; Modified: branches/tmp/aschnell/graph/qt/src/YQGraphPluginIf.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/qt/src/YQGr... ============================================================================== --- branches/tmp/aschnell/graph/qt/src/YQGraphPluginIf.h (original) +++ branches/tmp/aschnell/graph/qt/src/YQGraphPluginIf.h Thu Jan 15 14:22:47 2009 @@ -23,6 +23,14 @@ #include <YEvent.h> #include <YGraphPlugin.h> + +extern "C" +{ + struct Agraph_t; + typedef struct Agraph_t graph_t; +} + + class YQGraphPluginIf { @@ -33,6 +41,8 @@ virtual YGraph *createGraph( YWidget *parent, const string & filename, const string & layoutAlgorithm ) = 0; + virtual YGraph *createGraph( YWidget *parent, graph_t * graph ) = 0; + }; #endif Modified: branches/tmp/aschnell/graph/qt/src/YQGraphPluginStub.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/qt/src/YQGr... ============================================================================== --- branches/tmp/aschnell/graph/qt/src/YQGraphPluginStub.cc (original) +++ branches/tmp/aschnell/graph/qt/src/YQGraphPluginStub.cc Thu Jan 15 14:22:47 2009 @@ -57,3 +57,13 @@ return impl->createGraph( parent, filename, layoutAlgorithm ); } + + +YGraph * +YQGraphPluginStub::createGraph( YWidget * parent, graph_t * graph ) +{ + if ( ! impl ) + YUI_THROW( YUIPluginException( PLUGIN_BASE_NAME ) ); + + return impl->createGraph( parent, graph ); +} Modified: branches/tmp/aschnell/graph/qt/src/YQGraphPluginStub.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/qt/src/YQGr... ============================================================================== --- branches/tmp/aschnell/graph/qt/src/YQGraphPluginStub.h (original) +++ branches/tmp/aschnell/graph/qt/src/YQGraphPluginStub.h Thu Jan 15 14:22:47 2009 @@ -55,6 +55,8 @@ virtual YGraph * createGraph( YWidget * parent, const string & filename, const string & layoutAlgorithm ); + virtual YGraph * createGraph( YWidget * parent, graph_t * graph ); + YQGraphPluginIf * impl ; }; Modified: branches/tmp/aschnell/graph/qt/src/YQOptionalWidgetFactory.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/qt/src/YQOp... ============================================================================== --- branches/tmp/aschnell/graph/qt/src/YQOptionalWidgetFactory.cc (original) +++ branches/tmp/aschnell/graph/qt/src/YQOptionalWidgetFactory.cc Thu Jan 15 14:22:47 2009 @@ -273,6 +273,18 @@ } +YGraph * +YQOptionalWidgetFactory::createGraph( YWidget * parent, graph_t * graph ) +{ + YQGraphPluginStub * plugin = YQApplication::graphPlugin(); + + if ( plugin ) + return plugin->createGraph( parent, graph ); + else + return 0; +} + + YWidget * YQOptionalWidgetFactory::createPatternSelector(YWidget* parent, long modeFlags) { Modified: branches/tmp/aschnell/graph/qt/src/YQOptionalWidgetFactory.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/qt/src/YQOp... ============================================================================== --- branches/tmp/aschnell/graph/qt/src/YQOptionalWidgetFactory.h (original) +++ branches/tmp/aschnell/graph/qt/src/YQOptionalWidgetFactory.h Thu Jan 15 14:22:47 2009 @@ -116,6 +116,7 @@ virtual bool hasGraph(); virtual YGraph * createGraph( YWidget * parent, const string & filename, const string & layoutAlgorithm ); + virtual YGraph * createGraph( YWidget * parent, graph_t * graph ); protected: -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org