BVB Source Codes

Gource Show dirnode.h Source code

Return Download Gource: download dirnode.h Source code - Download Gource Source code - Type:.h
  1. /*
  2.     Copyright (C) 2009 Andrew Caudwell (acaudwell@gmail.com)
  3.  
  4.     This program is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU General Public License
  6.     as published by the Free Software Foundation; either version
  7.     3 of the License, or (at your option) any later version.
  8.  
  9.     This program is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.     GNU General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU General Public License
  15.     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16. */
  17.  
  18. #ifndef RDIRNODE_H
  19. #define RDIRNODE_H
  20.  
  21. #include "core/sdlapp.h"
  22. #include "core/bounds.h"
  23. #include "core/quadtree.h"
  24. #include "core/pi.h"
  25. #include "core/vbo.h"
  26.  
  27. #include "gource_settings.h"
  28.  
  29. #include "spline.h"
  30. #include "file.h"
  31. #include "bloom.h"
  32.  
  33. #include <list>
  34. #include <set>
  35.  
  36. class RFile;
  37.  
  38. class RDirNode : public QuadItem {
  39.     std::string abspath;
  40.  
  41.     std::string path_token;
  42.     int         path_token_offset;
  43.  
  44.     RDirNode* parent;
  45.     std::list<RDirNode*> children;
  46.     std::list<RFile*> files;
  47.  
  48.     SplineEdge spline;
  49.  
  50.     vec4 col;
  51.  
  52.     vec2 spos;
  53.  
  54.     vec2 projected_pos;
  55.     vec2 projected_spos;
  56.  
  57.     vec2 pos;
  58.     vec2 vel;
  59.     vec2 accel, prev_accel;
  60.  
  61.     float dir_area;
  62.  
  63.     bool visible;
  64.     bool in_frustum;
  65.     bool position_initialized;
  66.  
  67.     float since_node_visible;
  68.     float since_last_file_change;
  69.     float since_last_node_change;
  70.  
  71.     float file_area;
  72.     float dir_radius;
  73.     float dir_radius_sqrt;
  74.     float parent_radius;
  75.  
  76.     int depth;
  77.  
  78.     int visible_count;
  79.  
  80.     vec3 screenpos;
  81.     vec2 node_normal;
  82.  
  83.     void calcRadius();
  84.     void calcColour();
  85.  
  86.     std::string commonPathPrefix(const std::string& str) const;
  87.  
  88.     void changePath(const std::string & abspath);
  89.  
  90.     void setInitialPosition();
  91.  
  92.     void drawEdge(RDirNode* child) const;
  93.     void updateSplinePoint(float dt);
  94.     void move(float dt);
  95.  
  96.     vec2 calcFileDest(int layer_no, int file_no);
  97.     void updateFilePositions();
  98.  
  99.     void adjustDepth();
  100.     void adjustPath();
  101.     void drawDirName(FXFont& dirfont) const;
  102. public:
  103.     RDirNode(RDirNode* parent, const std::string & abspath);
  104.     ~RDirNode();
  105.  
  106.     void printFiles();
  107.  
  108.     bool empty() const;
  109.  
  110.     bool isAnchor(RDirNode* node) const;
  111.  
  112.     RDirNode* getRoot();
  113.  
  114.     void fileUpdated(bool userInitiated);
  115.     void nodeUpdated(bool userInitiated);
  116.  
  117.     void addVisible();
  118.     bool isVisible();
  119.  
  120.     float getArea() const;
  121.  
  122.     int totalDirCount() const;
  123.     int totalFileCount() const;
  124.  
  125.     int getTokenOffset() const;
  126.  
  127.     int dirCount() const;
  128.     int fileCount() const;
  129.     int visibleFileCount() const;
  130.     bool noDirs() const;
  131.     bool noFiles() const;
  132.  
  133.     bool prefixedBy(const std::string & path) const;
  134.  
  135.     const std::string & getPath() const;
  136.  
  137.     const vec2 & getNodeNormal() const;
  138.  
  139.     bool isParent(RDirNode* node) const;
  140.  
  141.     bool addFile(RFile* f);
  142.     bool removeFile(RFile* f);
  143.  
  144.     int getDepth() const;
  145.  
  146.     const std::list<RDirNode*> & getChildren() const;
  147.  
  148.     void updateQuadItemBounds();
  149.  
  150.     float getParentRadius() const;
  151.     float getRadius() const;
  152.     float getRadiusSqrt() const;
  153.  
  154.     const std::list<RFile*>* getFiles() const { return &files; };
  155.     void getFilesRecursive(std::list<RFile*>& files) const;
  156.  
  157.     vec3 averageFileColour() const;
  158.  
  159.     const vec4 & getColour() const;
  160.  
  161.     RDirNode* getParent() const;
  162.  
  163.     bool isDir(const std::string& path) const;
  164.     void findDirs(const std::string& path, std::list<RDirNode*>& dirs);
  165.  
  166.     const vec2 & getPos() const;
  167.  
  168.     void calcEdges();
  169.  
  170.     const vec2 & getProjectedPos() const;
  171.     const vec2 & getSPos() const;
  172.  
  173.     void setPos(const vec2 & pos);
  174.  
  175.     void rotate(float s, float c);
  176.  
  177.     void setParent(RDirNode* parent);
  178.  
  179.     float distanceToParent() const;
  180.  
  181.     void addNode(RDirNode* node);
  182.  
  183.     void debug(int indent=0) const;
  184.  
  185.     void applyForceDir(RDirNode* dir);
  186.     void applyForces(QuadTree &quadtree);
  187.  
  188.     void logic(float dt);
  189.  
  190.     void updateEdgeVBO(quadbuf& buffer) const;
  191.    
  192.     void drawEdges() const;
  193.     void drawEdgeShadows() const;
  194.  
  195.     void checkFrustum(const Frustum & frustum);
  196.  
  197.     void updateFilesVBO(quadbuf& buffer, float dt) const;
  198.     void updateBloomVBO(bloombuf& buffer, float dt);
  199.  
  200.     void drawShadows(float dt) const;
  201.     void drawFiles(float dt) const;
  202.     void drawBloom(float dt);
  203.  
  204.     void drawNames(FXFont& dirfont);
  205.  
  206.     void calcScreenPos(GLint* viewport, GLdouble* modelview, GLdouble* projection);
  207.  
  208.     void nodeCount() const;
  209. };
  210.  
  211. class DirForceFunctor : public VisitFunctor<QuadItem>{
  212.   private:
  213.     RDirNode * this_dir;
  214.     std::set<RDirNode*> seen;
  215.     size_t loopCount;
  216.  
  217.   public:
  218.     DirForceFunctor(RDirNode * dir) : this_dir(dir), seen(), loopCount(0){}
  219.     int getLoopCount() const{ return loopCount; }
  220.     void operator()(QuadItem * item){
  221.  
  222.         std::set<RDirNode*>::iterator seentest;
  223.         RDirNode* d = (RDirNode*) (item);
  224.  
  225.         if(d==this_dir) return;
  226.         if(d==this_dir->getParent()) return;
  227.         if(d->getParent() == this_dir) return;
  228.         if(this_dir->isParent(d)) return;
  229.         if(d->isParent(this_dir)) return;
  230.  
  231.         if(d->node_count != 1) {
  232.             if((seentest = seen.find(d)) != seen.end())
  233.                 return;
  234.  
  235.             seen.insert(d);
  236.         }
  237.  
  238.         this_dir->applyForceDir(d);
  239.  
  240.         loopCount++;
  241.  
  242.     }
  243.  
  244. };
  245.  
  246. extern int gGourceDirNodeInnerLoops;
  247. extern int gGourceFileInnerLoops;
  248.  
  249. extern float gGourcePointSize;
  250. extern bool  gGourceNodeDebug;
  251. extern bool  gGourceGravity;
  252. extern float gGourceForceGravity;
  253.  
  254. extern std::map<std::string, RDirNode*> gGourceDirMap;
  255.  
  256. #endif
  257.  
downloaddirnode.h Source code - Download Gource Source code
Related Source Codes/Software:
FDFullscreenPopGesture - A UINavigationController's category to enable full... 2017-01-10
node-style-guide - A guide for styling your node.js / JavaScript code... 2017-01-09
ImageOptim - GUI image optimizer for Mac htt... 2017-01-09
falcon - Falcon is a low-level, high-performance Python fra... 2017-01-09
prerender - Node server that uses phantomjs to render a javasc... 2017-01-09
che - Eclipse Che: Next-generation Eclipse IDE. Open sou... 2017-01-10
notepad-plus-plus - Notepad++ official repository h... 2017-01-10
waterline - An adapter-based ORM for Node.js with support for ... 2017-01-10
Workerman - An asynchronous event driven PHP framework for eas... 2017-01-10
structor - An advanced visual editor for React components ... 2017-01-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top