00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _PO_TIME_AXIS_
00025 #define _PO_TIME_AXIS_
00026
00027 #include <MeshViz/graph/PoAxis.h>
00028 #include <MeshViz/graph/PbDateFormatMapping.h>
00029 #include <MeshViz/graph/PiNumericFormat.h>
00030 #include <MeshViz/graph/PiDate.h>
00031
00032
00033 #include <Inventor/fields/SoSFEnum.h>
00034 #include <Inventor/fields/SoSFFloat.h>
00035 #include <Inventor/fields/SoSFString.h>
00036 #include <Inventor/fields/SoMFString.h>
00037
00038
00039 class SoMatrixTransform ;
00040
00305 class PoTimeAxis : public PoAxis {
00306
00307 SO_KIT_HEADER(PoTimeAxis) ;
00308
00309
00310 public:
00311
00315 enum Language {
00319 ENGLISH,
00323 FRANCAIS,
00327 DEUTSCH,
00331 ESPANOL
00332 } ;
00333
00334 enum GradFit {
00338 GRAD_FIT,
00342 GRAD_UNFIT
00343 } ;
00344
00345
00346
00350 enum Type {
00354 X,
00358 Y
00359 } ;
00360
00361
00362
00367 SoSFString startDate ;
00368
00373 SoSFString endDate ;
00374
00378 SoSFFloat coord ;
00379
00383 SoSFEnum type ;
00384
00388 SoSFEnum language ;
00389
00393 SoSFEnum gradFit ;
00394
00399 SoMFString gradRep ;
00400
00406 SoSFString timesPeriod ;
00407
00408
00409
00413 PoTimeAxis()
00414 { init(TRUE) ; }
00415
00419 PoTimeAxis(const char *_startDate, const char *_endDate, float _coord,
00420 Type _type = X)
00421 { init(FALSE, _startDate, _endDate, _coord, _type) ; }
00422
00426 virtual void rebuild() ;
00427
00435 void setDateFormatMapping(PbDateFormatMapping *formatMapping) ;
00436
00441 const PbDateFormatMapping *getDateFormatMapping() const ;
00442
00443
00444
00445 private:
00446
00447 static void initClass() ;
00448 static void exitClass() ;
00449
00450 enum Tdate_elem_form {
00451 TSECOND,
00452 TMINUTE,
00453 THOUR,
00454 TDAY_NUMBER,
00455 TWEEK_DAY,
00456 TMONTH_NUMBER,
00457 TYEAR_MONTH,
00458 TYEAR
00459 } ;
00460
00461 enum Tdate_step {
00462 TSTEP_UNKNOWN,
00463 TSTEP_SECONDS,
00464 TSTEP_MINUTES,
00465 TSTEP_HOURS,
00466 TSTEP_DAYS,
00467 TSTEP_MONTHS,
00468 TSTEP_YEARS
00469 } ;
00470
00471 struct Tdate_elem {
00472 int form_prefixe;
00473 Tdate_elem_form form;
00474 char *append_str;
00475 } ;
00476
00477
00478 struct Tdate_axis_level_rep {
00479 Tdate_step step;
00480 float num_step;
00481 int ten_power;
00482 char *append_str;
00483 int num_date_elems;
00484 Tdate_elem *date_elems;
00485 } ;
00486
00487 struct Tdate_axis_rep {
00488 int num_level;
00489 Tdate_axis_level_rep *level_rep;
00490 } ;
00491
00492 struct Tdate_interv {
00493 float num_units;
00494 Tdate_step units;
00495 } ;
00496
00497 struct Tdate_list {
00498 int num_dates;
00499 Tdate_interv *dates;
00500 } ;
00501
00502 private:
00503
00504 struct TimeAxisAttr {
00505 PbDateFormatMapping *formatMapping ;
00506 PiDate startDate ;
00507 PiDate endDate ;
00508 PiNumericFormat numericFormat ;
00509 Plane plane ;
00510 int num_date_limit ;
00511 PiDate *date_limit ;
00512 int num_rep ;
00513 Tdate_axis_rep *date_axis_rep ;
00514 } ;
00515
00516
00517
00518 virtual ~PoTimeAxis() ;
00519 virtual SbBool setUpConnections(SbBool onOff, SbBool doItAlways = FALSE) ;
00520 virtual void setDefaultOnNonWritingFields() ;
00521
00522
00523 virtual void basicObjectChange(PbBase *basicObj) ;
00524
00525
00526 virtual void saveAxisAttr() ;
00527
00528
00529 virtual void preRebuild() ;
00530 virtual void addElementsAllCaches() ;
00531
00532 private:
00533
00534 void init(SbBool isDefault, const char *startDate=NULL, const char *endDate=NULL,
00535 float coord=0.0, Type type = X) ;
00536
00537
00538 void computeTransfo(const SbVec2f &refPoint, SoMatrixTransform *transfo,
00539 float &deltaX, float &deltaY) ;
00540
00541
00542 void getDateAxisRep(const PiDate &date_min, const PiDate &date_max,
00543 Tdate_axis_rep &date_rep) ;
00544
00545
00546 static void copyDateRep(Tdate_axis_rep &dst_date_rep,
00547 const Tdate_axis_rep &src_date_rep) ;
00548
00549
00550 static void initDateStepOfLevel0(Tdate_axis_rep &date_rep, const PiDate &date_delta) ;
00551
00552
00553 static void initDateElem(Tdate_axis_level_rep &level_rep) ;
00554
00555
00556 static void initDateNumStep(Tdate_axis_level_rep &level_rep, const PiDate &date_delta) ;
00557
00558
00559 static void freeDateAxisRep(Tdate_axis_rep &axis_rep) ;
00560
00561
00562 static void freeDateAxisRepList(int num_axis_rep, Tdate_axis_rep *axis_rep_list) ;
00563
00564
00565 void initAutoRep(const PiDate &date_delta, Tdate_axis_rep &date_rep) ;
00566
00567
00568 void chooseBestDateRep(int num_rep, const Tdate_axis_rep *rep,
00569 const PiDate &date_delta, Tdate_axis_rep &date_rep) ;
00570
00571
00572 void getGradList(const PiDate &date_1, const PiDate &date_2,
00573 GradFit grad_fit,
00574 const Tdate_axis_level_rep &level_rep,
00575 int &num_gradu, char ***gradu_string_list,
00576 std::vector<float>& x_gradu_list) ;
00577
00578
00579 void getFirstDateGrad(const PiDate &date_1, const PiDate &date_2,
00580 Tdate_step step, float float_step, GradFit
00581 grad_fit, PiDate &date_ref) ;
00582
00583
00584 void getStringDate(const PiDate &date, int form_prefixe,
00585 Tdate_elem_form form, char *string_date) ;
00586
00587
00588 void buildDateGrads(const PiDate &date_1, const PiDate &date_2,
00589 const Tdate_axis_rep &date_rep, SoGroup *group) ;
00590
00591
00592
00593 void setDateAxisRep() ;
00594
00595
00596 static void parseDateList(char *form, Tdate_list *dl, int *err_ind) ;
00597 static void parseDateListNewDate(double num_units, int units) ;
00598 static Tdate_list *date_list ;
00599 friend int tpdlparse(void);
00600 friend int tpdllex(void) ;
00601
00602
00603 static void parseAxisRep(char *form, int n_l, Tdate_axis_rep *da_rep,
00604 int *err_ind) ;
00605 static void parseAxisRepNewLevel(double num_step, int step, char *append_str) ;
00606 static void parseAxisRepAddToLevel(int form_prefixe, int form, char *append_str) ;
00607 static Tdate_axis_rep *date_axis_rep ;
00608 friend int tpaxparse(void) ;
00609 friend int tpaxlex(void) ;
00610
00611
00612 TimeAxisAttr timeAxisAttr ;
00613
00614
00615 PbDateFormatMapping *m_dateFormatMapping, m_defaultDateFormatMapping ;
00616
00617
00618 FieldSensorList fieldSensorList ;
00619
00620
00621 SoFieldList fieldList ;
00622
00623 } ;
00624
00625
00626
00627 #endif
00628
00629