Создание редактора входных воздействий цифровых сигналов для САПР OrCad 9.1, страница 7

    x+=step;

  }

//end of Сетка

  StmForm->Canvas->Pen->Width=2;

  i=2,j=sig_offset;

  for(;j<num_signals;j++)

  {

    global_y+=Y_STEP;

    signals[j].GetOneFF(0,&time1,val1);

    StmForm->Canvas->Pen->Color=clRed;

    StmForm->Canvas->MoveTo(0,global_y);

    dimension=signals[j].GetDimension();

    if (dimension==3)

    {

      y_high=global_y,y_low=global_y+20,y=global_y;

      signals[j].GetOneFF(0,&time1,val1);

      signals[j].GetOneFF(1,&time2,val2);

      int c_x=0;

      int n=(r_res_x+offset)/(time1+time2)+1;

      if (val1[0]=='1'||val1[0]=='H') y1=y_high;

      if (val1[0]=='0'||val1[0]=='L') y1=y_low;

      if (val2[0]=='1'||val2[0]=='H') y2=y_high;

      if (val2[0]=='0'||val2[0]=='L') y2=y_low;

      Canvas->MoveTo(0,y1);

      StmForm->Canvas->Pen->Color=clLime;

      for (i=0;i<n;i++)

      {

        Canvas->LineTo((time1+c_x-offset)*koef_x,y1);

        Canvas->LineTo((time1+c_x-offset)*koef_x,y2);

        Canvas->LineTo((time2+time1+c_x-offset)*koef_x,y2);

        Canvas->LineTo((time2+time1+c_x-offset)*koef_x,y1);       

        c_x+=time1+time2;

      }

    }

    if (dimension==2)

    {

      y_high=global_y,y_low=global_y+20,y=global_y;

      Canvas->Font->Color=clLime;

      Canvas->Font->Size=10;

      signals[j].GetOneFF(0,&time1,val1);

      StmForm->Canvas->Pen->Color=clRed;

      StmForm->Canvas->MoveTo(0,y-10);

      StmForm->Canvas->LineTo(time1*koef_x-offset*koef_x-10,y-10);

      StmForm->Canvas->LineTo(time1*koef_x-offset*koef_x,y);

      StmForm->Canvas->LineTo(time1*koef_x-offset*koef_x-10,y+10);

      StmForm->Canvas->LineTo(0,y+10);

      for(i=1;i<=signals[j].GetNumFF();i++)

      {

        signals[j].GetOneFF(i-1,&time1,val1);

        signals[j].GetOneFF(i,&time2,val2);

        StmForm->Canvas->Pen->Color=clLime;

        if (time2>time1)

        {

                len=(time2-time1)/2;

                StmForm->Canvas->TextOut(time1*koef_x-offset*koef_x+len*koef_x-2,y-7,val1);

                StmForm->Canvas->MoveTo(time1*koef_x-offset*koef_x,y);

                StmForm->Canvas->LineTo(time1*koef_x-offset*koef_x+10,y-10);

                StmForm->Canvas->LineTo(time2*koef_x-offset*koef_x-10,y-10);

                StmForm->Canvas->LineTo(time2*koef_x-offset*koef_x,y);

                StmForm->Canvas->LineTo(time2*koef_x-offset*koef_x-10,y+10);

                StmForm->Canvas->LineTo(time1*koef_x-offset*koef_x+10,y+10);

                StmForm->Canvas->LineTo(time1*koef_x-offset*koef_x,y);

        }

      }

      if (time2<=time1)

      {

        len=(offset+r_res_x-time1-OTSTUP)/2;

        StmForm->Canvas->TextOut(time1*koef_x-offset*koef_x+len*koef_x-2,y-7,val1);

        StmForm->Canvas->MoveTo(time1*koef_x-offset*koef_x,y);

        StmForm->Canvas->LineTo(time1*koef_x-offset*koef_x+10,y-10);

        StmForm->Canvas->LineTo(StmForm->Width-OTSTUP,y-10);

        StmForm->Canvas->LineTo(StmForm->Width-OTSTUP,y+10);

        StmForm->Canvas->LineTo(time1*koef_x-offset*koef_x+10,y+10);

        StmForm->Canvas->LineTo(time1*koef_x-offset*koef_x,y);

      }

    }

    if (dimension==1)

    {

    int x=0,y_high=global_y,y_low=global_y+20,y_middle=global_y+10,y=global_y;

    StmForm->Canvas->LineTo(time1*koef_x-offset*koef_x,global_y);

    StmForm->Canvas->Pen->Color=clLime;

    for(i=1;i<=signals[j].GetNumFF();i++)

    {

      signals[j].GetOneFF(i-1,&time1,val1);

      signals[j].GetOneFF(i,&time2,val2);

      if (val1[0]=='1'||val1[0]=='H') y=y_high;

      if (val1[0]=='0'||val1[0]=='L') y=y_low;

      if (val1[0]=='Z'){ y=y_high;StmForm->Canvas->Pen->Color=clRed;}

      if (time2>=time1)

      {

        StmForm->Canvas->LineTo(time1*koef_x-offset*koef_x,y);

        StmForm->Canvas->LineTo(time2*koef_x-offset*koef_x,y);

        StmForm->Canvas->Pen->Color=clLime;

      }

      if (val2[0]=='1'||val2[0]=='H') y=y_high;

      if (val2[0]=='0'||val2[0]=='L') y=y_low;

      if (val2[0]=='Z'){ y=y_high;StmForm->Canvas->Pen->Color=clRed;}

      if (time2>=time1)

        StmForm->Canvas->LineTo(time2*koef_x-offset*koef_x,y);

      StmForm->Canvas->Pen->Color=clLime;

    }

      if (val2[0]=='1'||val2[0]=='H') y=y_high;

      if (val2[0]=='0'||val2[0]=='L') y=y_low;

      if (val2[0]=='Z'){ y=y_high;StmForm->Canvas->Pen->Color=clRed;}

      if (time2>=time1)

        StmForm->Canvas->LineTo(time2*koef_x-offset*koef_x,y);

      else

      {

         if (val1[0]=='1') y=y_high;

         if (val1[0]=='0') y=y_low;

         if (val1[0]=='Z'){ y=y_high;StmForm->Canvas->Pen->Color=clRed;}

         StmForm->Canvas->LineTo(time1*koef_x-offset*koef_x,y);

      }

      StmForm->Canvas->LineTo(StmForm->Width-OTSTUP,y);

      StmForm->Canvas->Pen->Color=clLime;

      }

  }

  StmForm->Canvas->Brush->Color=clBlack;

  StmForm->Canvas->FillRect(Rect(Width-OTSTUP,0,Width,Height));

  StmForm->Canvas->Pen->Color=clGray;

  StmForm->Canvas->MoveTo(0,StmForm->Height-100);

  StmForm->Canvas->LineTo(StmForm->Width,StmForm->Height-100);

  StmForm->Canvas->Pen->Width=3;

  StmForm->Canvas->MoveTo(Width-OTSTUP,0);

  StmForm->Canvas->LineTo(Width-OTSTUP,Height);

//signal names

  global_y=-35;j=sig_offset;

  Canvas->Font->Color=clLtGray;

  Canvas->Font->Size=10;

  for(;j<num_signals;j++)

  {

      global_y+=Y_STEP;

      val=signals[j].GetName();

      char *c=val;

      for(i=0;val[i]&&val[i]!='.';i++,c++);c++;

      val[i]=0;

      Canvas->Font->Color=clLtGray;

      StmForm->Canvas->TextOut(Width-98,global_y,val);

      Canvas->Font->Color=clWhite;

      StmForm->Canvas->TextOut(Width-98,global_y+20,c);

  }

  delete val;

}

//---------------------------------------------------------------------------