Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2d506f31e3
Fetching contributors…

Cannot retrieve contributors at this time

file 195 lines (165 sloc) 6.038 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
//=============================================================================
// MuseScore
// Music Composition & Notation
// $Id:$
//
// Copyright (C) 2011 Werner Schweer and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENSE.GPL
//=============================================================================

#include "omrpanel.h"
#include "musescore.h"
#include "scoreview.h"
#include "omr/omrview.h"
#include "omr/omr.h"
#include "libmscore/score.h"

//---------------------------------------------------------
// showOmrPanel
//---------------------------------------------------------

void MuseScore::showOmrPanel(bool visible)
      {
      QAction* a = getAction("omr");
      if (visible) {
            if (!omrPanel) {
                  omrPanel = new OmrPanel();
                  connect(omrPanel, SIGNAL(omrPanelVisible(bool)), a, SLOT(setChecked(bool)));
                  addDockWidget(Qt::RightDockWidgetArea, omrPanel);
                  }
            }
      if (omrPanel)
            omrPanel->setVisible(visible);
      if (omrPanel && visible) {
            if (cv && cv->omrView())
                  omrPanel->setOmrView(cv->omrView());
            else
                  omrPanel->setOmrView(0);
            }
      a->setChecked(visible);
      }

//---------------------------------------------------------
// OmrPanel
//---------------------------------------------------------

OmrPanel::OmrPanel(QWidget* parent)
   : QDockWidget(tr("Omr Panel"), parent)
      {
      setObjectName("omrpanel");
      setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
      QWidget* mainWidget = new QWidget;
      mainWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
      setWidget(mainWidget);

      op.setupUi(mainWidget);

      setOmrView(0);

      connect(op.showBarlines, SIGNAL(toggled(bool)), SLOT(showBarlinesToggled(bool)));
      connect(op.showLines, SIGNAL(toggled(bool)), SLOT(showLinesToggled(bool)));
      connect(op.showSlices, SIGNAL(toggled(bool)), SLOT(showSlicesToggled(bool)));
      connect(op.showStaves, SIGNAL(toggled(bool)), SLOT(showStavesToggled(bool)));
      connect(op.spatium, SIGNAL(valueChanged(double)), SLOT(spatiumChanged(double)));
      connect(op.process, SIGNAL(clicked()), SLOT(processClicked()));
      }

//---------------------------------------------------------
// closeEvent
//---------------------------------------------------------

void OmrPanel::closeEvent(QCloseEvent* ev)
      {
      emit omrPanelVisible(false);
      QWidget::closeEvent(ev);
      }

//---------------------------------------------------------
// showBarlinesToggled
//---------------------------------------------------------

void OmrPanel::showBarlinesToggled(bool val)
      {
      if (omrView)
            omrView->setShowBarlines(val);
      }

//---------------------------------------------------------
// showLinesToggled
//---------------------------------------------------------

void OmrPanel::showLinesToggled(bool val)
      {
      if (omrView)
            omrView->setShowLines(val);
      }

//---------------------------------------------------------
// showSlicesToggled
//---------------------------------------------------------

void OmrPanel::showSlicesToggled(bool val)
      {
      if (omrView)
            omrView->setShowSlices(val);
      }

//---------------------------------------------------------
// showStavesToggled
//---------------------------------------------------------

void OmrPanel::showStavesToggled(bool val)
      {
      if (omrView)
            omrView->setShowStaves(val);
      }

//---------------------------------------------------------
// spatiumChanged
//---------------------------------------------------------

void OmrPanel::spatiumChanged(double val)
      {
      if (omrView) {
            omrView->omr()->setSpatium(val * omrView->omr()->dpmm());
            omrView->update();
            }
      }

//---------------------------------------------------------
// blockSignals
//---------------------------------------------------------

void OmrPanel::blockSignals(bool val)
      {
      op.showBarlines->blockSignals(val);
      op.showLines->blockSignals(val);
      op.showSlices->blockSignals(val);
      op.showStaves->blockSignals(val);
      op.spatium->blockSignals(val);
      }

//---------------------------------------------------------
// enableGui
//---------------------------------------------------------

void OmrPanel::enableGui(bool val)
      {
      op.showBarlines->setEnabled(val);
      op.showLines->setEnabled(val);
      op.showSlices->setEnabled(val);
      op.showStaves->setEnabled(val);
      op.spatium->setEnabled(val);
      op.process->setEnabled(val);
      }

//---------------------------------------------------------
// setOmr
//---------------------------------------------------------

void OmrPanel::setOmrView(OmrView* v)
      {
      omrView = v;
      if (omrView) {
            enableGui(true);
            blockSignals(true);

            op.showBarlines->setChecked(omrView->showBarlines());
            op.showLines->setChecked(omrView->showLines());
            op.showSlices->setChecked(omrView->showSlices());
            op.showStaves->setChecked(omrView->showStaves());
            op.spatium->setValue(omrView->omr()->spatiumMM());

            blockSignals(false);
            }
      else {
            enableGui(false);
            }
      }

//---------------------------------------------------------
// processClicked
//---------------------------------------------------------

void OmrPanel::processClicked()
      {
      if (omrView) {
            omrView->omr()->process();
            omrView->update();
            setOmrView(omrView); // update values
            }
      }
Something went wrong with that request. Please try again.