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

DasherView.cpp

Go to the documentation of this file.
00001 // DasherView.cpp
00002 //
00004 //
00005 // Copyright (c) 2001-2002 David Ward
00006 //
00008 
00009 #include "DasherView.h"
00010 using namespace Dasher;
00011 
00012 
00013 CDasherView::CDasherView(CDasherScreen* DasherScreen, CDasherModel& DasherModel, Opts::ScreenOrientations Orientation)
00014   : m_Screen(DasherScreen), m_DasherModel(DasherModel), ScreenOrientation(Orientation), ColourMode(false)
00015 {
00016 //      XYScale = (double)m_Screen->GetHeight() / m_Screen->GetWidth();
00017 }
00018 
00019 
00020 void CDasherView::ChangeOrientation(Dasher::Opts::ScreenOrientations Orientation)
00021 {
00022         ScreenOrientation = Orientation;
00023         Render();
00024 }
00025 
00026 
00027 void CDasherView::FlushAt(int ,int ) 
00028 {
00029         m_DasherModel.Flush(0,0);
00030 }
00031 
00032 int CDasherView::RecursiveRender(CDasherNode* Render, myint y1,myint y2,int mostleft, bool text)
00033 {
00034         // symbol CurChar = Render->Symbol();
00035         int Color;
00036 
00037         if (ColourMode==true) {
00038           Color = Render->Colour();
00039         } else {
00040           Color = Render->Phase()%3; 
00041         }
00042 
00043         if (RenderNode(Render->Symbol(), Color, Render->Cscheme(), y1, y2, mostleft, Render->m_bForce, text))
00044                 RenderGroups(Render, y1, y2, text);
00045         else
00046                 Render->Kill();
00047         
00048         CDasherNode** const Children=Render->Children();
00049         if (!Children)
00050           return 0;
00051         int norm=DasherModel().Normalization();
00052                 for (unsigned int i=1; i<Render->Chars(); i++) {
00053                 if (Children[i]->Alive()) {
00054                         myint Range=y2-y1;
00055                         myint newy1=y1+(Range*Children[i]->Lbnd())/norm;
00056                         myint newy2=y1+(Range*Children[i]->Hbnd())/norm;
00057                         RecursiveRender(Children[i], newy1, newy2, mostleft, text);
00058                 }
00059         }
00060         return 1;
00061 
00062 
00063 }
00064 
00065 
00066 void CDasherView::RenderGroups(CDasherNode* Render, myint y1, myint y2, bool text)
00067 {
00068         CDasherNode** Children = Render->Children();
00069         if (!Children)
00070                 return;
00071         int current=0;
00072         int lower=0;
00073         int upper=0;
00074         myint range=y2-y1;
00075         for (unsigned int i=1; i<Render->Chars(); i++) {
00076                 int g=Children[i]->Group();
00077                 if (g!=current) {
00078                         lower=upper;
00079                         upper=i;
00080                         
00081                         if (current!=0) {
00082                                 myint lbnd=Children[lower]->Lbnd();
00083                                 myint hbnd=Children[upper]->Lbnd();
00084                                 myint newy1=y1+(range*lbnd)/m_DasherModel.Normalization();
00085                                 myint newy2=y1+(range*hbnd)/m_DasherModel.Normalization();
00086                                 int mostleft;
00087                                 bool force;
00088                                 RenderNode(0,current-1,Opts::Groups,newy1,newy2,mostleft,force,text);
00089                         }
00090                         current=g;
00091                 }
00092         }
00093 }

Generated on Sat Nov 5 16:16:00 2005 for OPIE by  doxygen 1.4.2