⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrixview.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: *//*    Rosegarden    A MIDI and audio sequencer and musical notation editor.     This program is Copyright 2000-2007        Guillaume Laurent   <glaurent@telegraph-road.org>,        Chris Cannam        <cannam@all-day-breakfast.com>,        Richard Bown        <richard.bown@ferventsoftware.com>     The moral rights of Guillaume Laurent, Chris Cannam, and Richard    Bown to claim authorship of this work have been asserted.     Other copyrights also apply to some parts of this work.  Please    see the AUTHORS file and individual file headers for details.     This program is free software; you can redistribute it and/or    modify it under the terms of the GNU General Public License as    published by the Free Software Foundation; either version 2 of the    License, or (at your option) any later version.  See the file    COPYING included with this distribution for more information.*/#include "MatrixView.h"#include "base/BaseProperties.h"#include "misc/Debug.h"#include "misc/Strings.h"#include "base/AudioLevel.h"#include "base/Clipboard.h"#include "base/Composition.h"#include "base/Event.h"#include "base/Instrument.h"#include "base/LayoutEngine.h"#include "base/MidiProgram.h"#include "base/NotationTypes.h"#include "base/Profiler.h"#include "base/PropertyName.h"#include "base/BasicQuantizer.h"#include "base/LegatoQuantizer.h"#include "base/RealTime.h"#include "base/RulerScale.h"#include "base/Segment.h"#include "base/Selection.h"#include "base/SnapGrid.h"#include "base/Staff.h"#include "base/Studio.h"#include "base/Track.h"#include "commands/edit/ChangeVelocityCommand.h"#include "commands/edit/ClearTriggersCommand.h"#include "commands/edit/CollapseNotesCommand.h"#include "commands/edit/CopyCommand.h"#include "commands/edit/CutCommand.h"#include "commands/edit/EraseCommand.h"#include "commands/edit/EventQuantizeCommand.h"#include "commands/edit/EventUnquantizeCommand.h"#include "commands/edit/PasteEventsCommand.h"#include "commands/edit/SelectionPropertyCommand.h"#include "commands/edit/SetTriggerCommand.h"#include "commands/matrix/MatrixInsertionCommand.h"#include "document/RosegardenGUIDoc.h"#include "document/ConfigGroups.h"#include "gui/application/RosegardenGUIApp.h"#include "gui/dialogs/EventFilterDialog.h"#include "gui/dialogs/EventParameterDialog.h"#include "gui/dialogs/QuantizeDialog.h"#include "gui/dialogs/TriggerSegmentDialog.h"#include "gui/editors/guitar/Chord.h"#include "gui/editors/notation/NotationElement.h"#include "gui/editors/notation/NotationStrings.h"#include "gui/editors/notation/NotePixmapFactory.h"#include "gui/editors/parameters/InstrumentParameterBox.h"#include "gui/rulers/StandardRuler.h"#include "gui/general/ActiveItem.h"#include "gui/general/EditViewBase.h"#include "gui/general/EditView.h"#include "gui/general/GUIPalette.h"#include "gui/general/MidiPitchLabel.h"#include "gui/kdeext/KTmpStatusMsg.h"#include "gui/rulers/ChordNameRuler.h"#include "gui/rulers/LoopRuler.h"#include "gui/rulers/PercussionPitchRuler.h"#include "gui/rulers/PitchRuler.h"#include "gui/rulers/PropertyBox.h"#include "gui/rulers/PropertyViewRuler.h"#include "gui/rulers/TempoRuler.h"#include "gui/studio/StudioControl.h"#include "gui/widgets/QDeferScrollView.h"#include "MatrixCanvasView.h"#include "MatrixElement.h"#include "MatrixEraser.h"#include "MatrixHLayout.h"#include "MatrixMover.h"#include "MatrixPainter.h"#include "MatrixResizer.h"#include "MatrixSelector.h"#include "MatrixStaff.h"#include "MatrixToolBox.h"#include "MatrixVLayout.h"#include "PianoKeyboard.h"#include "sound/MappedEvent.h"#include "sound/SequencerDataBlock.h"#include <klocale.h>#include <kstddirs.h>#include <kaction.h>#include <kcombobox.h>#include <kconfig.h>#include <kdockwidget.h>#include <kglobal.h>#include <kmessagebox.h>#include <kstatusbar.h>#include <ktoolbar.h>#include <kxmlguiclient.h>#include <qcanvas.h>#include <qcursor.h>#include <qdialog.h>#include <qlayout.h>#include <qiconset.h>#include <qlabel.h>#include <qpixmap.h>#include <qpoint.h>#include <qscrollview.h>#include <qsize.h>#include <qslider.h>#include <qstring.h>#include <qwidget.h>#include <qwmatrix.h>namespace Rosegarden{static double xorigin = 0.0;MatrixView::MatrixView(RosegardenGUIDoc *doc,                       std::vector<Segment *> segments,                       QWidget *parent,                       bool drumMode)        : EditView(doc, segments, 3, parent, "matrixview"),        m_hlayout(&doc->getComposition()),        m_referenceRuler(new ZoomableMatrixHLayoutRulerScale(m_hlayout)),        m_vlayout(),        m_snapGrid(new SnapGrid(&m_hlayout)),        m_lastEndMarkerTime(0),        m_hoveredOverAbsoluteTime(0),        m_hoveredOverNoteName(0),        m_selectionCounter(0),        m_insertModeLabel(0),        m_haveHoveredOverNote(false),        m_previousEvPitch(0),        m_dockLeft(0),        m_canvasView(0),        m_pianoView(0),        m_localMapping(0),        m_lastNote(0),        m_quantizations(BasicQuantizer::getStandardQuantizations()),        m_chordNameRuler(0),        m_tempoRuler(0),        m_playTracking(true),        m_dockVisible(true),        m_drumMode(drumMode),        m_mouseInCanvasView(false){    RG_DEBUG << "MatrixView ctor: drumMode " << drumMode << "\n";    QString pixmapDir = KGlobal::dirs()->findResource("appdata", "pixmaps/toolbar");    QPixmap matrixPixmap(pixmapDir + "/matrix.xpm");    m_dockLeft = createDockWidget("params dock", matrixPixmap, 0L,                                  i18n("Instrument Parameters"));    m_dockLeft->manualDock(m_mainDockWidget,             // dock target                           KDockWidget::DockLeft,  // dock site                           20);                   // relation target/this (in percent)    connect(m_dockLeft, SIGNAL(iMBeingClosed()),            this, SLOT(slotParametersClosed()));    connect(m_dockLeft, SIGNAL(hasUndocked()),            this, SLOT(slotParametersClosed()));    // Apparently, hasUndocked() is emitted when the dock widget's    // 'close' button on the dock handle is clicked.    connect(m_mainDockWidget, SIGNAL(docking(KDockWidget*, KDockWidget::DockPosition)),            this, SLOT(slotParametersDockedBack(KDockWidget*, KDockWidget::DockPosition)));    Composition &comp = doc->getComposition();    m_toolBox = new MatrixToolBox(this);    initStatusBar();    connect(m_toolBox, SIGNAL(showContextHelp(const QString &)),            this, SLOT(slotToolHelpChanged(const QString &)));    QCanvas *tCanvas = new QCanvas(this);    m_config->setGroup(MatrixViewConfigGroup);    if (m_config->readBoolEntry("backgroundtextures-1.6-plus", true)) {        QPixmap background;        QString pixmapDir =            KGlobal::dirs()->findResource("appdata", "pixmaps/");	// We now use a lined background for the non-percussion matrix,	// suggested and supplied by Alessandro Preziosi	QString backgroundPixmap = isDrumMode() ? "bg-paper-white.xpm" : "bg-matrix-lines.xpm";        if (background.load(QString("%1/misc/%2").                            arg(pixmapDir, backgroundPixmap))) {            tCanvas->setBackgroundPixmap(background);        }    }    MATRIX_DEBUG << "MatrixView : creating staff\n";    Track *track =        comp.getTrackById(segments[0]->getTrack());    Instrument *instr = getDocument()->getStudio().                        getInstrumentById(track->getInstrument());    int resolution = 8;    if (isDrumMode() && instr && instr->getKeyMapping()) {        resolution = 11;    }    for (unsigned int i = 0; i < segments.size(); ++i) {        m_staffs.push_back(new MatrixStaff(tCanvas,                                           segments[i],                                           m_snapGrid,                                           i,                                           resolution,                                           this));        // staff has one too many rows to avoid a half-row at the top:        m_staffs[i]->setY( -resolution / 2);        //!!!	if (isDrumMode()) m_staffs[i]->setX(resolution);        if (i == 0)            m_staffs[i]->setCurrent(true);    }    MATRIX_DEBUG << "MatrixView : creating canvas view\n";    const MidiKeyMapping *mapping = 0;    if (instr) {        mapping = instr->getKeyMapping();        if (mapping) {            RG_DEBUG << "MatrixView: Instrument has key mapping: "            << mapping->getName() << endl;            m_localMapping = new MidiKeyMapping(*mapping);            extendKeyMapping();        } else {            RG_DEBUG << "MatrixView: Instrument has no key mapping\n";        }    }    m_pianoView = new QDeferScrollView(getCentralWidget());    QWidget* vport = m_pianoView->viewport();    if (isDrumMode() && mapping &&            !m_localMapping->getMap().empty()) {        m_pitchRuler = new PercussionPitchRuler(vport,                                                m_localMapping,                                                resolution); // line spacing    } else {        m_pitchRuler = new PianoKeyboard(vport);    }    m_pianoView->setVScrollBarMode(QScrollView::AlwaysOff);    m_pianoView->setHScrollBarMode(QScrollView::AlwaysOff);    m_pianoView->addChild(m_pitchRuler);    m_pianoView->setFixedWidth(m_pianoView->contentsWidth());    m_grid->addWidget(m_pianoView, CANVASVIEW_ROW, 1);    m_parameterBox = new InstrumentParameterBox(getDocument(), m_dockLeft);    m_dockLeft->setWidget(m_parameterBox);    RosegardenGUIApp *app = RosegardenGUIApp::self();    connect(app,            SIGNAL(pluginSelected(InstrumentId, int, int)),            m_parameterBox,            SLOT(slotPluginSelected(InstrumentId, int, int)));    connect(app,            SIGNAL(pluginBypassed(InstrumentId, int, bool)),            m_parameterBox,            SLOT(slotPluginBypassed(InstrumentId, int, bool)));    connect(app,            SIGNAL(instrumentParametersChanged(InstrumentId)),            m_parameterBox,            SLOT(slotInstrumentParametersChanged(InstrumentId)));    connect(m_parameterBox,            SIGNAL(instrumentParametersChanged(InstrumentId)),            app,            SIGNAL(instrumentParametersChanged(InstrumentId)));    connect(m_parameterBox,            SIGNAL(selectPlugin(QWidget *, InstrumentId, int)),            app,            SLOT(slotShowPluginDialog(QWidget *, InstrumentId, int)));    connect(m_parameterBox,            SIGNAL(showPluginGUI(InstrumentId, int)),            app,            SLOT(slotShowPluginGUI(InstrumentId, int)));    connect(parent,  // RosegardenGUIView            SIGNAL(checkTrackAssignments()),            this,            SLOT(slotCheckTrackAssignments()));    // Assign the instrument    //    m_parameterBox->useInstrument(instr);    if (m_drumMode) {        connect(m_parameterBox,                SIGNAL(instrumentPercussionSetChanged(Instrument *)),                this,                SLOT(slotPercussionSetChanged(Instrument *)));    }    // Set the snap grid from the stored size in the segment    //    int snapGridSize = m_staffs[0]->getSegment().getSnapGridSize();    MATRIX_DEBUG << "MatrixView : Snap Grid Size = " << snapGridSize << endl;    if (snapGridSize != -1) {        m_snapGrid->setSnapTime(snapGridSize);    } else {        m_config->setGroup(MatrixViewConfigGroup);        snapGridSize = m_config->readNumEntry            ("Snap Grid Size", SnapGrid::SnapToBeat);        m_snapGrid->setSnapTime(snapGridSize);        m_staffs[0]->getSegment().setSnapGridSize(snapGridSize);    }    m_canvasView = new MatrixCanvasView(*m_staffs[0],                                        m_snapGrid,                                        m_drumMode,                                        tCanvas,                                        getCentralWidget());    setCanvasView(m_canvasView);    // do this after we have a canvas    setupActions();    setupAddControlRulerMenu();    stateChanged("parametersbox_closed", KXMLGUIClient::StateReverse);    // tool bars    initActionsToolbar();    initZoomToolbar();    // Connect vertical scrollbars between matrix and piano    //    connect(m_canvasView->verticalScrollBar(), SIGNAL(valueChanged(int)),            this, SLOT(slotVerticalScrollPianoKeyboard(int)));    connect(m_canvasView->verticalScrollBar(), SIGNAL(sliderMoved(int)),            this, SLOT(slotVerticalScrollPianoKeyboard(int)));    connect(m_canvasView, SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));    connect(m_canvasView, SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));    connect(m_pianoView, SIGNAL(gotWheelEvent(QWheelEvent*)),            m_canvasView, SLOT(slotExternalWheelEvent(QWheelEvent*)));    // ensure the piano keyb keeps the right margins when the user toggles    // the canvas view rulers    //    connect(m_canvasView, SIGNAL(bottomWidgetHeightChanged(int)),            this, SLOT(slotCanvasBottomWidgetHeightChanged(int)));    connect(m_canvasView, SIGNAL(mouseEntered()),            this, SLOT(slotMouseEnteredCanvasView()));    connect(m_canvasView, SIGNAL(mouseLeft()),            this, SLOT(slotMouseLeftCanvasView()));    /*    QObject::connect        (getCanvasView(), SIGNAL(activeItemPressed(QMouseEvent*, QCanvasItem*)),         this,            SLOT  (activeItemPressed(QMouseEvent*, QCanvasItem*)));         */    QObject::connect    (getCanvasView(),     SIGNAL(mousePressed(timeT,                         int, QMouseEvent*, MatrixElement*)),     this,     SLOT(slotMousePressed(timeT,                           int, QMouseEvent*, MatrixElement*)));    QObject::connect    (getCanvasView(),     SIGNAL(mouseMoved(timeT, int, QMouseEvent*)),     this,     SLOT(slotMouseMoved(timeT, int, QMouseEvent*)));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -