12 #include <KeySymbols.h>
18 #include "../CommonXAxis.h"
38 void ObjectLine::InitLine(
double x0,
double y0,
double x1,
double y1)
41 std::cout <<
"ObjectLine::InitLine " << std::endl;
55 fline =
new TLine ( x0, y0, x1, y1 );
58 fline->SetLineWidth( 2 );
59 fline->SetLineColor ( 4 );
66 std::cout <<
"Entry Constructor default Base ObjectLine " << std::endl;
74 std::cout <<
"ObjectLine::ObjectLine( Int_t typeline, valueY ) " <<
" valuey0 " << valuey0 << std::endl;
79 InitLine ( 0., valuey0, 1.0, valuey0);
88 std::cout <<
"Constructor ObjectLine with 4 arguments call InitLine " << std::endl;
98 std::cout <<
"Entry ObjectLine::GetValues px/py where used to move ?? px/py " << px <<
" " << py << std::endl;
101 std::vector<float>
values;
109 #ifdef DEBUG_OBJSTOCK
110 std::cout <<
"ObjectLine::GetValues, need to extrapolate " << std::endl;
121 values.push_back ( 0. );
128 #ifdef DEBUG_OBJSTOCK
129 std::cout <<
"ObjectLine::DistancetoPrimitive return dist " <<
fline->DistancetoPrimitive( px, py ) << std::endl;
130 std::cout <<
"fline->ClassName() " <<
fline->ClassName() << std::endl;
134 return fline->DistancetoPrimitive( px, py );
146 #ifdef DEBUG_OBJSTOCK
147 std::cout <<
"\tObjectLine::Paint" << std::endl;
166 #ifdef DEBUG_OBJSTOCK
167 std::cout <<
"Entry Constructor ObjectLineIndicator name " << name <<
" value " << value << std::endl;
185 #ifdef DEBUG_OBJSTOCK
186 std::cout <<
"Entry ObjectLineIndicator::MakeStringForStatusBar " << std::endl;
187 std::cout <<
"px " << px << std::endl;
191 std::vector<std::string> vec_string;
196 #ifdef DEBUG_OBJSTOCK
197 std::cout <<
"bin " << bin <<
"bin2 " << bin2 << std::endl;
204 vec_string.push_back( str1 );
210 #ifdef DEBUG_OBJSTOCK
211 std::cout <<
"ObjectLineIndicator::SetObjectStock easy than general function " << std::endl;
212 std::cout <<
"Hparam.xmin/xmax " << Hparam_stock.
xmin <<
" Hparam_stock.xmax " << Hparam_stock.
xmax << std::endl;
223 ObjectLine(), coeff_d ( 0. ), origin ( 0 ), valueY0(0.), valueY1(0.),
224 ftbegin(0), ftend(0),fbin_begin(0),fbin_end(0)
226 #ifdef DEBUG_OBJSTOCK
227 std::cout <<
"Const ObjectLineTendance::ObjectLineTendance( int mode_line, doubleX, doubleY ) " << std::endl;
228 std::cout <<
"test X " << valueX << std::endl;
229 std::cout <<
"test Y " << valueY << std::endl;
237 InitLine ( valueX, valueY, valueX, valueY );
247 #ifdef DEBUG_OBJSTOCK
248 std::cout <<
"ObjectLineTendance::RecalcCoeff_origin" << std::endl;
249 std::cout <<
"x0 " << x0 <<
" x1 " << x1 << std::endl;
260 coeff_d = ( y1 - y0 ) / ( x1 - x0 );
263 #ifdef DEBUG_OBJSTOCK
264 std::cout <<
"y0 " << y0 <<
" y1 " << y1 << std::endl;
265 std:: cout <<
" coeff origin " <<
coeff_d <<
" " <<
origin << std::endl;
267 std:: cout <<
" should be equal coeff origin " <<
coeff_d <<
" " << y1 -
coeff_d * x1 << std::endl;
274 #ifdef DEBUG_OBJSTOCK
275 std::cout <<
"ObjectLineTendance::InitCoeff_origin" << std::endl;
280 coeff_d = ( y1 - y0 ) / ( x1 - x0 );
283 #ifdef DEBUG_OBJSTOCK
284 std:: cout <<
" coeff origin " <<
coeff_d <<
" " <<
origin << std::endl;
293 #ifdef DEBUG_OBJSTOCK
294 std::cout <<
"GetXBorder y " << y << std::endl;
305 #ifdef DEBUG_OBJSTOCK
306 std::cout <<
"ExtrapolateYPad coeff_d origin " <<
coeff_d <<
" " <<
origin << std::endl;
317 #ifdef DEBUG_OBJSTOCK
318 std::cout <<
"\n\tEntry ObjectLineTendance::FinaliseDrawableLine()" << std::endl;
319 std::cout <<
"fcommon_axis " << fcommon_xaxis_th << std::endl;
324 Int_t bin_x0 = fcommon_xaxis_th->
GetXAxis()->FindBin(
GetX0() );
325 Int_t bin_x1 = fcommon_xaxis_th->
GetXAxis()->FindBin(
GetX1() );
328 #ifdef DEBUG_OBJSTOCK
329 std::cout <<
"set bins " << bin_x0 <<
" " << bin_x1 << std::endl;
330 std::cout <<
"set bins ok " << std::endl;
331 std::cout <<
"test fParentTHStock " <<
fParentTHStock << std::endl;
347 #ifdef DEBUG_OBJSTOCK
348 std::cout <<
"InitValuesY Y0/Y1 " <<
valueY0 <<
" " <<
valueY1 << std::endl;
351 SetX0( fcommon_xaxis_th->
GetXAxis()->GetBinCenter( bin_x0 ) );
352 SetX1( fcommon_xaxis_th->
GetXAxis()->GetBinCenter( bin_x1 ) );
353 #ifdef DEBUG_OBJSTOCK
354 std::cout <<
"new X0 X1 " <<
GetX0() <<
" " <<
GetX1() << std::endl;
360 #ifdef DEBUG_OBJSTOCK
361 std::cout <<
"GetY0/Y1 after extrapolate " <<
GetY0() <<
" " <<
GetY1() << std::endl;
368 #ifdef DEBUG_OBJSTOCK
369 std::cout <<
"Set origin " << x <<
" " << y <<
" " <<
origin << std::endl;
372 #ifdef DEBUG_OBJSTOCK
373 std::cout <<
"new origin " <<
origin << std::endl;
379 #ifdef DEBUG_OBJSTOCK
380 std::cout <<
"Entry ObjectLineTendance::MakeStringForStatusBar px/py " << std::endl;
382 std::string text_str0, text_str1;
383 std::vector<std::string> vec_string;
385 std::vector<float>
values;
390 values.push_back (
GetY0() );
394 #ifdef DEBUG_OBJSTOCK
395 std::cout <<
"ObjectLineTendance::MakeStringForStatusBar, call get value to extrapolate " << std::endl;
403 text_str1 =
"Tendance = "+ Utils::toString<double>(fvalues);
406 vec_string.push_back(text_str0);
407 vec_string.push_back(text_str1);
415 #ifdef DEBUG_OBJSTOCK
416 std::cout <<
"Entry ObjectLineTendance::SetObjectStock " << std::endl;
417 std::cout <<
"Hparam_stock.xfirst/xlast " << Hparam_stock.
xfirst <<
" " << Hparam_stock.
xlast << std::endl;
426 double tmp_x0 = gPad->XtoPad( fcommon_xaxis_th->
GetXAxis()->GetBinCenter( bin_x0 ) );
427 double tmp_x1 = gPad->XtoPad( fcommon_xaxis_th->
GetXAxis()->GetBinCenter( bin_x1 ) );
437 #ifdef DEBUG_OBJSTOCK
438 std::cout <<
"IsLine true" << std::endl;
472 if ( bin_x0 < Hparam_stock.
xfirst ) {
473 bin_x0 = Hparam_stock.
xfirst;
476 tmp_x0 = gPad->XtoPad( fcommon_xaxis_th->
GetXAxis()->GetBinCenter( bin_x0 ) );
492 if ( bin_x0 == Hparam_stock.
xlast) {
493 #ifdef DEBUG_OBJSTOCK
494 std::cout <<
"bad effect " << std::endl;
504 if ( bin_x1 > Hparam_stock.
xlast ) {
505 bin_x1 = Hparam_stock.
xlast;
507 tmp_x1 = gPad->XtoPad( fcommon_xaxis_th->
GetXAxis()->GetBinCenter( bin_x1 ) );
520 if ( bin_x1 == Hparam_stock.
xfirst) {
521 #ifdef DEBUG_OBJSTOCK
522 std::cout <<
" bad effect kHalfLine2 " << std::endl;
533 #ifdef DEBUG_OBJSTOCK
534 std::cout <<
"Pad Ymin/max " << Hparam_stock.
ymin <<
" " << Hparam_stock.
ymax << std::endl;
565 #ifdef DEBUG_OBJSTOCK
566 std::cout <<
"ObjectLineTendance::Paint " << std::endl;
580 static bool p1, p2, pL;
581 static int d1,d2,px1,px2,py1,py2;
582 static int pxold, pyold, px1old, py1old, px2old, py2old;
585 #ifdef DEBUG_OBJSTOCK
586 std::cout <<
"Entry ObjectLineTendance::ExecuteEvent " << std::endl;
587 std::cout <<
"pxold/pyold " << pxold <<
" " << pyold << std::endl;
588 std::cout <<
"px/py " << px <<
" " << py << std::endl;
595 #ifdef DEBUG_OBJSTOCK
596 std::cout <<
" kButton1Down no break , setLineColor(-1) " << std::endl;
599 gVirtualX->SetLineColor(-1);
608 #ifdef DEBUG_OBJSTOCK
609 std::cout <<
"kMouseMotion " << std::endl;
611 px1 = gPad->XtoAbsPixel(
GetX0() );
612 py1 = gPad->YtoAbsPixel(
GetY0() );
613 px2 = gPad->XtoAbsPixel(
GetX1() );
614 py2 = gPad->YtoAbsPixel(
GetY1() );
617 p1 = p2 = pL = kFALSE;
619 d1 = abs(px1 - px) + abs(py1-py);
621 px1old = px1; py1old = py1;
623 gPad->SetCursor(kPointer);
626 d2 = abs(px2 - px) + abs(py2-py);
628 px2old = px2; py2old = py2;
630 gPad->SetCursor(kPointer);
636 pxold = px; pyold = py;
637 gPad->SetCursor(kMove);
642 #ifdef DEBUG_OBJSTOCK
643 std::cout <<
"kButton1Motion " << std::endl;
647 gVirtualX->DrawLine(px1old, py1old, px2, py2);
648 gVirtualX->DrawLine(px, py, px2, py2);
653 gVirtualX->DrawLine(px1, py1, px2old, py2old);
654 gVirtualX->DrawLine(px1, py1, px, py);
659 gVirtualX->DrawLine(px1, py1, px2, py2);
660 dx = px-pxold; dy = py-pyold;
661 px1 += dx; py1 += dy; px2 += dx; py2 += dy;
662 gVirtualX->DrawLine(px1, py1, px2, py2);
670 #ifdef DEBUG_OBJSTOCK
671 std::cout <<
"kButton1Up " << std::endl;
682 if ( ( px==pxold ) && ( py=pyold ) ) {
683 std::cout <<
"px==pxold && py==pyold what to do !!!" << std::endl;
685 #ifdef DEBUG_OBJSTOCK
686 std::cout <<
"p1, p2, pL " << p1 <<
" " << p2 <<
" " << pL << std::endl;
696 SetX0 ( gPad->PadtoX(gPad->AbsPixeltoX(px)) );
697 SetY0 ( gPad->PadtoY(gPad->AbsPixeltoY(py)) );
700 SetX1 ( gPad->PadtoX(gPad->AbsPixeltoX(px)) );
701 SetY1 ( gPad->PadtoY(gPad->AbsPixeltoY(py)) );
705 SetX0 ( gPad->PadtoX(gPad->AbsPixeltoX(px1)) );
706 SetY0 ( gPad->PadtoY(gPad->AbsPixeltoY(py1)) );
707 SetX1 ( gPad->PadtoX(gPad->AbsPixeltoX(px2)) );
708 SetY1 ( gPad->PadtoY(gPad->AbsPixeltoY(py2)) );
721 #ifdef DEBUG_OBJSTOCK
722 std::cout <<
" IsSupport ? " <<
IsSupport() << std::endl;
742 p1 = p2 = pL = kFALSE;
749 gPad->Modified(kTRUE);
756 #ifdef DEBUG_OBJSTOCK
757 std::cout <<
"kKeyPress " <<
event <<
" px " << px <<
" py " << py << std::endl;
766 switch ((EKeySym)keysym) {
787 std::cout<<
"left arrow"<<std::endl;
790 std::cout<<
"rightarrow"<<std::endl;
794 std::cout<<
"down arrow, last commented "<<std::endl;
801 std::cout <<
"up arrow, last commented " << std::endl;
810 std::cout <<
"kKey_Return " << std::endl;
815 std::cout <<
"default case unset trans and rotat" << std::endl;
826 std::cout <<
"default case no event associated, nothing to do " << std::endl;
838 #ifdef DEBUG_OBJSTOCK
839 std::cout <<
"Entry ObjectLineTendance::MoveObjectLine " << std::endl;
840 std::cout <<
"kdir " << kdir << std::endl;
843 double new_coeff,old_coeff = 0.;
847 #ifdef DEBUG_OBJSTOCK
848 std::cout <<
"mode translation " << std::endl;
851 if ( kdir ==
true ) {
859 #ifdef DEBUG_OBJSTOCK
860 std::cout <<
"new valueY0 " <<
valueY0 << std::endl;
861 std::cout <<
"new valueY1 " <<
valueY1 << std::endl;
862 std::cout <<
"new Y0/Y1 " <<
GetY0() <<
"/" <<
GetY1() << std::endl;
867 #ifdef DEBUG_OBJSTOCK
868 std::cout <<
"mode rotation " << std::endl;
871 #ifdef DEBUG_OBJSTOCK
872 std::cout <<
"old_coeff " << old_coeff << std::endl;
875 if ( kdir ==
true ) {
876 new_coeff = old_coeff * 1.025;
880 new_coeff = old_coeff * 0.975;
886 #ifdef DEBUG_OBJSTOCK
887 std::cout <<
"new coeff " <<
GetCoeffD() << std::endl;
900 #ifdef DEBUG_OBJSTOCK
903 std::cout <<
"any transl or rotate selected " << std::endl;
ClassImp(ObjectLine) ClassImp(ObjectLineIndicator) ClassImp(ObjectLineTendance) void ObjectLine
wrapper to TLine constructor
double coeff_d
most general for drawing a line, y = ax + b and moving as well, rotate a, translate b ! a and b not f...
virtual std::string GetNameObject() const
pure-virtual access
ObjectLineIndicator()
constructors
virtual std::vector< float > GetValues(int px, int py, time_t &date) const
used by MakeStringForStatusBar only base in ObjectLine should be very simple
virtual void SetObjectStock(ListDataStockBase *, CommonXAxis *, Hparam_stock_t &)
implements a easy way for this case only set to xmin xmax
ModeLine fModeLine
kLine, kSegment, kHalfSegment0, kHalfSegment1
virtual bool IsHalfLine1()
double valueY0
save initial values, y's overridden if Lines Y initial values , no overloaded by line->SetY, here stay constant associated to fbin_begin/fend
TLine * fline
use composition TLine*, valable for all derived class
void SetBins(Int_t bin_x0, Int_t bin_x1)
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py, AbstractObjectStock **obj)
void InitCoeff_origin(double x0, double x1, double y0, double y1)
void SetCoeffD(double &new_coeff)
virtual void Paint(const Option_t *="")
Paint the objet, to overide.
virtual void MoveObjectLine(bool kdir)
pass the direction ( positive, negative ) to extend
double GetCoeffD() const
member functions specific
virtual std::vector< std::string > MakeStringForStatusBar(int px, int py) const
specific output for ObjectLineIndicator
double GetX0() const
wrapper functions to fline, need public for all ??
Hparam_stock_t Hparam_stock
Int_t GetBinFromPixel(Int_t px, Int_t &total_bin) const
called by ObjectStock, for StatusBar
virtual void SetObjectStock(ListDataStockBase *, CommonXAxis *, Hparam_stock_t &)
used for from the listdata
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Make all drawable modification, move by mouse and arrow.
Define the template ListObjectStock<T> in a separate header.
Regroup sub-hierarchy related to the LineObject :
virtual bool IsSupport() const
void InitLine(double x0, double y0, double x1, double y1)
virtual void Paint(const Option_t *="")
Paint the objet, to overide.
std::string toString(const T &t)
std::string Time_tToString(const time_t &time, const bool b_hour)
Return a string representing the date All times are expressed in the localtime.
virtual void SetTimes(time_t begin, time_t end)
time_t GetDateFromBin(Int_t bin) const
called by ObjectLine need the date from a bin
TypeLine fTypeLine
TypeLine, enum : kNone, kSupport, kTendance, kFibo.
virtual double GetXBorder(double y) const
specific for extrapolation return X value where border is crossed
void SetOrigin(double &x, double &y)
virtual double ExtrapolateYPad(double) const
extrapolate y fom line equation
Used for free drawing of support/tendance Add a general line description with coeef_d and origin : y ...
virtual std::vector< std::string > MakeStringForStatusBar(int px, int py) const
create the string for the StatusBar
void FinaliseDrawableLine(CommonXAxis *fcommon_xaxis_th)
set up all data member after drawing.
Abstract base class for the ListDataStock, for storing base pointers in vectors.
std::string name_line
add a name, absent in AbstractObjectStock
virtual bool IsHalfLine2()
Define an abstract base class for all objects to be painted in a THStock.
Int_t GetBinBegin() const
TypeLine
c++ 11 style, used by both EditorObjectStock and ObjectLine cannot make dictionary with enum class ! ...
Line for drawing with indicator, eg, RSI 30-70 Could be in Collection or in THStock They are fixed : ...
time_t GetDateBinFromPixel(Int_t px, Int_t py, Int_t &bin, Int_t &bin2) const
return both the date and two bins called only ObjectLine::GetValues
void RecalcCoeff_origin(double x0, double x1)
mathematical functions
ObjectLineTendance()
default constructor