comparison libinterp/dldfcn/__init_fltk__.cc @ 19895:19755f4fc851

maint: Cleanup C++ code to follow Octave coding conventions. Try to wrap long lines to < 80 characters. Use GNU style and don't indent first brace of function definition. "case" statement is aligned flush left with brace of switch stmt. Remove trailing '\' line continuation from the end of #define macros. Use 2 spaces for indent. * files-dock-widget.cc, history-dock-widget.cc, main-window.cc, octave-cmd.cc, octave-dock-widget.cc, octave-gui.cc, resource-manager.cc, settings-dialog.cc, shortcut-manager.cc, welcome-wizard.cc, workspace-view.cc, cellfun.cc, data.cc, debug.cc, debug.h, dirfns.cc, error.h, file-io.cc, gl-render.cc, gl-render.h, gl2ps-renderer.h, graphics.cc, graphics.in.h, help.cc, input.cc, load-path.cc, load-path.h, lookup.cc, lu.cc, oct-stream.cc, octave-default-image.h, ordschur.cc, pr-output.cc, qz.cc, strfns.cc, symtab.cc, symtab.h, sysdep.cc, variables.cc, zfstream.h, __fltk_uigetfile__.cc, __init_fltk__.cc, __magick_read__.cc, __osmesa_print__.cc, audiodevinfo.cc, ov-classdef.cc, ov-classdef.h, ov-fcn.h, ov-float.cc, ov-flt-complex.cc, ov-java.cc, ov-range.cc, ov-re-mat.cc, ov-usr-fcn.h, ov.cc, op-int.h, options-usage.h, pt-eval.cc, Array-C.cc, Array-fC.cc, Array.cc, Array.h, PermMatrix.cc, Sparse.cc, chMatrix.h, dSparse.cc, dim-vector.h, bsxfun-decl.h, bsxfun-defs.cc, oct-norm.cc, Sparse-op-defs.h, oct-inttypes.cc, oct-inttypes.h, main.in.cc, mkoctfile.in.cc: Cleanup C++ code to follow Octave coding conventions.
author Rik <rik@octave.org>
date Wed, 25 Feb 2015 11:55:49 -0800
parents a5206dfbaa13
children 6ba3d0f7c6e8
comparison
equal deleted inserted replaced
19894:e8ccfc5d892b 19895:19755f4fc851
649 649
650 class plot_window : public Fl_Window 650 class plot_window : public Fl_Window
651 { 651 {
652 friend class fltk_uimenu; 652 friend class fltk_uimenu;
653 public: 653 public:
654 plot_window (int xx, int yy, int ww, int hh, figure::properties& xfp, bool internal) 654 plot_window (int xx, int yy, int ww, int hh, figure::properties& xfp,
655 bool internal)
655 : Fl_Window (xx, yy, ww, hh + menu_h + status_h + 2, "octave"), 656 : Fl_Window (xx, yy, ww, hh + menu_h + status_h + 2, "octave"),
656 window_label (), fp (xfp), canvas (0), 657 window_label (), fp (xfp), canvas (0),
657 autoscale (0), togglegrid (0), panzoom (0), rotate (0), help (0), 658 autoscale (0), togglegrid (0), panzoom (0), rotate (0), help (0),
658 status (0), resize_dummy (0), ax_obj (), pos_x (0), pos_y (0) 659 status (0), resize_dummy (0), ax_obj (), pos_x (0), pos_y (0)
659 { 660 {
887 init_sizes (); 888 init_sizes ();
888 redraw (); 889 redraw ();
889 } 890 }
890 891
891 Matrix outerposition2position (const Matrix& outerpos) 892 Matrix outerposition2position (const Matrix& outerpos)
892 { 893 {
893 Matrix pos = outerpos; 894 Matrix pos = outerpos;
894 pos(1) += menu_dy (); 895 pos(1) += menu_dy ();
895 pos(3) -= menu_dy () + status_h + 2; 896 pos(3) -= menu_dy () + status_h + 2;
896 return pos; 897 return pos;
897 } 898 }
898 899
899 Matrix position2outerposition (const Matrix& pos) 900 Matrix position2outerposition (const Matrix& pos)
900 { 901 {
901 Matrix outerpos = pos; 902 Matrix outerpos = pos;
902 outerpos(1) -= menu_dy (); 903 outerpos(1) -= menu_dy ();
903 outerpos(3) += menu_dy () + status_h + 2; 904 outerpos(3) += menu_dy () + status_h + 2;
904 return outerpos; 905 return outerpos;
905 } 906 }
906 907
907 // Called from figure::properties::ID_POSITION if internal = true 908 // Called from figure::properties::ID_POSITION if internal = true
908 // or ID_OUTERPOSITION if false. 909 // or ID_OUTERPOSITION if false.
909 // (someone has requested a position change with set (h, "position", [...]) 910 // (someone has requested a position change with set (h, "position", [...])
910 // or set (h, "outerposition", [...]) 911 // or set (h, "outerposition", [...])
1435 return 1; 1436 return 1;
1436 } 1437 }
1437 break; 1438 break;
1438 } 1439 }
1439 1440
1440 // Events we only handle if they are in the canvas area. 1441 // Events we only handle if they are in the canvas area.
1441 if (Fl::event_inside (canvas)) 1442 if (Fl::event_inside (canvas))
1442 switch (event) 1443 switch (event)
1443 {
1444 case FL_MOVE:
1445 pixel2status (pixel2axes_or_ca (Fl::event_x (),
1446 Fl::event_y () - menu_dy ()),
1447 Fl::event_x (), Fl::event_y () - menu_dy ());
1448 return 1;
1449
1450 case FL_PUSH:
1451 pos_x = Fl::event_x ();
1452 pos_y = Fl::event_y () - menu_dy ();
1453
1454 set_currentpoint (pos_x, pos_y);
1455
1456 if (Fl::event_button () == FL_LEFT_MOUSE
1457 && Fl::event_shift ())
1458 fp.set_selectiontype ("extend");
1459 else if ((Fl::event_button () == FL_LEFT_MOUSE
1460 && Fl::event_ctrl ())
1461 || Fl::event_button () == FL_RIGHT_MOUSE)
1462 fp.set_selectiontype ("alternate");
1463 else if (Fl::event_clicks ())
1464 fp.set_selectiontype ("open");
1465 else
1466 fp.set_selectiontype ("normal");
1467
1468 if (fp.get_windowbuttondownfcn ().is_defined ())
1469 fp.execute_windowbuttondownfcn (Fl::event_button ());
1470
1471 gh = pixel2axes_or_ca (pos_x, pos_y);
1472
1473 if (gh.ok ())
1474 {
1475 ax_obj = gh_manager::get_object (gh);
1476 set_axes_currentpoint (ax_obj, pos_x, pos_y);
1477
1478 int ndim = calc_dimensions (ax_obj);
1479
1480 if (ndim == 3)
1481 rotate->activate ();
1482 else // ndim == 2
1483 rotate->deactivate ();
1484
1485 fp.set_currentobject (ax_obj.get_handle ().value ());
1486
1487 base_properties& props = ax_obj.get_properties ();
1488 if (props.get_buttondownfcn ().is_defined ())
1489 props.execute_buttondownfcn (Fl::event_button ());
1490
1491 return 1;
1492 }
1493 else if (fp.get_buttondownfcn ().is_defined ())
1494 fp.execute_buttondownfcn (Fl::event_button ());
1495
1496 break;
1497
1498 case FL_DRAG:
1499 if (fp.get_windowbuttonmotionfcn ().is_defined ())
1500 {
1501 set_currentpoint (Fl::event_x (), Fl::event_y () - menu_dy ());
1502 fp.execute_windowbuttonmotionfcn ();
1503 }
1504
1505 if (Fl::event_button () == 1)
1506 {
1507 if (ax_obj && ax_obj.isa ("axes"))
1508 {
1509 axes::properties& ap =
1510 dynamic_cast<axes::properties&>
1511 (ax_obj.get_properties ());
1512
1513 // Don't pan or rotate legend
1514 if (ap.get_tag ().compare ("legend") < 0)
1515 {
1516 if (rotate_enabled ())
1517 view2status (ax_obj);
1518 else
1519 pixel2status (ax_obj, pos_x, pos_y,
1520 Fl::event_x (),
1521 Fl::event_y () - menu_dy ());
1522
1523 double x0, y0, x1, y1;
1524 Matrix pos = fp.get_boundingbox (true);
1525 pixel2pos (ax_obj, pos_x, pos_y, x0, y0);
1526 pixel2pos (ax_obj, Fl::event_x (),
1527 Fl::event_y () - menu_dy (),
1528 x1, y1);
1529
1530 if (pan_enabled ())
1531 ap.translate_view ("both", x0, x1, y0, y1);
1532 else if (rotate_enabled ())
1533 {
1534 double daz, del;
1535 daz = (Fl::event_x () - pos_x) / pos(2) * 360;
1536 del = (Fl::event_y () - menu_dy () - pos_y)
1537 / pos(3) * 360;
1538 ap.rotate_view (del, daz);
1539 }
1540 }
1541 else
1542 { // move the position of the legend
1543 Matrix pos = ap.get_position ().matrix_value ();
1544 pos(0) += double (Fl::event_x () - pos_x)
1545 / canvas->w ();
1546 pos(1) -= double (Fl::event_y () - menu_dy () - pos_y)
1547 / canvas->h ();
1548 ap.set_position (pos);
1549 }
1550
1551 pos_x = Fl::event_x ();
1552 pos_y = Fl::event_y () - menu_dy ();
1553 mark_modified ();
1554 }
1555 return 1;
1556 }
1557 else if (Fl::event_button () == 3)
1558 {
1559 pixel2status (ax_obj, pos_x, pos_y,
1560 Fl::event_x (), Fl::event_y () - menu_dy ());
1561 Matrix zoom_box (1,4,0);
1562 zoom_box (0) = pos_x;
1563 zoom_box (1) = pos_y;
1564 zoom_box (2) = Fl::event_x ();
1565 zoom_box (3) = Fl::event_y () - menu_dy ();
1566 canvas->set_zoom_box (zoom_box);
1567 canvas->zoom (true);
1568 mark_modified ();
1569 return 1;
1570 }
1571
1572 break;
1573
1574 case FL_MOUSEWHEEL:
1575 { 1444 {
1576 graphics_object ax = 1445 case FL_MOVE:
1577 gh_manager::get_object (pixel2axes_or_ca (Fl::event_x (), 1446 pixel2status (pixel2axes_or_ca (Fl::event_x (),
1578 Fl::event_y () 1447 Fl::event_y () - menu_dy ()),
1579 - menu_dy ())); 1448 Fl::event_x (), Fl::event_y () - menu_dy ());
1580 if (ax && ax.isa ("axes")) 1449 return 1;
1450
1451 case FL_PUSH:
1452 pos_x = Fl::event_x ();
1453 pos_y = Fl::event_y () - menu_dy ();
1454
1455 set_currentpoint (pos_x, pos_y);
1456
1457 if (Fl::event_button () == FL_LEFT_MOUSE
1458 && Fl::event_shift ())
1459 fp.set_selectiontype ("extend");
1460 else if ((Fl::event_button () == FL_LEFT_MOUSE
1461 && Fl::event_ctrl ())
1462 || Fl::event_button () == FL_RIGHT_MOUSE)
1463 fp.set_selectiontype ("alternate");
1464 else if (Fl::event_clicks ())
1465 fp.set_selectiontype ("open");
1466 else
1467 fp.set_selectiontype ("normal");
1468
1469 if (fp.get_windowbuttondownfcn ().is_defined ())
1470 fp.execute_windowbuttondownfcn (Fl::event_button ());
1471
1472 gh = pixel2axes_or_ca (pos_x, pos_y);
1473
1474 if (gh.ok ())
1581 { 1475 {
1582 axes::properties& ap = 1476 ax_obj = gh_manager::get_object (gh);
1583 dynamic_cast<axes::properties&> (ax.get_properties ()); 1477 set_axes_currentpoint (ax_obj, pos_x, pos_y);
1584 1478
1585 // Control how fast to zoom when using scroll wheel. 1479 int ndim = calc_dimensions (ax_obj);
1586 double wheel_zoom_speed = ap.get_mousewheelzoom (); 1480
1587 1481 if (ndim == 3)
1588 // Determine if we're zooming in or out. 1482 rotate->activate ();
1589 const double factor = 1483 else // ndim == 2
1590 (Fl::event_dy () > 0) ? 1 / (1.0 - wheel_zoom_speed) 1484 rotate->deactivate ();
1591 : 1.0 - wheel_zoom_speed; 1485
1592 1486 fp.set_currentobject (ax_obj.get_handle ().value ());
1593 // Get the point we're zooming about. 1487
1594 double x1, y1; 1488 base_properties& props = ax_obj.get_properties ();
1595 pixel2pos (ax, Fl::event_x (), Fl::event_y () - menu_dy (), 1489 if (props.get_buttondownfcn ().is_defined ())
1596 x1, y1); 1490 props.execute_buttondownfcn (Fl::event_button ());
1597 1491
1598 ap.zoom_about_point ("both", x1, y1, factor, false); 1492 return 1;
1493 }
1494 else if (fp.get_buttondownfcn ().is_defined ())
1495 fp.execute_buttondownfcn (Fl::event_button ());
1496
1497 break;
1498
1499 case FL_DRAG:
1500 if (fp.get_windowbuttonmotionfcn ().is_defined ())
1501 {
1502 set_currentpoint (Fl::event_x (), Fl::event_y () - menu_dy ());
1503 fp.execute_windowbuttonmotionfcn ();
1504 }
1505
1506 if (Fl::event_button () == 1)
1507 {
1508 if (ax_obj && ax_obj.isa ("axes"))
1509 {
1510 axes::properties& ap =
1511 dynamic_cast<axes::properties&>
1512 (ax_obj.get_properties ());
1513
1514 // Don't pan or rotate legend
1515 if (ap.get_tag ().compare ("legend") < 0)
1516 {
1517 if (rotate_enabled ())
1518 view2status (ax_obj);
1519 else
1520 pixel2status (ax_obj, pos_x, pos_y,
1521 Fl::event_x (),
1522 Fl::event_y () - menu_dy ());
1523
1524 double x0, y0, x1, y1;
1525 Matrix pos = fp.get_boundingbox (true);
1526 pixel2pos (ax_obj, pos_x, pos_y, x0, y0);
1527 pixel2pos (ax_obj, Fl::event_x (),
1528 Fl::event_y () - menu_dy (),
1529 x1, y1);
1530
1531 if (pan_enabled ())
1532 ap.translate_view ("both", x0, x1, y0, y1);
1533 else if (rotate_enabled ())
1534 {
1535 double daz, del;
1536 daz = (Fl::event_x () - pos_x) / pos(2) * 360;
1537 del = (Fl::event_y () - menu_dy () - pos_y)
1538 / pos(3) * 360;
1539 ap.rotate_view (del, daz);
1540 }
1541 }
1542 else
1543 {
1544 // move the position of the legend
1545 Matrix pos = ap.get_position ().matrix_value ();
1546 pos(0) += double (Fl::event_x () - pos_x)
1547 / canvas->w ();
1548 pos(1) -= double (Fl::event_y () - menu_dy () - pos_y)
1549 / canvas->h ();
1550 ap.set_position (pos);
1551 }
1552
1553 pos_x = Fl::event_x ();
1554 pos_y = Fl::event_y () - menu_dy ();
1555 mark_modified ();
1556 }
1557 return 1;
1558 }
1559 else if (Fl::event_button () == 3)
1560 {
1561 pixel2status (ax_obj, pos_x, pos_y,
1562 Fl::event_x (), Fl::event_y () - menu_dy ());
1563 Matrix zoom_box (1,4,0);
1564 zoom_box (0) = pos_x;
1565 zoom_box (1) = pos_y;
1566 zoom_box (2) = Fl::event_x ();
1567 zoom_box (3) = Fl::event_y () - menu_dy ();
1568 canvas->set_zoom_box (zoom_box);
1569 canvas->zoom (true);
1599 mark_modified (); 1570 mark_modified ();
1600 return 1; 1571 return 1;
1601 } 1572 }
1602 } 1573
1603 1574 break;
1604 case FL_RELEASE: 1575
1605 if (fp.get_windowbuttonupfcn ().is_defined ()) 1576 case FL_MOUSEWHEEL:
1606 { 1577 {
1607 set_currentpoint (Fl::event_x (), Fl::event_y () - menu_dy ()); 1578 graphics_object ax =
1608 fp.execute_windowbuttonupfcn (); 1579 gh_manager::get_object (pixel2axes_or_ca (Fl::event_x (),
1609 } 1580 Fl::event_y ()
1610 1581 - menu_dy ()));
1611 if ((Fl::event_button () == 1) && Fl::event_clicks ()) 1582 if (ax && ax.isa ("axes"))
1612 {
1613 // Double click
1614 set_on_ax_obj ("xlimmode", "auto");
1615 set_on_ax_obj ("ylimmode", "auto");
1616 set_on_ax_obj ("zlimmode", "auto");
1617 return 1;
1618 }
1619 if (Fl::event_button () == 3)
1620 {
1621 // End of drag -- zoom.
1622 if (canvas->zoom ())
1623 { 1583 {
1624 canvas->zoom (false); 1584 axes::properties& ap =
1625 double x0,y0,x1,y1; 1585 dynamic_cast<axes::properties&> (ax.get_properties ());
1626 if (ax_obj && ax_obj.isa ("axes")) 1586
1627 { 1587 // Control how fast to zoom when using scroll wheel.
1628 axes::properties& ap = dynamic_cast<axes::properties&> 1588 double wheel_zoom_speed = ap.get_mousewheelzoom ();
1629 (ax_obj.get_properties ()); 1589
1630 pixel2pos (ax_obj, pos_x, pos_y, x0, y0); 1590 // Determine if we're zooming in or out.
1631 int pos_x1 = Fl::event_x (); 1591 const double factor =
1632 int pos_y1 = Fl::event_y () - menu_dy (); 1592 (Fl::event_dy () > 0) ? 1 / (1.0 - wheel_zoom_speed)
1633 pixel2pos (ax_obj, pos_x1, pos_y1, x1, y1); 1593 : 1.0 - wheel_zoom_speed;
1634 Matrix xl (1,2,0); 1594
1635 Matrix yl (1,2,0); 1595 // Get the point we're zooming about.
1636 int dx = abs (pos_x - pos_x1); 1596 double x1, y1;
1637 int dy = abs (pos_y - pos_y1); 1597 pixel2pos (ax, Fl::event_x (), Fl::event_y () - menu_dy (),
1638 // Smallest zoom box must be 4 pixels square 1598 x1, y1);
1639 if ((dx > 4) && (dy > 4)) 1599
1640 { 1600 ap.zoom_about_point ("both", x1, y1, factor, false);
1641 if (x0 < x1) 1601 mark_modified ();
1642 { 1602 return 1;
1643 xl(0) = x0;
1644 xl(1) = x1;
1645 }
1646 else
1647 {
1648 xl(0) = x1;
1649 xl(1) = x0;
1650 }
1651 if (y0 < y1)
1652 {
1653 yl(0) = y0;
1654 yl(1) = y1;
1655 }
1656 else
1657 {
1658 yl(0) = y1;
1659 yl(1) = y0;
1660 }
1661 ap.zoom ("both", xl, yl);
1662 }
1663 mark_modified ();
1664 return 1;
1665 }
1666 } 1603 }
1667 } 1604 }
1668 break; 1605
1669 } 1606 case FL_RELEASE:
1607 if (fp.get_windowbuttonupfcn ().is_defined ())
1608 {
1609 set_currentpoint (Fl::event_x (), Fl::event_y () - menu_dy ());
1610 fp.execute_windowbuttonupfcn ();
1611 }
1612
1613 if ((Fl::event_button () == 1) && Fl::event_clicks ())
1614 {
1615 // Double click
1616 set_on_ax_obj ("xlimmode", "auto");
1617 set_on_ax_obj ("ylimmode", "auto");
1618 set_on_ax_obj ("zlimmode", "auto");
1619 return 1;
1620 }
1621 if (Fl::event_button () == 3)
1622 {
1623 // End of drag -- zoom.
1624 if (canvas->zoom ())
1625 {
1626 canvas->zoom (false);
1627 double x0,y0,x1,y1;
1628 if (ax_obj && ax_obj.isa ("axes"))
1629 {
1630 axes::properties& ap = dynamic_cast<axes::properties&>
1631 (ax_obj.get_properties ());
1632 pixel2pos (ax_obj, pos_x, pos_y, x0, y0);
1633 int pos_x1 = Fl::event_x ();
1634 int pos_y1 = Fl::event_y () - menu_dy ();
1635 pixel2pos (ax_obj, pos_x1, pos_y1, x1, y1);
1636 Matrix xl (1,2,0);
1637 Matrix yl (1,2,0);
1638 int dx = abs (pos_x - pos_x1);
1639 int dy = abs (pos_y - pos_y1);
1640 // Smallest zoom box must be 4 pixels square
1641 if ((dx > 4) && (dy > 4))
1642 {
1643 if (x0 < x1)
1644 {
1645 xl(0) = x0;
1646 xl(1) = x1;
1647 }
1648 else
1649 {
1650 xl(0) = x1;
1651 xl(1) = x0;
1652 }
1653 if (y0 < y1)
1654 {
1655 yl(0) = y0;
1656 yl(1) = y1;
1657 }
1658 else
1659 {
1660 yl(0) = y1;
1661 yl(1) = y0;
1662 }
1663 ap.zoom ("both", xl, yl);
1664 }
1665 mark_modified ();
1666 return 1;
1667 }
1668 }
1669 }
1670 break;
1671 }
1670 } 1672 }
1671 //std::cout << "plot_window::handle wasn't interested in event " << fl_eventnames[event] << std::endl; 1673 //std::cout << "plot_window::handle wasn't interested in event " << fl_eventnames[event] << std::endl;
1672 return Fl_Window::handle (event); 1674 return Fl_Window::handle (event);
1673 } 1675 }
1674 }; 1676 };
1855 pos = fp.get_boundingbox (internal); 1857 pos = fp.get_boundingbox (internal);
1856 } 1858 }
1857 1859
1858 idx2figprops (curr_index, fp); 1860 idx2figprops (curr_index, fp);
1859 1861
1860 windows[curr_index++] = new plot_window (pos(0), pos(1), pos(2), pos(3), fp, internal); 1862 windows[curr_index++] = new plot_window (pos(0), pos(1), pos(2), pos(3),
1863 fp, internal);
1861 } 1864 }
1862 } 1865 }
1863 1866
1864 void do_delete_window (int idx) 1867 void do_delete_window (int idx)
1865 { 1868 {