Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

View Class Reference

#include <celestiacore.h>

Collaboration diagram for View:

Collaboration graph
List of all members.

Public Types

enum  Type { ViewWindow = 1, HorizontalSplit = 2, VerticalSplit = 3 }

Public Member Functions

void mapWindowToView (float, float, float &, float &) const
 View (Type, Observer *, float, float, float, float)
void walkTreeResize (View *, int)
bool walkTreeResizeDelta (View *, float, bool)

Public Attributes

float alternateZoom
Viewchild1
Viewchild2
float height
int labelMode
Observerobserver
Viewparent
int renderFlags
Type type
float width
float x
float y
float zoom

Member Enumeration Documentation

enum View::Type
 

Enumeration values:
ViewWindow 
HorizontalSplit 
VerticalSplit 

Definition at line 52 of file celestiacore.h.

00052               {
00053         ViewWindow      = 1,
00054         HorizontalSplit = 2,
00055         VerticalSplit   = 3
00056     };


Constructor & Destructor Documentation

View::View Type  ,
Observer ,
float  ,
float  ,
float  ,
float 
 

Definition at line 151 of file celestiacore.cpp.

00154                                         :
00155     type(_type),
00156     observer(_observer),
00157     parent(0),
00158     child1(0),
00159     child2(0),
00160     x(_x),
00161     y(_y),
00162     width(_width),
00163     height(_height),
00164     renderFlags(0),
00165     labelMode(0),
00166     zoom(1),
00167     alternateZoom(1)
00168 {
00169 }


Member Function Documentation

void View::mapWindowToView float  ,
float  ,
float &  ,
float & 
const
 

Definition at line 171 of file celestiacore.cpp.

References height, width, x, and y.

Referenced by CelestiaCore::mouseButtonUp().

00172 {
00173     vx = (wx - x) / width;
00174     vy = (wy + (y + height - 1)) / height;
00175     vx = (vx - 0.5f) * (width / height);
00176     vy = 0.5f - vy;
00177 }

void View::walkTreeResize View ,
int 
 

Definition at line 179 of file celestiacore.cpp.

References height, HorizontalSplit, parent, sign(), type, VerticalSplit, ViewWindow, width, x, and y.

Referenced by CelestiaCore::deleteView().

00179                                                  {
00180    float ratio;
00181    switch (parent->type)
00182     {
00183     case View::HorizontalSplit:
00184         ratio = parent->height / (parent->height -  height);
00185         sibling->height *= ratio;
00186         if (sign == 1)
00187         {
00188             sibling->y = parent->y + (sibling->y - parent->y) * ratio;
00189         }
00190         else
00191         {
00192             sibling->y = parent->y + (sibling->y - (y + height)) * ratio;
00193         }
00194         break;
00195 
00196     case View::VerticalSplit:
00197         ratio = parent->width / (parent->width - width);
00198         sibling->width *= ratio;
00199         if (sign == 1)
00200         {
00201             sibling->x = parent->x + (sibling->x - parent->x) * ratio;
00202         }
00203         else
00204         {
00205             sibling->x = parent->x + (sibling->x - (x + width) ) * ratio;
00206         }
00207         break;
00208     case View::ViewWindow:
00209         break;
00210     }
00211     if (sibling->child1) walkTreeResize(sibling->child1, sign);
00212     if (sibling->child2) walkTreeResize(sibling->child2, sign);
00213 }

bool View::walkTreeResizeDelta View ,
float  ,
bool 
 

Definition at line 215 of file celestiacore.cpp.

References child1, child2, height, HorizontalSplit, parent, sign(), type, VerticalSplit, ViewWindow, width, x, and y.

Referenced by CelestiaCore::mouseMove().

00216 {
00217    View *p=v;
00218    int sign = -1;
00219    float ratio;
00220    double newSize;
00221 
00222    if (v->child1)
00223    {
00224        if (!walkTreeResizeDelta(v->child1, delta, check))
00225            return false;
00226    }
00227 
00228    if (v->child2)
00229    {
00230        if (!walkTreeResizeDelta(v->child2, delta, check))
00231            return false;
00232    }
00233 
00234    while ( p != child1 && p != child2 && (p = p->parent) ) ;
00235    if (p == child1) sign = 1;
00236    switch (type)
00237     {
00238     case View::HorizontalSplit:
00239         delta = -delta;
00240         ratio = (p->height  + sign * delta) / p->height;
00241         newSize = v->height * ratio;
00242         if (newSize <= .1) return false;
00243         if (check) return true;
00244         v->height = (float) newSize;
00245         if (sign == 1)
00246         {
00247             v->y = p->y + (v->y - p->y) * ratio;
00248         }
00249         else
00250         {
00251             v->y = p->y + delta + (v->y - p->y) * ratio;
00252         }
00253         break;
00254 
00255     case View::VerticalSplit:
00256         ratio = (p->width + sign * delta) / p->width;
00257         newSize = v->width * ratio;
00258         if (newSize <= .1) return false;
00259         if (check) return true;
00260         v->width = (float) newSize;
00261         if (sign == 1)
00262         {
00263             v->x = p->x + (v->x - p->x) * ratio;
00264         }
00265         else
00266         {
00267             v->x = p->x + delta + (v->x - p->x) * ratio;
00268         }
00269         break;
00270     case View::ViewWindow:
00271         break;
00272     }
00273 
00274     return true;
00275 }


Member Data Documentation

float View::alternateZoom
 

Definition at line 76 of file celestiacore.h.

View* View::child1
 

Definition at line 67 of file celestiacore.h.

Referenced by CelestiaCore::deleteView(), CelestiaCore::mouseMove(), CelestiaCore::splitView(), and walkTreeResizeDelta().

View* View::child2
 

Definition at line 68 of file celestiacore.h.

Referenced by CelestiaCore::deleteView(), CelestiaCore::mouseMove(), CelestiaCore::splitView(), and walkTreeResizeDelta().

float View::height
 

Definition at line 72 of file celestiacore.h.

Referenced by CelestiaCore::draw(), mapWindowToView(), CelestiaCore::mouseButtonDown(), CelestiaCore::mouseMove(), CelestiaCore::splitView(), walkTreeResize(), and walkTreeResizeDelta().

int View::labelMode
 

Definition at line 74 of file celestiacore.h.

Observer* View::observer
 

Definition at line 65 of file celestiacore.h.

Referenced by CelestiaCore::draw(), and CelestiaCore::setFOVFromZoom().

View* View::parent
 

Definition at line 66 of file celestiacore.h.

Referenced by CelestiaCore::deleteView(), CelestiaCore::mouseButtonDown(), CelestiaCore::splitView(), walkTreeResize(), and walkTreeResizeDelta().

int View::renderFlags
 

Definition at line 73 of file celestiacore.h.

Type View::type
 

Definition at line 63 of file celestiacore.h.

Referenced by CelestiaCore::mouseMove(), walkTreeResize(), and walkTreeResizeDelta().

float View::width
 

Definition at line 71 of file celestiacore.h.

Referenced by CelestiaCore::draw(), mapWindowToView(), CelestiaCore::mouseButtonDown(), CelestiaCore::mouseMove(), CelestiaCore::splitView(), walkTreeResize(), and walkTreeResizeDelta().

float View::x
 

Definition at line 69 of file celestiacore.h.

Referenced by CelestiaCore::draw(), mapWindowToView(), CelestiaCore::mouseButtonDown(), CelestiaCore::mouseMove(), walkTreeResize(), and walkTreeResizeDelta().

float View::y
 

Definition at line 70 of file celestiacore.h.

Referenced by CelestiaCore::draw(), mapWindowToView(), CelestiaCore::mouseButtonDown(), CelestiaCore::mouseMove(), walkTreeResize(), and walkTreeResizeDelta().

float View::zoom
 

Definition at line 75 of file celestiacore.h.

Referenced by CelestiaCore::setFOVFromZoom(), and CelestiaCore::splitView().


The documentation for this class was generated from the following files:
Generated on Sat Jan 14 22:33:42 2006 for Celestia by  doxygen 1.4.1