Logo Search packages:      
Sourcecode: dasher version File versions

DasherView.cpp

// DasherView.cpp
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2001-2004 David Ward
//
/////////////////////////////////////////////////////////////////////////////

#include "DasherView.h"
using namespace Dasher;


CDasherView::CDasherView(CDasherScreen* DasherScreen, CDasherModel& DasherModel, CLanguageModel* LanguageModel, Opts::ScreenOrientations Orientation, bool ColourMode)
  : ScreenOrientation(Orientation), ColourMode(ColourMode), m_Screen(DasherScreen), m_DasherModel(DasherModel), m_LanguageModel(LanguageModel)
{
//    XYScale = (double)m_Screen->GetHeight() / m_Screen->GetWidth();

// myint ySum, ySumCounter=0, yFilterTimescale=2, yAutoOffset=0, ySigBiasPixels=0, ySigBiasPercentage=0;   
}


void CDasherView::ChangeOrientation(Dasher::Opts::ScreenOrientations Orientation)
{
      ScreenOrientation = Orientation;
}


int CDasherView::RecursiveRender(CDasherNode* Render, myint y1,myint y2,int mostleft, bool text)
{
      int Color;

      if (ColourMode==true) {
        if (Render->Colour()!=-1) {
          Color = Render->Colour();
        } else {
          if (Render->Symbol()==m_LanguageModel->GetSpaceSymbol()) {
            Color = 9;
          } else if (Render->Symbol()==m_LanguageModel->GetControlSymbol()) {
            Color = 8;
          } else {
            Color = (Render->Symbol()%3)+10;
          }
        }
      } else {
        Color = Render->Phase()%3; 
      }

      if ((Render->Cscheme()%2)==1 && Color<130 && ColourMode==true) { // We don't loop on high
        Color+=130;                                // colours
      }

      if (Render->GetControlTree()!=NULL) {
        if (RenderNode(Render->Symbol(), Color, Render->Cscheme(), y1, y2, mostleft, Render->m_bForce, text,Render->GetControlTree()->text))
          RenderGroups(Render, y1, y2, text);
        else
          Render->Kill();
      } else {
        if (RenderNode(Render->Symbol(), Color, Render->Cscheme(), y1, y2, mostleft, Render->m_bForce, text,""))
          RenderGroups(Render, y1, y2, text);
        else
          Render->Kill();
      }
      
      CDasherNode** const Children=Render->Children();
      if (!Children)
        return 0;
      int norm=DasherModel().Normalization();
            for (unsigned int i=1; i<Render->ChildCount(); i++) {
            if (Children[i]->Alive()) {
                  myint Range=y2-y1;
                  myint newy1=y1+(Range*Children[i]->Lbnd())/norm;
                  myint newy2=y1+(Range*Children[i]->Hbnd())/norm;
                  RecursiveRender(Children[i], newy1, newy2, mostleft, text);
            }
      }
      return 1;


}

void CDasherView::ResetSum() { ySum=0; }
void CDasherView::ResetSumCounter() { ySumCounter=0; }
void CDasherView::ResetYAutoOffset() { yAutoOffset=0; }


void CDasherView::RenderGroups(CDasherNode* Render, myint y1, myint y2, bool text)
{
      CDasherNode** Children = Render->Children();
      if (!Children)
            return;
      int current=0;
      int lower=0;
      int upper=0;
    std::string Label="";

      myint range=y2-y1;
      for (unsigned int i=1; i<Render->ChildCount(); i++) {
            int g=Children[i]->Group();
            if (g!=current) {
                  lower=upper;
                  upper=i;
                  
                  if (current!=0) {
                        myint lbnd=Children[lower]->Lbnd();
                        myint hbnd=Children[upper]->Lbnd();
                        myint newy1=y1+(range*lbnd)/m_DasherModel.Normalization();
                        myint newy2=y1+(range*hbnd)/m_DasherModel.Normalization();
                        int mostleft;
                        bool force;
                        if (ColourMode==true) {
                  std::string Label = Render->GroupLabel(current);
                          int Colour = Render->GroupColour(current);
                  
                  if (Colour!=-1) {
                              RenderNode(0,Render->GroupColour(current),Opts::Groups,newy1,newy2,mostleft,force,text,Label);
                          } else {
                            RenderNode(0,(current%3)+110,Opts::Groups,newy1,newy2,mostleft,force,text,Label);
                          }
                        } else {
                              RenderNode(0,current-1,Opts::Groups,newy1,newy2,mostleft,force,text,Label);
                        }
                  }
                  current=g;
            }
      }
}

Generated by  Doxygen 1.6.0   Back to index