daily pastebin goal
15%
SHARE
TWEET

vpaint build-run

a guest May 8th, 2016 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Copyright (C) 2012-2016 The VPaint Developers.
  2. // See the COPYRIGHT file at the top-level directory of this distribution
  3. // and at https://github.com/dalboris/vpaint/blob/master/COPYRIGHT
  4. //
  5. // This file is part of VPaint, a vector graphics editor. It is subject to the
  6. // license terms and conditions in the LICENSE.MIT file found in the top-level
  7. // directory of this distribution and at http://opensource.org/licenses/MIT
  8.  
  9. #include "ViewSettings.h"
  10.  
  11. ViewSettings::ViewSettings() :
  12.     // Display
  13.     zoom_(1.0),
  14.     displayMode_(ILLUSTRATION),
  15.     outlineOnly_(false),
  16.     drawBackground_(true),
  17.     drawCursor_(true),
  18.     isMainDrawing_(true),
  19.     vertexTopologySize_(5),
  20.     edgeTopologyWidth_(3),
  21.     drawTopologyFaces_(false),
  22.     screenRelative_(true),
  23.  
  24.     time_(),
  25.  
  26.     // Onion skinning
  27.     onionSkinningIsEnabled_(false),
  28.     areOnionSkinsPickable_(true),
  29.     numOnionSkinsBefore_(3),
  30.     numOnionSkinsAfter_(3),
  31.     onionSkinsTimeOffset_(Time(1)),
  32.     onionSkinsXOffset_(0.0),
  33.     onionSkinsYOffset_(0.0),
  34.     onionSkinsTransparencyRatio_(1.0)
  35. {
  36. }
  37.  
  38. ViewSettings::~ViewSettings()
  39. {
  40. }
  41.  
  42.  
  43. Time ViewSettings::time() const
  44. {
  45.     return time_;
  46. }
  47.  
  48. void ViewSettings::setTime(const Time & t)
  49. {
  50.     time_ = t;
  51. }
  52.  
  53. // Zoom level
  54. double ViewSettings::zoom() const
  55. {
  56.     return zoom_;
  57. }
  58. void ViewSettings::setZoom(double newValue)
  59. {
  60.     if(zoom_ != newValue)
  61.     {
  62.         zoom_ = newValue;
  63.     }
  64. }
  65.  
  66. ViewSettings::DisplayMode ViewSettings::displayMode() const
  67. {
  68.     return displayMode_;
  69. }
  70. void ViewSettings::setDisplayMode(DisplayMode mode)
  71. {
  72.     if(displayMode_ != mode)
  73.     {
  74.         displayMode_ = mode;
  75.     }
  76. }
  77.  
  78. void ViewSettings::toggleOutline()
  79. {
  80.     if(displayMode() == ILLUSTRATION)
  81.     {
  82.         if(outlineOnly_)
  83.             setDisplayMode(OUTLINE);
  84.         else
  85.             setDisplayMode(ILLUSTRATION_OUTLINE);
  86.     }
  87.     else
  88.         setDisplayMode(ILLUSTRATION);
  89. }
  90.  
  91. void ViewSettings::toggleOutlineOnly()
  92. {
  93.     if(displayMode() != ILLUSTRATION)
  94.     {
  95.         outlineOnly_ = !outlineOnly_;
  96.         if(outlineOnly_)
  97.             setDisplayMode(OUTLINE);
  98.         else
  99.             setDisplayMode(ILLUSTRATION_OUTLINE);
  100.     }
  101. }
  102.  
  103. bool ViewSettings::drawCursor() const
  104. {
  105.     return drawCursor_;
  106. }
  107. void ViewSettings::setDrawCursor(bool newValue)
  108. {
  109.     drawCursor_ = newValue;
  110. }
  111.  
  112. bool ViewSettings::isMainDrawing() const
  113. {
  114.     return isMainDrawing_;
  115. }
  116. void ViewSettings::setMainDrawing(bool newValue)
  117. {
  118.     if(isMainDrawing_ != newValue)
  119.     {
  120.         isMainDrawing_ = newValue;
  121.     }
  122. }
  123.  
  124. int ViewSettings::vertexTopologySize() const
  125. {
  126.     return vertexTopologySize_;
  127. }
  128. void ViewSettings::setVertexTopologySize(int newValue)
  129. {
  130.     if(vertexTopologySize_ != newValue)
  131.     {
  132.         vertexTopologySize_ = newValue;
  133.     }
  134. }
  135.  
  136. int ViewSettings::edgeTopologyWidth() const
  137. {
  138.     return edgeTopologyWidth_;
  139. }
  140. void ViewSettings::setEdgeTopologyWidth(int newValue)
  141. {
  142.     if(edgeTopologyWidth_ != newValue)
  143.     {
  144.         edgeTopologyWidth_ = newValue;
  145.     }
  146. }
  147.  
  148. bool ViewSettings::drawTopologyFaces() const
  149. {
  150.     return drawTopologyFaces_;
  151. }
  152. void ViewSettings::setDrawTopologyFaces(bool newValue)
  153. {
  154.     if(drawTopologyFaces_ != newValue)
  155.     {
  156.         drawTopologyFaces_ = newValue;
  157.     }
  158. }
  159.  
  160. bool ViewSettings::screenRelative() const
  161. {
  162.     return screenRelative_;
  163. }
  164. void ViewSettings::setScreenRelative(bool newValue)
  165. {
  166.     if(screenRelative_ != newValue)
  167.     {
  168.         screenRelative_ = newValue;
  169.     }
  170. }
  171.  
  172.  
  173.  
  174.  
  175.  
  176. bool ViewSettings::onionSkinningIsEnabled() const
  177. {
  178.     return onionSkinningIsEnabled_;
  179. }
  180. void ViewSettings::setOnionSkinningIsEnabled(bool newValue)
  181. {
  182.     onionSkinningIsEnabled_ = newValue;
  183. }
  184.  
  185. bool ViewSettings::areOnionSkinsPickable() const
  186. {
  187.     return areOnionSkinsPickable_;
  188. }
  189. void ViewSettings::setAreOnionSkinsPickable(bool newValue)
  190. {
  191.     areOnionSkinsPickable_ = newValue;
  192. }
  193.  
  194. int ViewSettings::numOnionSkinsBefore() const
  195. {
  196.     return numOnionSkinsBefore_;
  197. }
  198. void ViewSettings::setNumOnionSkinsBefore(int newValue)
  199. {
  200.     numOnionSkinsBefore_ = newValue;
  201. }
  202.  
  203. int ViewSettings::numOnionSkinsAfter() const
  204. {
  205.     return numOnionSkinsAfter_;
  206. }
  207. void ViewSettings::setNumOnionSkinsAfter(int newValue)
  208. {
  209.     numOnionSkinsAfter_ = newValue;
  210. }
  211.  
  212. Time ViewSettings::onionSkinsTimeOffset() const
  213. {
  214.     return onionSkinsTimeOffset_;
  215. }
  216. void ViewSettings::setOnionSkinsTimeOffset(Time newValue)
  217. {
  218.     onionSkinsTimeOffset_ = newValue;
  219. }
  220.  
  221. void ViewSettings::setOnionSkinsTimeOffset(double newValue)
  222. {
  223.     int intValue = newValue;
  224.     if(newValue == (double) intValue)
  225.         onionSkinsTimeOffset_ = Time(intValue); // Exact frame
  226.     else
  227.         onionSkinsTimeOffset_ = Time(newValue); // float time
  228. }
  229.  
  230. double ViewSettings::onionSkinsXOffset() const
  231. {
  232.     return onionSkinsXOffset_;
  233. }
  234. void ViewSettings::setOnionSkinsXOffset(double newValue)
  235. {
  236.     onionSkinsXOffset_ = newValue;
  237. }
  238.  
  239. double ViewSettings::onionSkinsYOffset() const
  240. {
  241.     return onionSkinsYOffset_;
  242. }
  243. void ViewSettings::setOnionSkinsYOffset(double newValue)
  244. {
  245.     onionSkinsYOffset_ = newValue;
  246. }
  247.  
  248. double ViewSettings::onionSkinsTransparencyRatio() const
  249. {
  250.     return onionSkinsTransparencyRatio_;
  251. }
  252. void ViewSettings::setOnionSkinsTransparencyRatio(double newValue)
  253. {
  254.     onionSkinsTransparencyRatio_ = newValue;
  255. }
  256.  
  257. #include <QWidgetAction>
  258. #include <QMenuBar>
  259. #include <QMenu>
  260. #include <QLabel>
  261. #include <QComboBox>
  262. #include <QPushButton>
  263. #include <QLineEdit>
  264.  
  265. ViewSettingsWidget::ViewSettingsWidget(ViewSettings & viewSettings, QWidget * parent) :
  266.     QWidget(parent),
  267.     viewSettings_(viewSettings),
  268.     ignoreZoomValueChangedSignal_(false)
  269. {
  270.     // ----------------- MacOS X style ------------------------
  271.  
  272. #ifdef Q_OS_MAC
  273.     // Set style
  274.     setAutoFillBackground(true);
  275.     setCursor(Qt::ArrowCursor);
  276.     buttonSize = 48;
  277.  
  278.     /* THE FOLLOWING ARE NOT IMPLEMENTED OR DEEMED IRRELEVANT
  279.     screenRelative_ = new QCheckBox();
  280.     onionSkinsTransparencyRatio_ = new QDoubleSpinBox();
  281.     onionSkinsTransparencyRatio_->setRange(0.0,1.0);
  282.     onionSkinsTransparencyRatio_->setDecimals(2);
  283.     */
  284.  
  285.     // Button to show/hide view settings
  286.  
  287.     showHideSettingsButton_ = new QPushButton("");
  288.     showHideSettingsButton_->setToolTip("Show/hide view settings");
  289.     showHideSettingsButton_->setIcon(QIcon(":images/view-settings.png"));
  290.     //showHideSettingsButton_->setIconSize(QSize(32,32));
  291.     showHideSettingsButton_->setCheckable(true);
  292.     showHideSettingsButton_->setChecked(true);
  293.     showHideSettingsButton_->setFixedSize(20,20);
  294.     showHideSettingsButton_->setAttribute(Qt::WA_LayoutUsesWidgetRect);
  295.     connect(showHideSettingsButton_, SIGNAL(toggled(bool)), this, SLOT(toggleVisible(bool)));
  296.  
  297.  
  298.     // View label, frame number, zoom level
  299.  
  300.     //QGridLayout * frameZoomLayout = new QGridLayout();
  301.     //frameZoomLayout->setMargin(0);
  302.     //frameZoomLayout->setSpacing(0);
  303.  
  304.     QPushButton * goToPreviousFrameButton = new QPushButton();
  305.     goToPreviousFrameButton->setFixedSize(20,20);
  306.     goToPreviousFrameButton->setIcon(QIcon(":/images/go-first-view.png"));
  307.     goToPreviousFrameButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
  308.     //frameZoomLayout->addWidget(goToPreviousFrameButton,0,0);
  309.  
  310.     QPushButton * goToNextFrameButton = new QPushButton();
  311.     goToNextFrameButton->setFixedSize(20,20);
  312.     goToNextFrameButton->setIcon(QIcon(":/images/go-last-view.png"));
  313.     goToNextFrameButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
  314.     //frameZoomLayout->addWidget(goToNextFrameButton,0,2);
  315.  
  316.     frameLineEdit_ = new QLineEdit();
  317.     frameLineEdit_->setFixedSize(40,20);
  318.     frameLineEdit_->setAlignment(Qt::AlignCenter);
  319.     frameLineEdit_->setAttribute(Qt::WA_LayoutUsesWidgetRect);
  320.     //frameZoomLayout->addWidget(frameLineEdit_,0,1);
  321.  
  322.     zoomSpinBox_ = new QSpinBox();
  323.     zoomSpinBox_->setRange(1,1e7);
  324.     zoomSpinBox_->setValue(100);
  325.     zoomSpinBox_->setSuffix(" %");
  326.     zoomSpinBox_->setFixedSize(75,20);
  327.     zoomSpinBox_->setAlignment(Qt::AlignCenter);
  328.     zoomSpinBox_->setAttribute(Qt::WA_LayoutUsesWidgetRect);
  329.     //zoomSpinBox_->setDecimals(0);
  330.     //frameZoomLayout->addWidget(zoomSpinBox_,1,0,1,3);
  331.  
  332.  
  333.     // Menu to change the display mode and options
  334.  
  335.     QHBoxLayout * displayModeLayout = new QHBoxLayout();
  336.     displayModeLayout->setMargin(0);
  337.     displayModeLayout->setSpacing(0);
  338.  
  339.     QVBoxLayout * displayModeLayoutLeftColumn = new QVBoxLayout();
  340.     displayModeLayoutLeftColumn->setMargin(0);
  341.     displayModeLayoutLeftColumn->setSpacing(0);
  342.  
  343.     QFormLayout * displayModeLayoutRightColumn = new QFormLayout();
  344.     displayModeLayoutRightColumn->setMargin(10);
  345.     displayModeLayoutRightColumn->setSpacing(10);
  346.  
  347.     displayModeButton_Normal_ = new QPushButton();
  348.     displayModeButton_Normal_->setToolTip("Normal display mode");
  349.     displayModeButton_Normal_->setIcon(QIcon(":images/display-mode-normal.png"));
  350.     displayModeButton_Normal_->setIconSize(QSize(32,32));
  351.     displayModeButton_Normal_->setFixedSize(buttonSize+20,buttonSize);
  352.     displayModeButton_Normal_->setAutoExclusive(true);
  353.     displayModeButton_Normal_->setCheckable(true);
  354.     displayModeButton_Normal_->setChecked(true);
  355.  
  356.     displayModeButton_NormalOutline_ = new QPushButton();
  357.     displayModeButton_NormalOutline_->setToolTip("Normal+Outline display mode");
  358.     displayModeButton_NormalOutline_->setIcon(QIcon(":images/display-mode-normal-outline.png"));
  359.     displayModeButton_NormalOutline_->setIconSize(QSize(32,32));
  360.     displayModeButton_NormalOutline_->setFixedSize(buttonSize+20,buttonSize);
  361.     displayModeButton_NormalOutline_->setAutoExclusive(true);
  362.     displayModeButton_NormalOutline_->setCheckable(true);
  363.     displayModeButton_NormalOutline_->setChecked(false);
  364.  
  365.     displayModeButton_Outline_ = new QPushButton();
  366.     displayModeButton_Outline_->setToolTip("Outline display mode");
  367.     displayModeButton_Outline_->setIcon(QIcon(":images/display-mode-outline.png"));
  368.     displayModeButton_Outline_->setIconSize(QSize(32,32));
  369.     displayModeButton_Outline_->setFixedSize(buttonSize+20,buttonSize);
  370.     displayModeButton_Outline_->setAutoExclusive(true);
  371.     displayModeButton_Outline_->setCheckable(true);
  372.     displayModeButton_Outline_->setChecked(false);
  373.  
  374.     displayModeLayoutLeftColumn->addWidget(displayModeButton_Normal_);
  375.     displayModeLayoutLeftColumn->addWidget(displayModeButton_NormalOutline_);
  376.     displayModeLayoutLeftColumn->addWidget(displayModeButton_Outline_);
  377.     displayModeLayoutLeftColumn->addStretch();
  378.  
  379.  
  380.     vertexTopologySize_ = new QSlider();
  381.     vertexTopologySize_->setOrientation(Qt::Horizontal);
  382.     vertexTopologySize_->setRange(0,100);
  383.     displayModeLayoutRightColumn->addRow(tr("Vertex outline size"), vertexTopologySize_);
  384.  
  385.     edgeTopologyWidth_ = new QSlider();
  386.     edgeTopologyWidth_->setOrientation(Qt::Horizontal);
  387.     edgeTopologyWidth_->setRange(0,100);
  388.     displayModeLayoutRightColumn->addRow(tr("Edge outline width"), edgeTopologyWidth_);
  389.  
  390.     drawTopologyFaces_ = new QCheckBox();
  391.     displayModeLayoutRightColumn->addRow(tr("Display faces in outline mode"), drawTopologyFaces_);
  392.  
  393.     QWidget * displayModeWidget = new QWidget();
  394.     displayModeLayout->addLayout(displayModeLayoutLeftColumn);
  395.     displayModeLayout->addLayout(displayModeLayoutRightColumn);
  396.     displayModeWidget->setLayout(displayModeLayout);
  397.  
  398.     QMenu * displayModeMenu = new QMenu();
  399.     QWidgetAction * displayModeWidgetAction = new QWidgetAction(this);
  400.     displayModeWidgetAction->setDefaultWidget(displayModeWidget);
  401.     displayModeMenu->addAction(displayModeWidgetAction);
  402.  
  403.  
  404.     // Button to show/hide the display mode menu
  405.  
  406.     displayModeButton_ = new QPushButton();
  407.     displayModeButton_->setToolTip("Display mode settings");
  408.     displayModeButton_->setIcon(QIcon(":images/display-mode-normal.png"));
  409.     //displayModeButton_->setIconSize(QSize(32,32));
  410.     displayModeButton_->setFixedSize(40,20);
  411.     displayModeButton_->setMenu(displayModeMenu);
  412.     displayModeButton_->setAttribute(Qt::WA_LayoutUsesWidgetRect);
  413.  
  414.  
  415.     // Menu to change onion skinning options
  416.  
  417.     QHBoxLayout * onionSkinningLayout = new QHBoxLayout();
  418.     onionSkinningLayout->setMargin(0);
  419.     onionSkinningLayout->setSpacing(0);
  420.  
  421.     QVBoxLayout * onionSkinningLayoutLeftColumn = new QVBoxLayout();
  422.     onionSkinningLayoutLeftColumn->setMargin(0);
  423.     onionSkinningLayoutLeftColumn->setSpacing(0);
  424.  
  425.     QFormLayout * onionSkinningLayoutRightColumn = new QFormLayout();
  426.     onionSkinningLayoutRightColumn->setMargin(10);
  427.     onionSkinningLayoutRightColumn->setSpacing(10);
  428.  
  429.     QFormLayout * onionSkinningLayoutRightColumn2 = new QFormLayout();
  430.     onionSkinningLayoutRightColumn2->setMargin(10);
  431.     onionSkinningLayoutRightColumn2->setSpacing(10);
  432.  
  433.     onionSkinningButton_Off_ = new QPushButton();
  434.     onionSkinningButton_Off_->setToolTip("Onion skinning off");
  435.     onionSkinningButton_Off_->setIcon(QIcon(":images/onion-skinning-off.png"));
  436.     onionSkinningButton_Off_->setIconSize(QSize(32,32));
  437.     onionSkinningButton_Off_->setFixedSize(buttonSize+20,buttonSize);
  438.     onionSkinningButton_Off_->setAutoExclusive(true);
  439.     onionSkinningButton_Off_->setCheckable(true);
  440.     onionSkinningButton_Off_->setChecked(true);
  441.  
  442.     onionSkinningButton_On_ = new QPushButton();
  443.     onionSkinningButton_On_->setToolTip("Onion skinning on");
  444.     onionSkinningButton_On_->setIcon(QIcon(":images/onion-skinning-on.png"));
  445.     onionSkinningButton_On_->setIconSize(QSize(32,32));
  446.     onionSkinningButton_On_->setFixedSize(buttonSize+20,buttonSize);
  447.     onionSkinningButton_On_->setAutoExclusive(true);
  448.     onionSkinningButton_On_->setCheckable(true);
  449.     onionSkinningButton_On_->setChecked(false);
  450.  
  451.     onionSkinningLayoutLeftColumn->addWidget(onionSkinningButton_Off_);
  452.     onionSkinningLayoutLeftColumn->addWidget(onionSkinningButton_On_);
  453.     onionSkinningLayoutLeftColumn->addStretch();
  454.  
  455.     numOnionSkinsBefore_ = new QSpinBox();
  456.     numOnionSkinsBefore_->setRange(0,100);
  457.     onionSkinningLayoutRightColumn->addRow(tr("Num skins before"), numOnionSkinsBefore_);
  458.  
  459.     numOnionSkinsAfter_ = new QSpinBox();
  460.     numOnionSkinsAfter_->setRange(0,100);
  461.     onionSkinningLayoutRightColumn->addRow(tr("Num skins after"), numOnionSkinsAfter_);
  462.  
  463.     areOnionSkinsPickable_ = new QCheckBox();
  464.     onionSkinningLayoutRightColumn->addRow(tr("Are skins pickable"), areOnionSkinsPickable_);
  465.  
  466.     onionSkinsTimeOffset_ = new QDoubleSpinBox();
  467.     onionSkinsTimeOffset_->setRange(-100,100);
  468.     onionSkinsTimeOffset_->setDecimals(2);
  469.     onionSkinningLayoutRightColumn2->addRow(tr("Skins frame offset"), onionSkinsTimeOffset_);
  470.  
  471.     onionSkinsXOffset_ = new QDoubleSpinBox();
  472.     onionSkinsXOffset_->setRange(-10000,10000);
  473.     onionSkinsXOffset_->setDecimals(2);
  474.     onionSkinningLayoutRightColumn2->addRow(tr("Skin X offset"), onionSkinsXOffset_);
  475.  
  476.     onionSkinsYOffset_ = new QDoubleSpinBox();
  477.     onionSkinsYOffset_->setRange(-10000,10000);
  478.     onionSkinsYOffset_->setDecimals(2);
  479.     onionSkinningLayoutRightColumn2->addRow(tr("Skin Y offset"), onionSkinsYOffset_);
  480.  
  481.     QWidget * onionSkinningWidget = new QWidget();
  482.     onionSkinningLayout->addLayout(onionSkinningLayoutLeftColumn);
  483.     onionSkinningLayout->addLayout(onionSkinningLayoutRightColumn);
  484.     onionSkinningLayout->addLayout(onionSkinningLayoutRightColumn2);
  485.     onionSkinningWidget->setLayout(onionSkinningLayout);
  486.  
  487.     QMenu * onionSkinningMenu = new QMenu();
  488.     QWidgetAction * onionSkinningWidgetAction = new QWidgetAction(this);
  489.     onionSkinningWidgetAction->setDefaultWidget(onionSkinningWidget);
  490.     onionSkinningMenu->addAction(onionSkinningWidgetAction);
  491.  
  492.  
  493.     // Button to show/hide the onion skinning menu
  494.  
  495.     onionSkinningButton_ = new QPushButton();
  496.     onionSkinningButton_->setToolTip("Onion skinning settings");
  497.     onionSkinningButton_->setIcon(QIcon(":images/display-mode-normal.png"));
  498.     //onionSkinningButton_->setIconSize(QSize(32,32));
  499.     onionSkinningButton_->setFixedSize(40,20);
  500.     onionSkinningButton_->setMenu(onionSkinningMenu);
  501.     onionSkinningButton_->setAttribute(Qt::WA_LayoutUsesWidgetRect);
  502.  
  503.  
  504.     // Layouts and widgets for grouping
  505.  
  506.     QHBoxLayout * hlayout = new QHBoxLayout();
  507.     hlayout->setMargin(0);
  508.     hlayout->setSpacing(0);
  509.     hlayout->addWidget(zoomSpinBox_);
  510.     hlayout->addSpacing(5);
  511.     hlayout->addWidget(goToPreviousFrameButton);
  512.     hlayout->addWidget(frameLineEdit_);
  513.     hlayout->addWidget(goToNextFrameButton);
  514.     //hlayout->addLayout(frameZoomLayout);
  515.     hlayout->addWidget(displayModeButton_);
  516.     hlayout->addWidget(onionSkinningButton_);
  517.  
  518.     containerWidget = new QWidget();
  519.     containerWidget->setLayout(hlayout);
  520.     containerWidget->setVisible(true);
  521.  
  522.     QHBoxLayout * hlayoutfull = new QHBoxLayout();
  523.     hlayoutfull->setMargin(0);
  524.     hlayoutfull->setSpacing(0);
  525.     hlayoutfull->addWidget(showHideSettingsButton_);
  526.     hlayoutfull->addWidget(containerWidget);
  527.  
  528.     setLayout(hlayoutfull);
  529.  
  530.  
  531.     // ----------------- Backend/Gui connections -----------------
  532.  
  533.     updateWidgetFromSettings(); // Might not be an exact match due to widget min/max values
  534.     updateSettingsFromWidget(); // Make sure its an exact match
  535.  
  536.     /* THE FOLLOWING ARE NOT IMPLEMENTED OR DEEMED IRRELEVANT
  537.     connect(screenRelative_, SIGNAL(stateChanged(int)), this, SLOT(updateSettingsFromWidget()));
  538.     connect(onionSkinsTransparencyRatio_, SIGNAL(valueChanged(double)), this, SLOT(updateSettingsFromWidget()));
  539.     */
  540.  
  541.     // Widget -> Settings connection
  542.     connect(zoomSpinBox_, SIGNAL(valueChanged(int)), this, SLOT(processZoomValueChangedSignal(int)));
  543.     connect(frameLineEdit_, SIGNAL(returnPressed()), this,  SLOT(updateSettingsFromWidget()));
  544.     connect(goToPreviousFrameButton, SIGNAL(clicked(bool)), this, SLOT(decrFrame()));
  545.     connect(goToNextFrameButton, SIGNAL(clicked(bool)), this, SLOT(incrFrame()));
  546.  
  547.     connect(displayModeButton_Normal_, SIGNAL(clicked(bool)), this, SLOT(updateSettingsFromWidget()));
  548.     connect(displayModeButton_NormalOutline_, SIGNAL(clicked(bool)), this, SLOT(updateSettingsFromWidget()));
  549.     connect(displayModeButton_Outline_, SIGNAL(clicked(bool)), this, SLOT(updateSettingsFromWidget()));
  550.     connect(onionSkinningButton_Off_, SIGNAL(clicked(bool)), this, SLOT(updateSettingsFromWidget()));
  551.     connect(onionSkinningButton_On_, SIGNAL(clicked(bool)), this, SLOT(updateSettingsFromWidget()));
  552.  
  553.     connect(vertexTopologySize_, SIGNAL(valueChanged(int)), this, SLOT(updateSettingsFromWidget()));
  554.     connect(edgeTopologyWidth_, SIGNAL(valueChanged(int)), this, SLOT(updateSettingsFromWidget()));
  555.     connect(drawTopologyFaces_, SIGNAL(stateChanged(int)), this, SLOT(updateSettingsFromWidget()));
  556.  
  557.     connect(areOnionSkinsPickable_, SIGNAL(stateChanged(int)), this, SLOT(updateSettingsFromWidget()));
  558.     connect(numOnionSkinsBefore_, SIGNAL(valueChanged(int)), this, SLOT(updateSettingsFromWidget()));
  559.     connect(numOnionSkinsAfter_, SIGNAL(valueChanged(int)), this, SLOT(updateSettingsFromWidget()));
  560.     connect(onionSkinsTimeOffset_, SIGNAL(valueChanged(double)), this, SLOT(updateSettingsFromWidget()));
  561.     connect(onionSkinsXOffset_, SIGNAL(valueChanged(double)), this, SLOT(updateSettingsFromWidget()));
  562.     connect(onionSkinsYOffset_, SIGNAL(valueChanged(double)), this, SLOT(updateSettingsFromWidget()));
  563.  
  564.  
  565.     // Settings -> Widget connection
  566.     //  -> must be done manually by owner of ViewSettings and ViewSettingsWidget
  567.  
  568.  
  569.     // ----------------- Set position and size -----------------
  570.  
  571.     setGeometry(10,10,100,100); // Move to (10,10) and resize arbitrarily to (100,100)
  572.     setFixedSize(sizeHint());   // Resize to optimal size
  573.  
  574.  
  575.  
  576.     // ----------------- Windows or Linux style ------------------------
  577.  
  578. #else
  579.     // Set style
  580.     setAutoFillBackground(true);
  581.     setCursor(Qt::ArrowCursor);
  582.     buttonSize = 48;
  583.  
  584.     /* THE FOLLOWING ARE NOT IMPLEMENTED OR DEEMED IRRELEVANT
  585.     screenRelative_ = new QCheckBox();
  586.     onionSkinsTransparencyRatio_ = new QDoubleSpinBox();
  587.     onionSkinsTransparencyRatio_->setRange(0.0,1.0);
  588.     onionSkinsTransparencyRatio_->setDecimals(2);
  589.     */
  590.  
  591.     // Button to show/hide view settings
  592.  
  593.     showHideSettingsButton_ = new QPushButton("");
  594.     showHideSettingsButton_->setToolTip("Show/hide view settings");
  595.     showHideSettingsButton_->setIcon(QIcon(":images/view-settings.png"));
  596.     showHideSettingsButton_->setIconSize(QSize(32,32));
  597.     showHideSettingsButton_->setCheckable(true);
  598.     showHideSettingsButton_->setChecked(true);
  599.     showHideSettingsButton_->setFixedSize(buttonSize,buttonSize);
  600.     connect(showHideSettingsButton_, SIGNAL(toggled(bool)), this, SLOT(toggleVisible(bool)));
  601.  
  602.  
  603.     // View label, frame number, zoom level
  604.  
  605.     QGridLayout * frameZoomLayout = new QGridLayout();
  606.     frameZoomLayout->setMargin(0);
  607.     frameZoomLayout->setSpacing(0);
  608.  
  609.     int frameZoomWidth = buttonSize+30;
  610.  
  611.     QPushButton * goToPreviousFrameButton = new QPushButton();
  612.     goToPreviousFrameButton->setFixedSize(25,0.5*buttonSize);
  613.     goToPreviousFrameButton->setIcon(QIcon(":/images/go-first-view.png"));
  614.     frameZoomLayout->addWidget(goToPreviousFrameButton,0,0);
  615.  
  616.     QPushButton * goToNextFrameButton = new QPushButton();
  617.     goToNextFrameButton->setFixedSize(25,0.5*buttonSize);
  618.     goToNextFrameButton->setIcon(QIcon(":/images/go-last-view.png"));
  619.     frameZoomLayout->addWidget(goToNextFrameButton,0,2);
  620.  
  621.     frameLineEdit_ = new QLineEdit();
  622.     frameLineEdit_->setFixedSize(frameZoomWidth-50,0.5*buttonSize);
  623.     frameLineEdit_->setAlignment(Qt::AlignCenter);
  624.     frameZoomLayout->addWidget(frameLineEdit_,0,1);
  625.  
  626.     zoomSpinBox_ = new QSpinBox();
  627.     zoomSpinBox_->setRange(1,1e7);
  628.     zoomSpinBox_->setValue(100);
  629.     zoomSpinBox_->setSuffix(" %");
  630.     zoomSpinBox_->setFixedSize(frameZoomWidth,0.5*buttonSize);
  631.     zoomSpinBox_->setAlignment(Qt::AlignCenter);
  632.     //zoomSpinBox_->setDecimals(0);
  633.     frameZoomLayout->addWidget(zoomSpinBox_,1,0,1,3);
  634.  
  635.  
  636.     // Menu to change the display mode and options
  637.  
  638.     QHBoxLayout * displayModeLayout = new QHBoxLayout();
  639.     displayModeLayout->setMargin(0);
  640.     displayModeLayout->setSpacing(0);
  641.  
  642.     QVBoxLayout * displayModeLayoutLeftColumn = new QVBoxLayout();
  643.     displayModeLayoutLeftColumn->setMargin(0);
  644.     displayModeLayoutLeftColumn->setSpacing(0);
  645.  
  646.     QFormLayout * displayModeLayoutRightColumn = new QFormLayout();
  647.     displayModeLayoutRightColumn->setMargin(10);
  648.     displayModeLayoutRightColumn->setSpacing(10);
  649.  
  650.     displayModeButton_Normal_ = new QPushButton();
  651.     displayModeButton_Normal_->setToolTip("Normal display mode");
  652.     displayModeButton_Normal_->setIcon(QIcon(":images/display-mode-normal.png"));
  653.     displayModeButton_Normal_->setIconSize(QSize(32,32));
  654.     displayModeButton_Normal_->setFixedSize(buttonSize+20,buttonSize);
  655.     displayModeButton_Normal_->setAutoExclusive(true);
  656.     displayModeButton_Normal_->setCheckable(true);
  657.     displayModeButton_Normal_->setChecked(true);
  658.  
  659.     displayModeButton_NormalOutline_ = new QPushButton();
  660.     displayModeButton_NormalOutline_->setToolTip("Normal+Outline display mode");
  661.     displayModeButton_NormalOutline_->setIcon(QIcon(":images/display-mode-normal-outline.png"));
  662.     displayModeButton_NormalOutline_->setIconSize(QSize(32,32));
  663.     displayModeButton_NormalOutline_->setFixedSize(buttonSize+20,buttonSize);
  664.     displayModeButton_NormalOutline_->setAutoExclusive(true);
  665.     displayModeButton_NormalOutline_->setCheckable(true);
  666.     displayModeButton_NormalOutline_->setChecked(false);
  667.  
  668.     displayModeButton_Outline_ = new QPushButton();
  669.     displayModeButton_Outline_->setToolTip("Outline display mode");
  670.     displayModeButton_Outline_->setIcon(QIcon(":images/display-mode-outline.png"));
  671.     displayModeButton_Outline_->setIconSize(QSize(32,32));
  672.     displayModeButton_Outline_->setFixedSize(buttonSize+20,buttonSize);
  673.     displayModeButton_Outline_->setAutoExclusive(true);
  674.     displayModeButton_Outline_->setCheckable(true);
  675.     displayModeButton_Outline_->setChecked(false);
  676.  
  677.     displayModeLayoutLeftColumn->addWidget(displayModeButton_Normal_);
  678.     displayModeLayoutLeftColumn->addWidget(displayModeButton_NormalOutline_);
  679.     displayModeLayoutLeftColumn->addWidget(displayModeButton_Outline_);
  680.     displayModeLayoutLeftColumn->addStretch();
  681.  
  682.  
  683.     vertexTopologySize_ = new QSlider();
  684.     vertexTopologySize_->setOrientation(Qt::Horizontal);
  685.     vertexTopologySize_->setRange(0,100);
  686.     displayModeLayoutRightColumn->addRow(tr("Vertex outline size"), vertexTopologySize_);
  687.  
  688.     edgeTopologyWidth_ = new QSlider();
  689.     edgeTopologyWidth_->setOrientation(Qt::Horizontal);
  690.     edgeTopologyWidth_->setRange(0,100);
  691.     displayModeLayoutRightColumn->addRow(tr("Edge outline width"), edgeTopologyWidth_);
  692.  
  693.     drawTopologyFaces_ = new QCheckBox();
  694.     displayModeLayoutRightColumn->addRow(tr("Display faces in outline mode"), drawTopologyFaces_);
  695.  
  696.     QWidget * displayModeWidget = new QWidget();
  697.     displayModeLayout->addLayout(displayModeLayoutLeftColumn);
  698.     displayModeLayout->addLayout(displayModeLayoutRightColumn);
  699.     displayModeWidget->setLayout(displayModeLayout);
  700.  
  701.     QMenu * displayModeMenu = new QMenu();
  702.     QWidgetAction * displayModeWidgetAction = new QWidgetAction(this);
  703.     displayModeWidgetAction->setDefaultWidget(displayModeWidget);
  704.     displayModeMenu->addAction(displayModeWidgetAction);
  705.  
  706.  
  707.     // Button to show/hide the display mode menu
  708.  
  709.     displayModeButton_ = new QPushButton();
  710.     displayModeButton_->setToolTip("Display mode settings");
  711.     displayModeButton_->setIcon(QIcon(":images/display-mode-normal.png"));
  712.     displayModeButton_->setIconSize(QSize(32,32));
  713.     displayModeButton_->setFixedSize(buttonSize+20,buttonSize);
  714.     displayModeButton_->setMenu(displayModeMenu);
  715.  
  716.  
  717.     // Menu to change onion skinning options
  718.  
  719.     QHBoxLayout * onionSkinningLayout = new QHBoxLayout();
  720.     onionSkinningLayout->setMargin(0);
  721.     onionSkinningLayout->setSpacing(0);
  722.  
  723.     QVBoxLayout * onionSkinningLayoutLeftColumn = new QVBoxLayout();
  724.     onionSkinningLayoutLeftColumn->setMargin(0);
  725.     onionSkinningLayoutLeftColumn->setSpacing(0);
  726.  
  727.     QFormLayout * onionSkinningLayoutRightColumn = new QFormLayout();
  728.     onionSkinningLayoutRightColumn->setMargin(10);
  729.     onionSkinningLayoutRightColumn->setSpacing(10);
  730.  
  731.     QFormLayout * onionSkinningLayoutRightColumn2 = new QFormLayout();
  732.     onionSkinningLayoutRightColumn2->setMargin(10);
  733.     onionSkinningLayoutRightColumn2->setSpacing(10);
  734.  
  735.     onionSkinningButton_Off_ = new QPushButton();
  736.     onionSkinningButton_Off_->setToolTip("Onion skinning off");
  737.     onionSkinningButton_Off_->setIcon(QIcon(":images/onion-skinning-off.png"));
  738.     onionSkinningButton_Off_->setIconSize(QSize(32,32));
  739.     onionSkinningButton_Off_->setFixedSize(buttonSize+20,buttonSize);
  740.     onionSkinningButton_Off_->setAutoExclusive(true);
  741.     onionSkinningButton_Off_->setCheckable(true);
  742.     onionSkinningButton_Off_->setChecked(true);
  743.  
  744.     onionSkinningButton_On_ = new QPushButton();
  745.     onionSkinningButton_On_->setToolTip("Onion skinning on");
  746.     onionSkinningButton_On_->setIcon(QIcon(":images/onion-skinning-on.png"));
  747.     onionSkinningButton_On_->setIconSize(QSize(32,32));
  748.     onionSkinningButton_On_->setFixedSize(buttonSize+20,buttonSize);
  749.     onionSkinningButton_On_->setAutoExclusive(true);
  750.     onionSkinningButton_On_->setCheckable(true);
  751.     onionSkinningButton_On_->setChecked(false);
  752.  
  753.     onionSkinningLayoutLeftColumn->addWidget(onionSkinningButton_Off_);
  754.     onionSkinningLayoutLeftColumn->addWidget(onionSkinningButton_On_);
  755.     onionSkinningLayoutLeftColumn->addStretch();
  756.  
  757.     numOnionSkinsBefore_ = new QSpinBox();
  758.     numOnionSkinsBefore_->setRange(0,100);
  759.     onionSkinningLayoutRightColumn->addRow(tr("Num skins before"), numOnionSkinsBefore_);
  760.  
  761.     numOnionSkinsAfter_ = new QSpinBox();
  762.     numOnionSkinsAfter_->setRange(0,100);
  763.     onionSkinningLayoutRightColumn->addRow(tr("Num skins after"), numOnionSkinsAfter_);
  764.  
  765.     areOnionSkinsPickable_ = new QCheckBox();
  766.     onionSkinningLayoutRightColumn->addRow(tr("Are skins pickable"), areOnionSkinsPickable_);
  767.  
  768.     onionSkinsTimeOffset_ = new QDoubleSpinBox();
  769.     onionSkinsTimeOffset_->setRange(-100,100);
  770.     onionSkinsTimeOffset_->setDecimals(2);
  771.     onionSkinningLayoutRightColumn2->addRow(tr("Skins frame offset"), onionSkinsTimeOffset_);
  772.  
  773.     onionSkinsXOffset_ = new QDoubleSpinBox();
  774.     onionSkinsXOffset_->setRange(-10000,10000);
  775.     onionSkinsXOffset_->setDecimals(2);
  776.     onionSkinningLayoutRightColumn2->addRow(tr("Skin X offset"), onionSkinsXOffset_);
  777.  
  778.     onionSkinsYOffset_ = new QDoubleSpinBox();
  779.     onionSkinsYOffset_->setRange(-10000,10000);
  780.     onionSkinsYOffset_->setDecimals(2);
  781.     onionSkinningLayoutRightColumn2->addRow(tr("Skin Y offset"), onionSkinsYOffset_);
  782.  
  783.     QWidget * onionSkinningWidget = new QWidget();
  784.     onionSkinningLayout->addLayout(onionSkinningLayoutLeftColumn);
  785.     onionSkinningLayout->addLayout(onionSkinningLayoutRightColumn);
  786.     onionSkinningLayout->addLayout(onionSkinningLayoutRightColumn2);
  787.     onionSkinningWidget->setLayout(onionSkinningLayout);
  788.  
  789.     QMenu * onionSkinningMenu = new QMenu();
  790.     QWidgetAction * onionSkinningWidgetAction = new QWidgetAction(this);
  791.     onionSkinningWidgetAction->setDefaultWidget(onionSkinningWidget);
  792.     onionSkinningMenu->addAction(onionSkinningWidgetAction);
  793.  
  794.  
  795.     // Button to show/hide the display mode menu
  796.  
  797.     onionSkinningButton_ = new QPushButton();
  798.     onionSkinningButton_->setToolTip("Onion skinning settings");
  799.     onionSkinningButton_->setIcon(QIcon(":images/display-mode-normal.png"));
  800.     onionSkinningButton_->setIconSize(QSize(32,32));
  801.     onionSkinningButton_->setFixedSize(buttonSize+20,buttonSize);
  802.     onionSkinningButton_->setMenu(onionSkinningMenu);
  803.  
  804.  
  805.     // Layouts and widgets for grouping
  806.  
  807.     QHBoxLayout * hlayout = new QHBoxLayout();
  808.     hlayout->setMargin(0);
  809.     hlayout->setSpacing(0);
  810.     hlayout->addLayout(frameZoomLayout);
  811.     hlayout->addWidget(displayModeButton_);
  812.     hlayout->addWidget(onionSkinningButton_);
  813.  
  814.     containerWidget = new QWidget();
  815.     containerWidget->setLayout(hlayout);
  816.     containerWidget->setVisible(true);
  817.  
  818.     QHBoxLayout * hlayoutfull = new QHBoxLayout();
  819.     hlayoutfull->setMargin(0);
  820.     hlayoutfull->setSpacing(0);
  821.     hlayoutfull->addWidget(showHideSettingsButton_);
  822.     hlayoutfull->addWidget(containerWidget);
  823.  
  824.     setLayout(hlayoutfull);
  825.  
  826.  
  827.     // ----------------- Backend/Gui connections -----------------
  828.  
  829.     updateWidgetFromSettings(); // Might not be an exact match due to widget min/max values
  830.     updateSettingsFromWidget(); // Make sure its an exact match
  831.  
  832.     /* THE FOLLOWING ARE NOT IMPLEMENTED OR DEEMED IRRELEVANT
  833.     connect(screenRelative_, SIGNAL(stateChanged(int)), this, SLOT(updateSettingsFromWidget()));
  834.     connect(onionSkinsTransparencyRatio_, SIGNAL(valueChanged(double)), this, SLOT(updateSettingsFromWidget()));
  835.     */
  836.  
  837.     // Widget -> Settings connection
  838.     connect(zoomSpinBox_, SIGNAL(valueChanged(int)), this, SLOT(processZoomValueChangedSignal(int)));
  839.     connect(frameLineEdit_, SIGNAL(returnPressed()), this,  SLOT(updateSettingsFromWidget()));
  840.     connect(goToPreviousFrameButton, SIGNAL(clicked(bool)), this, SLOT(decrFrame()));
  841.     connect(goToNextFrameButton, SIGNAL(clicked(bool)), this, SLOT(incrFrame()));
  842.  
  843.     connect(displayModeButton_Normal_, SIGNAL(clicked(bool)), this, SLOT(updateSettingsFromWidget()));
  844.     connect(displayModeButton_NormalOutline_, SIGNAL(clicked(bool)), this, SLOT(updateSettingsFromWidget()));
  845.     connect(displayModeButton_Outline_, SIGNAL(clicked(bool)), this, SLOT(updateSettingsFromWidget()));
  846.     connect(onionSkinningButton_Off_, SIGNAL(clicked(bool)), this, SLOT(updateSettingsFromWidget()));
  847.     connect(onionSkinningButton_On_, SIGNAL(clicked(bool)), this, SLOT(updateSettingsFromWidget()));
  848.  
  849.     connect(vertexTopologySize_, SIGNAL(valueChanged(int)), this, SLOT(updateSettingsFromWidget()));
  850.     connect(edgeTopologyWidth_, SIGNAL(valueChanged(int)), this, SLOT(updateSettingsFromWidget()));
  851.     connect(drawTopologyFaces_, SIGNAL(stateChanged(int)), this, SLOT(updateSettingsFromWidget()));
  852.  
  853.     connect(areOnionSkinsPickable_, SIGNAL(stateChanged(int)), this, SLOT(updateSettingsFromWidget()));
  854.     connect(numOnionSkinsBefore_, SIGNAL(valueChanged(int)), this, SLOT(updateSettingsFromWidget()));
  855.     connect(numOnionSkinsAfter_, SIGNAL(valueChanged(int)), this, SLOT(updateSettingsFromWidget()));
  856.     connect(onionSkinsTimeOffset_, SIGNAL(valueChanged(double)), this, SLOT(updateSettingsFromWidget()));
  857.     connect(onionSkinsXOffset_, SIGNAL(valueChanged(double)), this, SLOT(updateSettingsFromWidget()));
  858.     connect(onionSkinsYOffset_, SIGNAL(valueChanged(double)), this, SLOT(updateSettingsFromWidget()));
  859.  
  860.  
  861.     // Settings -> Widget connection
  862.     //  -> must be done manually by owner of ViewSettings and ViewSettingsWidget
  863.  
  864.  
  865.     // ----------------- Set position and size -----------------
  866.  
  867.     setGeometry(10,10,100,100); // Move to (10,10) and resize arbitrarily to (100,100)
  868.     setFixedSize(sizeHint());   // Resize to optimal size
  869.  
  870. #endif
  871. }
  872.  
  873. ViewSettingsWidget::~ViewSettingsWidget()
  874. {
  875. }
  876.  
  877. void ViewSettingsWidget::setActive(bool isActive)
  878. {
  879.     if(isActive)
  880.     {
  881.         showHideSettingsButton_->setIcon(QIcon(":images/view-settings-active.png"));
  882.     }
  883.     else
  884.     {
  885.         showHideSettingsButton_->setIcon(QIcon(":images/view-settings.png"));
  886.     }
  887. }
  888.  
  889. void ViewSettingsWidget::toggleVisible(bool checked)
  890. {
  891.     containerWidget->setVisible(checked);
  892.     setFixedSize(sizeHint());
  893. }
  894.  
  895. void ViewSettingsWidget::processZoomValueChangedSignal(int n)
  896. {
  897.     // Only set value from spinbox when user actual change value from
  898.     // spinbox, not when setValue() is called programmatically. We do
  899.     // this by manually setting
  900.     //     ignoreZoomValueChangedSignal_ = true;
  901.     // before calling setValue()
  902.     if(!ignoreZoomValueChangedSignal_)
  903.     {
  904.         zoomValue_ = 0.01 * n;
  905.         updateSettingsFromWidget();
  906.     }
  907. }
  908.  
  909.  
  910. void ViewSettingsWidget::updateWidgetFromSettings()
  911. {
  912.     /* THE FOLLOWING ARE NOT IMPLEMENTED OR DEEMED IRRELEVANT
  913.     screenRelative_->setChecked(viewSettings_.screenRelative());
  914.     onionSkinsTransparencyRatio_->setValue(viewSettings_.onionSkinsTransparencyRatio());
  915. */
  916.  
  917.     vertexTopologySize_->setValue(viewSettings_.vertexTopologySize());
  918.     edgeTopologyWidth_->setValue(viewSettings_.edgeTopologyWidth());
  919.     drawTopologyFaces_->setChecked(viewSettings_.drawTopologyFaces());
  920.  
  921.     areOnionSkinsPickable_->setChecked(viewSettings_.areOnionSkinsPickable());
  922.     numOnionSkinsBefore_->setValue(viewSettings_.numOnionSkinsBefore());
  923.     numOnionSkinsAfter_->setValue(viewSettings_.numOnionSkinsAfter());
  924.     onionSkinsTimeOffset_->setValue(viewSettings_.onionSkinsTimeOffset().floatTime());
  925.     onionSkinsXOffset_->setValue(viewSettings_.onionSkinsXOffset());
  926.     onionSkinsYOffset_->setValue(viewSettings_.onionSkinsYOffset());
  927.  
  928.     zoomValue_ = viewSettings_.zoom();
  929.     ignoreZoomValueChangedSignal_ = true;
  930.     zoomSpinBox_->setValue(100*viewSettings_.zoom());
  931.     ignoreZoomValueChangedSignal_ = false;
  932.  
  933.     frameLineEdit_->setText(QString().setNum(viewSettings_.time().frame()));
  934.  
  935.     switch(viewSettings_.displayMode())
  936.     {
  937.     case ViewSettings::ILLUSTRATION:
  938.         displayModeButton_Normal_->setChecked(true);
  939.         displayModeButton_->setIcon(QIcon(":images/display-mode-normal.png"));
  940.         break;
  941.     case ViewSettings::ILLUSTRATION_OUTLINE:
  942.         displayModeButton_NormalOutline_->setChecked(true);
  943.         displayModeButton_->setIcon(QIcon(":images/display-mode-normal-outline.png"));
  944.         break;
  945.     case ViewSettings::OUTLINE:
  946.         displayModeButton_Outline_->setChecked(true);
  947.         displayModeButton_->setIcon(QIcon(":images/display-mode-outline.png"));
  948.         break;
  949.     }
  950.  
  951.     if(viewSettings_.onionSkinningIsEnabled())
  952.     {
  953.         onionSkinningButton_On_->setChecked(true);
  954.         onionSkinningButton_->setIcon(QIcon(":images/onion-skinning-on.png"));
  955.     }
  956.     else
  957.     {
  958.         onionSkinningButton_Off_->setChecked(true);
  959.         onionSkinningButton_->setIcon(QIcon(":images/onion-skinning-off.png"));
  960.     }
  961. }
  962.  
  963. void ViewSettingsWidget::updateSettingsFromWidget()
  964. {
  965.     updateSettingsFromWidgetSilent();
  966.     emit changed();
  967. }
  968.  
  969. int ViewSettingsWidget::getFrame_()
  970. {
  971.     bool ok;
  972.     int frame = frameLineEdit_->text().toInt(&ok);
  973.     if(ok)
  974.     {
  975.         return frame;
  976.     }
  977.     else
  978.     {
  979.         return viewSettings_.time().frame();
  980.     }
  981. }
  982.  
  983. void ViewSettingsWidget::incrFrame()
  984. {
  985.     int frame = getFrame_();
  986.     frame++;
  987.     frameLineEdit_->setText(QString().setNum(frame));
  988.     updateSettingsFromWidget();
  989. }
  990.  
  991. void ViewSettingsWidget::decrFrame()
  992. {
  993.     int frame = getFrame_();
  994.     frame--;
  995.     frameLineEdit_->setText(QString().setNum(frame));
  996.     updateSettingsFromWidget();
  997. }
  998.  
  999. void ViewSettingsWidget::updateSettingsFromWidgetSilent()
  1000. {
  1001.     /* THE FOLLOWING ARE NOT IMPLEMENTED OR DEEMED IRRELEVANT
  1002.     viewSettings_.setScreenRelative(screenRelative_->isChecked());
  1003.     viewSettings_.setOnionSkinsTransparencyRatio(onionSkinsTransparencyRatio_->value());
  1004.     */
  1005.  
  1006.     viewSettings_.setVertexTopologySize(vertexTopologySize_->value());
  1007.     viewSettings_.setEdgeTopologyWidth(edgeTopologyWidth_->value());
  1008.     viewSettings_.setDrawTopologyFaces(drawTopologyFaces_->isChecked());
  1009.  
  1010.     viewSettings_.setAreOnionSkinsPickable(areOnionSkinsPickable_->isChecked());
  1011.     viewSettings_.setNumOnionSkinsBefore(numOnionSkinsBefore_->value());
  1012.     viewSettings_.setNumOnionSkinsAfter(numOnionSkinsAfter_->value());
  1013.     viewSettings_.setOnionSkinsTimeOffset(onionSkinsTimeOffset_->value());
  1014.     viewSettings_.setOnionSkinsXOffset(onionSkinsXOffset_->value());
  1015.     viewSettings_.setOnionSkinsYOffset(onionSkinsYOffset_->value());
  1016.  
  1017.     viewSettings_.setZoom(zoomValue_);
  1018.     QString textFrame = frameLineEdit_->text();
  1019.     bool ok;
  1020.     int frame = textFrame.toInt(&ok);
  1021.     if(ok)
  1022.     {
  1023.         viewSettings_.setTime(Time(frame));
  1024.     }
  1025.     else
  1026.     {
  1027.         frameLineEdit_->setText(QString().setNum(viewSettings_.time().frame()));
  1028.     }
  1029.  
  1030.     if(displayModeButton_Normal_->isChecked())
  1031.     {
  1032.         viewSettings_.setDisplayMode(ViewSettings::ILLUSTRATION);
  1033.         displayModeButton_->setIcon(QIcon(":images/display-mode-normal.png"));
  1034.     }
  1035.     else if(displayModeButton_NormalOutline_->isChecked())
  1036.     {
  1037.         viewSettings_.setDisplayMode(ViewSettings::ILLUSTRATION_OUTLINE);
  1038.         displayModeButton_->setIcon(QIcon(":images/display-mode-normal-outline.png"));
  1039.  
  1040.     }
  1041.     else if(displayModeButton_Outline_->isChecked())
  1042.     {
  1043.         viewSettings_.setDisplayMode(ViewSettings::OUTLINE);
  1044.         displayModeButton_->setIcon(QIcon(":images/display-mode-outline.png"));
  1045.     }
  1046.  
  1047.     if(onionSkinningButton_Off_->isChecked())
  1048.     {
  1049.         viewSettings_.setOnionSkinningIsEnabled(false);
  1050.         onionSkinningButton_->setIcon(QIcon(":images/onion-skinning-off.png"));
  1051.     }
  1052.     else if(onionSkinningButton_On_->isChecked())
  1053.     {
  1054.         viewSettings_.setOnionSkinningIsEnabled(true);
  1055.         onionSkinningButton_->setIcon(QIcon(":images/onion-skinning-on.png"));
  1056.     }
  1057.  
  1058. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top