| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeViewNode.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright © 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00026 #ifndef  __TERRALIB_INTERNAL_VIEWNODE_H
    00027 #define  __TERRALIB_INTERNAL_VIEWNODE_H
    00028
    00029 #define THEME_GROUP
    00030
    00031 #include "TeDefines.h"
    00032 #include "TeBox.h"
    00033 #include "TeAbstractFactory.h"
    00034
    00035 #include <iostream>
    00036 #include <string>
    00037 #include <vector>
    00038 using namespace std;
    00039
    00040 class TeProjection;
    00041 class TeViewNode;
    00042
    00044 enum TeViewNodeType
    00045 { TeTHEME=0, TeTREE=1, TeEXTERNALTHEME=2, TeFILETHEME=3, TeSFSTHEME=4 };
    00046
    00047
    00049
    00056 class TL_DLL TeViewNodeParams
    00057 {
    00058 public:
    00060            TeViewNodeParams(const string& name="", const int& id=0, const int& viewId=0,
    00061                       const int nodeType=0, const int& priority=0, TeViewNode* parentNode=0,
    00062                       const int parentId=0):
    00063                       name_(name),
    00064                       id_(id),
    00065                       viewId_(viewId),
    00066                       nodeType_(nodeType),
    00067                       priority_(priority),
    00068                       myParent_(parentNode),
    00069                       myParentId_(parentId)
    00070            { }
    00071
    00073            TeViewNodeParams(const TeViewNodeParams& params)
    00074            {
    00075                       name_ = params.name_;
    00076         id_ = params.id_;
    00077                       viewId_ = params.viewId_;
    00078         nodeType_ = params.nodeType_;
    00079                       priority_ = params.priority_;
    00080                       myParent_ = params.myParent_;
    00081                       myParentId_ = params.myParentId_;
    00082            }
    00083
    00084            virtual ~TeViewNodeParams();
    00086            int getProductId() { return nodeType_; }
    00087
    00089            string                           name_;
    00091            int                                         id_;
    00093            int                                         viewId_;
    00095            int                                         nodeType_;
    00097            int                                         priority_;
    00099            TeViewNode*           myParent_;
    00101            int                              myParentId_;
    00102 };
    00103
    00104
    00106
    00113 class TL_DLL TeViewNode
    00114 {
    00115 public:
    00117     TeViewNode(const string& name="", TeViewNode* parent=0, const int& view=0, const int& id=0, const int& nodeType=0):
    00118              viewNodeParams_(name, id, view, nodeType, 0, parent)
    00119            { }
    00120
    00122     TeViewNode(const TeViewNodeParams& viewNodeParams):
    00123              viewNodeParams_(viewNodeParams)
    00124            { }
    00125
    00127            virtual ~TeViewNode()
    00128            {}
    00129
    00131            virtual TeViewNode* clone()
    00132            {
    00133                       return new TeViewNode(viewNodeParams_);
    00134            };
    00135
    00137            virtual void add (TeViewNode*, const bool& /*updatePriority*/ = true) {}
    00138
    00140
    00144            virtual TeViewNode* removeID (int /* id */) { return 0; }
    00145
    00147
    00151            virtual TeViewNode* remove (const string& /*name*/) { return 0; }
    00152
    00154            virtual TeViewNode* retrieve (int)  { return 0; }
    00155
    00157            virtual TeViewNode* parent()
    00158            { return viewNodeParams_.myParent_; }
    00159
    00161            virtual int parentId()
    00162            {
    00163                       if (viewNodeParams_.myParent_)
    00164                                  return viewNodeParams_.myParent_->id();
    00165                       else
    00166                                  return viewNodeParams_.myParentId_;
    00167            }
    00168
    00170            virtual void parentId(int i)
    00171            {
    00172                       if (viewNodeParams_.myParent_)
    00173                                  viewNodeParams_.myParent_->id(i);
    00174                       viewNodeParams_.myParentId_ = i;
    00175            }
    00176
    00178            virtual void setParent ( TeViewNode* node )
    00179            {
    00180                       viewNodeParams_.myParent_ = node;
    00181                       viewNodeParams_.myParentId_ = (viewNodeParams_.myParent_)? viewNodeParams_.myParent_->id():0;
    00182            }
    00183
    00185            virtual int                      id () { return viewNodeParams_.id_; }
    00186
    00188            virtual void          id (int i){ viewNodeParams_.id_ = i; }
    00189
    00191            virtual string        name () { return viewNodeParams_.name_; }
    00193            virtual void          name (const string& s) { viewNodeParams_.name_ = s; }
    00194
    00196            virtual int                      priority() const { return viewNodeParams_.priority_; }
    00198            virtual void          priority(int i) { viewNodeParams_.priority_ = i; }
    00199
    00201            virtual void          view (int viewId) { viewNodeParams_.viewId_ = viewId; }
    00203            virtual int                      view () { return viewNodeParams_.viewId_ ; }
    00204
    00206            virtual int type() { return viewNodeParams_.nodeType_; };
    00208            virtual void type(const int& t) { viewNodeParams_.nodeType_ = t; }
    00209
    00211            virtual void moveUp ()
    00212            {
    00213                       if (viewNodeParams_.myParent_)
    00214                                  viewNodeParams_.myParent_->moveUp (this);
    00215            }
    00216
    00218            virtual void moveDown ()
    00219            {
    00220                       if (viewNodeParams_.myParent_)
    00221                                  viewNodeParams_.myParent_->moveDown (this);
    00222            }
    00223
    00225            virtual void swap ( unsigned int, unsigned int ) {}
    00226
    00228            virtual void visibility ( int ){};
    00229
    00231            virtual int visibility(){ return 1; };
    00232
    00234            virtual void draw() {}
    00235
    00237            virtual void sort() {}
    00238
    00239            static TeViewNode*    DefaultObject()
    00240            {          return 0; }
    00241
    00242            virtual int getProductId() const
    00243            {          return viewNodeParams_.nodeType_; }
    00244
    00245            virtual TeViewNodeParams& viewNodeParams()
    00246            {          return viewNodeParams_; }
    00247
    00248            virtual void viewNodeParams(TeViewNodeParams& p)
    00249            {          viewNodeParams_ = p; }
    00250
    00251
    00252 protected:
    00253
    00254            virtual void          moveUp (TeViewNode*) {}
    00255            virtual void          moveDown (TeViewNode*) {}
    00256
    00258            TeViewNodeParams      viewNodeParams_;
    00259 };
    00260
    00261
    00263
    00270 class TL_DLL TeViewNodeFactory : public TeAbstractFactory<TeViewNode,TeViewNodeParams, int>
    00271 {
    00272 public:
    00274            TeViewNodeFactory(const int& nodeType) :
    00275              TeAbstractFactory<TeViewNode,TeViewNodeParams, int>(nodeType)
    00276            { }
    00277 };
    00278
    00279
    00281 class TL_DLL TeViewTree: public TeViewNode
    00282 {
    00283 public:
    00284
    00286            TeViewTree(const string& name=""): TeViewNode(name, 0, 0, 0, (int)TeTREE)
    00287            { }
    00288
    00290     TeViewTree(const TeViewNodeParams& params):
    00291              TeViewNode(params)
    00292            { }
    00293
    00294
    00296            virtual ~TeViewTree ();
    00297
    00299            virtual void visibility (int vis);
    00300
    00302            virtual int visibility ();
    00303
    00305            virtual void swap (unsigned int i, unsigned int j);
    00306
    00308            virtual void moveUp (TeViewNode* node);
    00309
    00311            virtual void moveDown (TeViewNode* node);
    00312
    00314            virtual void add (TeViewNode* node, const bool& updatePriority = true);
    00315
    00317            virtual TeViewNode* remove (const string& name);
    00318
    00320            virtual TeViewNode* removeID (int id) ;
    00321
    00323            virtual TeViewNode* retrieve (unsigned int i)
    00324            { return nodes_[i]; }
    00325
    00327            virtual void draw ();
    00328
    00330            unsigned int size()
    00331     { return (unsigned int)nodes_.size(); }
    00332
    00334            vector<TeViewNode*>& nodes()
    00335            { return nodes_; }
    00336
    00338            void sort();
    00339
    00341            virtual void clear();
    00342
    00347            virtual int moveTop (TeViewNode* node);
    00348
    00353            int moveBottom(TeViewNode* node);
    00354
    00359            virtual void insertFront(TeViewNode* node);
    00360
    00364            virtual TeViewNode* find (int id);
    00365
    00370            virtual TeViewNode* find( std::string name, bool caseS = false );
    00371
    00375            virtual TeBox box(bool onlyVisible, TeProjection* projection );
    00376
    00380            virtual bool assertsPriorities();
    00381
    00382 private:
    00383            vector<TeViewNode*> nodes_;
    00384 };
    00385
    00386
    00388
    00395 class TL_DLL TeViewTreeFactory : public TeViewNodeFactory
    00396 {
    00397 public:
    00399            TeViewTreeFactory() : TeViewNodeFactory((int)TeTREE)
    00400            {}
    00401
    00403            TeViewTree* build(TeViewNodeParams* params)
    00404            {
    00405                       TeViewNodeParams auxParams = *params;
    00406                       return new TeViewTree(auxParams);
    00407            }
    00408 };
    00409
    00410 #endif
    00411

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines