Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

xysl.cpp

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /* Módulo: xysl.cpp                                                          */
00003 /* Autores: Carlos Henrique Levy e Jaudênia Cavalcante                       */
00004 /* Data: 29 jul 97                                                           */
00005 /* Comentário:                                                               */
00006 /*    Implementação de métodos da classe que evidencia uma área num gráfico  */
00007 /* através de traços verticais e mudança na cor de fundo da região por eles  */
00008 /* delimitada.                                                               */
00009 /*****************************************************************************/
00010 
00011 #include "xysl.h"
00012 
00013 const char* xy_id_xysl_cpp="$Id: xysl.cpp,v 1.8 1999/12/09 21:47:46 rborges Exp $";
00014                                                                 
00015 XYSlice::XYSlice (const XYAxis* axis,
00016                   double begin,
00017                               double end,
00018                   xybool visible)
00019                         : XYObject(0, 0, visible),
00020                           _axis(axis),
00021                           _beginMarker(NULL),
00022                           _endMarker(NULL),
00023                           _begin(begin),
00024                           _end(end)
00025 {
00026    double min = MIN(begin, end);
00027 
00028    double xb, yb;
00029    _axis -> pointInValue(min, xb, yb);
00030 
00031    position(xb, yb);
00032 }
00033 
00034 void XYSlice::beginMarker (XYMarker* b)
00035 {
00036    _beginMarker = b;
00037 }
00038 
00039 XYMarker* XYSlice::beginMarker (void) const
00040 {
00041    return _beginMarker;
00042 }
00043 
00044 void XYSlice::endMarker (XYMarker* e)
00045 {
00046    _endMarker = e;
00047 }
00048 
00049 XYMarker* XYSlice::endMarker (void) const
00050 {
00051    return _endMarker;
00052 }
00053 
00054 void XYSlice::axis (const XYAxis* ax)
00055 {
00056    _axis = ax;
00057 }
00058 
00059 const XYAxis* XYSlice::axis (void) const
00060 {
00061    return _axis;
00062 }
00063 
00064 void XYSlice::begin (double bm)
00065 {
00066    _begin = bm;
00067 
00068    if (_beginMarker)
00069       _beginMarker -> pos(bm);
00070 }
00071 
00072 double XYSlice::begin (void) const
00073 {
00074    return _begin;
00075 }
00076 
00077 void XYSlice::end (double em)
00078 {
00079    _end = em;
00080 
00081    if (_endMarker)
00082       _endMarker -> pos(em);
00083 }
00084 
00085 double XYSlice::end (void) const
00086 {
00087    return _end;
00088 }
00089 
00090 void XYSlice::color (long c)
00091 {
00092    _color = c;
00093 
00094    if (_beginMarker)
00095       _beginMarker -> color(c);
00096 
00097    if (_endMarker)
00098       _endMarker -> color(c);
00099 }
00100 
00101 long XYSlice::color (void) const
00102 {
00103    return _color;
00104 }
00105 
00106 void XYSlice::backgroundColor (long bc)
00107 {
00108    _backgroundColor = bc;
00109 }
00110 
00111 long XYSlice::backgroundColor (void) const
00112 {
00113    return _backgroundColor;
00114 }
00115 
00116 long XYSlice::changeColor(long color, int tr, int tg, int tb)
00117 {
00118    // decodifica a cor dada em fatores red, green e blue
00119    unsigned char red, green, blue;
00120    cdDecodeColor(color, &red, &green, &blue);
00121 
00122    // modifica o tom da cor dada segundo as taxas fornecidas
00123    int ired   = (int) red   + tr;
00124    int igreen = (int) green + tg;
00125    int iblue  = (int) blue  + tb;
00126 
00127    // teste de consistência, garantia de que os valores estão entre [0, 255]
00128    if (ired   > 255) ired = 255;
00129    if (ired   < 0)   ired = 0;
00130 
00131    if (igreen > 255) igreen = 255;
00132    if (igreen < 0)   igreen = 0;
00133 
00134    if (iblue  > 255) iblue = 255;
00135    if (iblue  < 0)   iblue = 0;
00136 
00137    red   = (unsigned char) ired;
00138    green = (unsigned char) igreen;
00139    blue  = (unsigned char) iblue;
00140 
00141    // nova cor com tonalidade ajustada
00142    return cdEncodeColor(red, green, blue);
00143 }
00144 
00145 //* Acao realizado quando da insercao de uma mascara no grafico
00146 void XYSlice::insertAction (XYGraph * /* graph */)
00147 {
00148 }
00149 
00150 //* Acao realizado quando da romcao de uma mascara no grafico
00151 void XYSlice::removeAction (XYGraph * /* graph */)
00152 {
00153 }

XY
Tecgraf / PUC-Rio - Computer Graphics Technology Group