comparison src/graphics.h.in @ 10135:4516a0c97ced

Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
author David Bateman <dbateman@free.fr>
date Wed, 20 Jan 2010 02:52:22 +0100
parents b5cc666da6ca
children 6a88b00c5ad6
comparison
equal deleted inserted replaced
10134:be13fa20656a 10135:4516a0c97ced
508 return false; 508 return false;
509 } 509 }
510 510
511 private: 511 private:
512 std::string str; 512 std::string str;
513 };
514
515 // ---------------------------------------------------------------------
516
517 class string_array_property : public base_property
518 {
519 public:
520 enum desired_enum { string_t, cell_t };
521
522 string_array_property (const std::string& s, const graphics_handle& h,
523 const std::string& val = "", const char& sep = '|',
524 const desired_enum& typ = string_t)
525 : base_property (s, h), desired_type (typ), separator (sep)
526 {
527 size_t pos = 0;
528
529 while (true)
530 {
531 size_t new_pos = val.find_first_of (separator, pos);
532
533 if (new_pos == std::string::npos)
534 {
535 str.append (val.substr (pos));
536 break;
537 }
538 else
539 str.append (val.substr (pos, new_pos - pos));
540
541 pos = new_pos + 1;
542 }
543 }
544
545 string_array_property (const std::string& s, const graphics_handle& h,
546 const Cell& c, const char& sep = '|',
547 const desired_enum& typ = string_t)
548 : base_property (s, h), desired_type (typ), separator (sep)
549 {
550 if (c.is_cellstr ())
551 {
552 string_vector strings (c.numel ());
553
554 for (octave_idx_type i = 0; i < c.numel (); i++)
555 strings (i) = c(i).string_value ();
556
557 str = strings;
558 }
559 else
560 error ("set: invalid order property value for \"%s\"",
561 get_name ().c_str ());
562 }
563
564 string_array_property (const string_array_property& p)
565 : base_property (p), desired_type (p.desired_type),
566 separator (p.separator), str (p.str) { }
567
568 octave_value get (void) const
569 {
570 if (desired_type == string_t)
571 return octave_value (string_value ());
572 else
573 return octave_value (cell_value ());
574 }
575
576 std::string string_value (void) const
577 {
578 std::string _str;
579
580 for (octave_idx_type i = 0; i < str.length (); i++)
581 {
582 _str += str(i);
583 if (i != str.length() - 1)
584 _str += separator;
585 }
586
587 return _str;
588 }
589
590 Cell cell_value (void) const {return Cell (str);}
591
592 string_array_property& operator = (const octave_value& val)
593 {
594 set (val);
595 return *this;
596 }
597
598 base_property* clone (void) const { return new string_array_property (*this); }
599
600 protected:
601 bool do_set (const octave_value& val)
602 {
603 if (val.is_string ())
604 {
605 bool replace = false;
606 std::string new_str = val.string_value ();
607 string_vector strings;
608 size_t pos = 0;
609
610 while (pos != std::string::npos)
611 {
612 size_t new_pos = new_str.find_first_of (separator, pos);
613
614 if (new_pos == std::string::npos)
615 {
616 strings.append (new_str.substr (pos));
617 break;
618 }
619 else
620 strings.append (new_str.substr (pos, new_pos - pos));
621
622 pos = new_pos + 1;
623 }
624
625 if (str.numel () == strings.numel ())
626 {
627 for (octave_idx_type i = 0; i < str.numel (); i++)
628 if (strings (i) != str(i))
629 {
630 replace = true;
631 break;
632 }
633 }
634 else
635 replace = true;
636
637 if (replace)
638 {
639 str = strings;
640 return true;
641 }
642 }
643 else if (val.is_cellstr ())
644 {
645 bool replace = false;
646 Cell new_cell = val.cell_value ();
647
648 string_vector strings (new_cell.numel ());
649
650 for (octave_idx_type i = 0; i < new_cell.numel (); i++)
651 {
652 strings (i) = new_cell(i).string_value ();
653 if (strings (i) != str (i))
654 replace = true;
655 }
656
657 if (replace)
658 {
659 str = strings;
660 return true;
661 }
662 }
663 else
664 error ("set: invalid string property value for \"%s\"",
665 get_name ().c_str ());
666 return false;
667 }
668
669 private:
670 desired_enum desired_type;
671 char separator;
672 string_vector str;
513 }; 673 };
514 674
515 // --------------------------------------------------------------------- 675 // ---------------------------------------------------------------------
516 676
517 class radio_values 677 class radio_values
2759 string_property fontname , OCTAVE_DEFAULT_FONTNAME 2919 string_property fontname , OCTAVE_DEFAULT_FONTNAME
2760 double_property fontsize , 12 2920 double_property fontsize , 12
2761 radio_property fontunits , "{points}|normalized|inches|centimeters|pixels" 2921 radio_property fontunits , "{points}|normalized|inches|centimeters|pixels"
2762 radio_property fontweight , "{normal}|light|demi|bold" 2922 radio_property fontweight , "{normal}|light|demi|bold"
2763 radio_property gridlinestyle , "-|--|{:}|-.|none" 2923 radio_property gridlinestyle , "-|--|{:}|-.|none"
2764 // FIXME -- should be kind of string array. 2924 string_array_property linestyleorder , "-"
2765 string_property linestyleorder , "-"
2766 double_property linewidth , 0.5 2925 double_property linewidth , 0.5
2767 // FIXME -- should be kind of string array.
2768 string_property markerorder , "+o*xsd^vh."
2769 radio_property minorgridlinestyle , "-|--|{:}|-.|none" 2926 radio_property minorgridlinestyle , "-|--|{:}|-.|none"
2770 array_property plotboxaspectratio m , Matrix (1, 3, 1.0) 2927 array_property plotboxaspectratio m , Matrix (1, 3, 1.0)
2771 radio_property plotboxaspectratiomode , "{auto}|manual" 2928 radio_property plotboxaspectratiomode , "{auto}|manual"
2772 radio_property projection , "{orthographic}|perpective" 2929 radio_property projection , "{orthographic}|perpective"
2773 radio_property tickdir m , "{in}|out" 2930 radio_property tickdir m , "{in}|out"