]> granicus.if.org Git - graphviz/commitdiff
within an edge, render first connectable geom as a connector and others as outer...
authorglenlow <devnull@localhost>
Tue, 7 Apr 2009 03:32:38 +0000 (03:32 +0000)
committerglenlow <devnull@localhost>
Tue, 7 Apr 2009 03:32:38 +0000 (03:32 +0000)
plugin/visio/VisioGraphic.cpp
plugin/visio/VisioGraphic.h
plugin/visio/VisioRender.cpp

index ff3a193aade22ae5b07b5d1d5254132d73b7fbfd..d55c4a88611ef5f35cd9495d96fe9da153841fe9 100644 (file)
@@ -112,6 +112,12 @@ namespace Visio
                return center;
        }
        
+       bool Ellipse::IsConnectable() const
+       {
+               /* cannot be a connector */
+               return false;
+       }
+       
        Path::Path(pointf* points, int pointCount)
        {
                /* copy over the points */
@@ -165,7 +171,6 @@ namespace Visio
                return _points[_pointCount - 1];
        }
        
-       
        Bezier::Bezier(pointf* points, int pointCount, bool filled):
                Path(points, pointCount),
                _filled(filled)
@@ -192,6 +197,12 @@ namespace Visio
                        /* just return the middle point */
                        return _points[_pointCount / 2];
        }
+
+       bool Bezier::IsConnectable() const
+       {
+               /* can be a connector */
+               return true;
+       }
        
        void Bezier::Print(GVJ_t* job, pointf first, pointf last) const
        {
@@ -265,6 +276,12 @@ namespace Visio
                return center;
        }
        
+       bool Polygon::IsConnectable() const
+       {
+               /* cannot be a connector */
+               return false;
+       }
+
        void Polygon::Print(GVJ_t* job, pointf first, pointf last) const
        {
                gvputs(job, "<Geom>\n");
@@ -333,6 +350,12 @@ namespace Visio
                        return _points[_pointCount / 2];
        }
        
+       bool Polyline::IsConnectable() const
+       {
+               /* cannot be a connector */
+               return false;
+       }
+       
        void Polyline::Print(GVJ_t* job, pointf first, pointf last) const
        {
                gvputs(job, "<Geom>\n");
@@ -537,6 +560,11 @@ namespace Visio
                return _geom->GetCenter();
        }
        
+       bool Graphic::IsConnectable() const
+       {
+               return _geom->IsConnectable();
+       }
+       
        void Graphic::Print(GVJ_t* job, pointf first, pointf last) const
        {
                if (_line)
index d8512c6e71fc34b498a55fd04b295a603e3636ca..167e5a14f57acaa2a6925ab1b744c69d37ddd332 100644 (file)
@@ -67,6 +67,7 @@ namespace Visio
                virtual pointf GetFirst() const = 0;    /* first point -- used by edge logic */
                virtual pointf GetLast() const = 0;             /* last point -- used by edge logic */
                virtual pointf GetCenter() const = 0;   /* midpoint of the path -- used by text logic */
+               virtual bool IsConnectable() const = 0; /* whether this geom can be turned into a connector -- used by edge logic */
                
                /* given first (lower left) and last points (upper right), output the geometry */ 
                virtual void Print(GVJ_t* job, pointf first, pointf last) const = 0;
@@ -76,13 +77,15 @@ namespace Visio
        {
        public:
                Ellipse(pointf* points, bool filled);
-               void Print(GVJ_t* job, pointf first, pointf last) const;
                
-               boxf GetBounds() const;
-               pointf GetFirst() const;
-               pointf GetLast() const;
-               pointf GetCenter() const;
-       
+               virtual boxf GetBounds() const;
+               virtual pointf GetFirst() const;
+               virtual pointf GetLast() const;
+               virtual pointf GetCenter() const;
+               virtual bool IsConnectable() const;
+
+               void Print(GVJ_t* job, pointf first, pointf last) const;
+
        private:
                bool _filled;
                pointf _points[2];
@@ -94,9 +97,9 @@ namespace Visio
                Path(pointf* points, int pointCount);
                ~Path();
                
-               boxf GetBounds() const;
-               pointf GetFirst() const;
-               pointf GetLast() const;
+               virtual boxf GetBounds() const;
+               virtual pointf GetFirst() const;
+               virtual pointf GetLast() const;
                
        protected:
                pointf* _points;
@@ -108,10 +111,12 @@ namespace Visio
        public:
                Bezier(pointf* points, int pointCount, bool filled);
                
-               pointf GetCenter() const;
-               
-               void Print(GVJ_t* job, pointf first, pointf last) const;
+               virtual pointf GetCenter() const;
+               virtual bool IsConnectable() const;
+
+               virtual void Print(GVJ_t* job, pointf first, pointf last) const;
                
+
        private:
                bool _filled;
        };
@@ -121,10 +126,11 @@ namespace Visio
        public:
                Polygon(pointf* points, int pointCount, bool filled);
                
-               pointf GetCenter() const;
-
-               void Print(GVJ_t* job, pointf first, pointf last) const;
+               virtual pointf GetCenter() const;
+               virtual bool IsConnectable() const;
                
+               virtual void Print(GVJ_t* job, pointf first, pointf last) const;
+
        private:
                bool _filled;
        };
@@ -134,9 +140,11 @@ namespace Visio
        public:
                Polyline(pointf* points, int pointCount);
                
-               pointf GetCenter() const;
+               virtual pointf GetCenter() const;
+               virtual bool IsConnectable() const;
 
                void Print(GVJ_t* job, pointf first, pointf last) const;
+
        };
        
        /* Line, Fill and Geom details for each Graphviz graphic */
@@ -155,6 +163,7 @@ namespace Visio
                pointf GetFirst() const;
                pointf GetLast() const;
                pointf GetCenter() const;
+               bool IsConnectable() const;
 
                void Print(GVJ_t* job, pointf first, pointf last) const;
                
index 8a0874c375d58d2f8a63d976efacc92dde3ef1d9..7e490147f7d0d3dc516ff2b9eb11b94a0283aaf6 100644 (file)
@@ -161,8 +161,17 @@ namespace Visio
                        NodeIds::const_iterator beginId = _nodeIds.find(job->obj->u.e->tail);
                        NodeIds::const_iterator endId = _nodeIds.find(job->obj->u.e->head);
                        
-                       /* output first shape as an edge shape */
-                       PrintEdgeShape(job, _graphics[0], beginId == _nodeIds.end() ? 0 : beginId->second, endId == _nodeIds.end() ? 0 : endId->second);
+                       /* output first connectable shape as an edge shape, all else as regular outer shapes */
+                       bool firstConnector = true;
+                       for (Graphics::const_iterator nextGraphic = _graphics.begin(), lastGraphic = _graphics.end(); nextGraphic != lastGraphic; ++nextGraphic)
+                               if (firstConnector && (*nextGraphic)->IsConnectable())
+                               {
+                                       PrintEdgeShape(job, _graphics[0], beginId == _nodeIds.end() ? 0 : beginId->second, endId == _nodeIds.end() ? 0 : endId->second);
+                                       firstConnector = false;
+                               }
+                               else
+                                       PrintOuterShape(job, *nextGraphic);
+
                }
                ClearGraphicsAndTexts();
        }