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

📄 notesymbols.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* -*- 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.    This file contains code from     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 "NoteSymbols.h"#include "Fingering.h"#include "misc/Debug.h"namespace Rosegarden{namespace Guitar{NoteSymbols::posPairNoteSymbols::getX ( int imgWidth, unsigned int stringNb, unsigned int nbOfStrings ) const{    /*            std::cout << "NoteSymbols::getX - input values" << std::endl            << "  position: " << position << std::endl            << "  string #: " << string_num << std::endl            << "  scale:    " << scale << std::endl;    */    unsigned int lBorder = getLeftBorder( imgWidth );    unsigned int guitarChordWidth = getGuitarChordWidth( imgWidth );    unsigned int columnWidth = guitarChordWidth / nbOfStrings;    return std::make_pair( ( stringNb * columnWidth + lBorder ), columnWidth );}NoteSymbols::posPairNoteSymbols::getY ( int imgHeight, unsigned int fretNb, unsigned int nbOfFrets ) const{    /*            std::cout << "NoteSymbols::getY - input values" << std::endl            << "  position: " << fret_pos << std::endl            << "  max frets:   " << maxFretNum << std::endl            << "  scale:    " << scale << std::endl;    */    unsigned int tBorder = getTopBorder( imgHeight );    unsigned int guitarChordHeight = getGuitarChordHeight( imgHeight );    unsigned int rowHeight = guitarChordHeight / nbOfFrets;    return std::make_pair( ( ( fretNb * rowHeight ) + tBorder ), rowHeight );}voidNoteSymbols::drawMuteSymbol ( QPainter* p,                              unsigned int position ) const{    QRect v = p->viewport();    posPair x_pos = getX ( v.width(), position, m_nbOfStrings );    unsigned int y_pos = getTopBorder( v.height() ) / 2;    double columnWidth = x_pos.second;    unsigned int width = static_cast<unsigned int>( columnWidth * 0.7 );    unsigned int height = static_cast<unsigned int>( columnWidth * 0.7 );    //std::cout << "NoteSymbols::drawMuteSymbol - drawing Mute symbol at string #" << position    //<< std::endl;    p->drawLine ( x_pos.first - ( width / 2 ),                  y_pos - ( height / 2 ),                  ( x_pos.first + ( width / 2 ) ),                  y_pos + ( height / 2 ) );    p->drawLine( x_pos.first + ( width / 2 ),                 y_pos - ( height / 2 ),                 ( x_pos.first - ( width / 2 ) ),                 y_pos + ( height / 2 ) );}voidNoteSymbols::drawOpenSymbol ( QPainter* p,                              unsigned int position ) const{    QRect v = p->viewport();    posPair x_pos = getX ( v.width(), position, m_nbOfStrings );    unsigned int y_pos = getTopBorder( v.height() ) / 2;    double columnWidth = x_pos.second;    unsigned int radius = static_cast<unsigned int>( columnWidth * 0.7 );    //std::cout << "NoteSymbols::drawOpenSymbol - drawing Open symbol at string #" << position    //<< std::endl;    p->setBrush( QBrush(p->brush().color(), Qt::NoBrush) );    p->drawEllipse( x_pos.first - ( radius / 2 ),                    y_pos - ( radius / 2 ),                    radius,                    radius );}voidNoteSymbols::drawNoteSymbol ( QPainter* p,                              unsigned int stringNb,                              int fretNb,                              bool transient ) const{//    NOTATION_DEBUG << "NoteSymbols::drawNoteSymbol - string: " << stringNb << ", fret:" << fretNb << endl;    QRect v = p->viewport();    posPair x_pos = getX ( v.width(), stringNb, m_nbOfStrings );    posPair y_pos = getY ( v.height(), fretNb, m_nbOfFrets );    double columnWidth = x_pos.second;    unsigned int radius;    if (transient) {        radius =  static_cast<unsigned int>( columnWidth /* * 0.9 */ );        p->setBrush( QBrush(p->brush().color(), Qt::NoBrush) );    } else {        radius =  static_cast<unsigned int>( columnWidth * 0.7 );        p->setBrush( QBrush(p->brush().color(), Qt::SolidPattern) );    }    int x = x_pos.first - ( radius / 2 ),        y = y_pos.first + ( (y_pos.second - radius) / 2) - y_pos.second + TOP_GUITAR_CHORD_MARGIN; //        y = y_pos.first - (radius / 2) - y_pos.second + TOP_GUITAR_CHORD_MARGIN;//    RG_DEBUG << "NoteSymbols::drawNoteSymbol : rect = " << QRect(x,y, radius, radius) << endl;    p->drawEllipse( x,                    y,                    radius,                    radius );                    //    p->save();//    p->setPen(Qt::red);//    p->drawRect( x, y, radius, radius );//    p->restore();}voidNoteSymbols::drawBarreSymbol ( QPainter* p,                               int fretNb,                               unsigned int start,                               unsigned int end ) const{    //std::cout << "NoteSymbols::drawBarreSymbol - start: " << start << ", end:" << end << std::endl;    drawNoteSymbol ( p, start, fretNb );    if ( ( end - start ) >= 1 ) {        QRect v = p->viewport();        posPair startXPos = getX ( v.width(), start, m_nbOfStrings );        posPair endXPos = getX ( v.width(), end, m_nbOfStrings );        posPair y_pos = getY ( v.height(), fretNb, m_nbOfFrets );        double columnWidth = startXPos.second;        unsigned int thickness = static_cast<unsigned int>( columnWidth * 0.7 );        p->drawRect( startXPos.first,                     y_pos.first + ( y_pos.second / 4 ) + TOP_GUITAR_CHORD_MARGIN,                     endXPos.first - startXPos.first,                     thickness );    }    drawNoteSymbol ( p, end, fretNb );}voidNoteSymbols::drawFretNumber ( QPainter* p,                              unsigned int fret_num ) const{    if ( fret_num > 1 ) {        QRect v = p->viewport();        unsigned int imgWidth = v.width();        unsigned int imgHeight = v.height();        p->save();        QFont font;        font.setPixelSize(getFontPixelSize(v.width(), v.height()));        p->setFont(font);        QString tmp;        tmp.setNum( fret_num );        // Use NoteSymbols to grab X and Y for first fret        posPair y_pos = getY( imgHeight, 0, m_nbOfFrets );        p->drawText( getLeftBorder( imgWidth ) / 4,                     y_pos.first + ( y_pos.second / 2 ),                     tmp );        p->restore();    }}voidNoteSymbols::drawFrets ( QPainter* p ) const{    /*            std::cout << "NoteSymbols::drawFretHorizontalLines" << std::endl            << "  scale: " << scale << std::endl            << "  frets: " << fretsDisplayed << std::endl            << "  max string: " << maxStringNum << std::endl;    */    QRect v = p->viewport();    unsigned int imgWidth = v.width();    unsigned int imgHeight = v.height();    //unsigned int endXPos = getGuitarChordWidth(imgWidth) + getLeftBorder(imgWidth);    posPair endXPos = getX ( imgWidth, m_nbOfStrings - 1, m_nbOfStrings );    unsigned int yGuitarChord = getGuitarChordHeight( imgHeight );    unsigned int rowHeight = yGuitarChord / m_nbOfFrets;    QPen pen(p->pen());    pen.setWidth(imgHeight >= 100 ? FRET_PEN_WIDTH : FRET_PEN_WIDTH / 2);      p->save();    p->setPen(pen);    unsigned int y_pos = (getY ( imgHeight, 0, m_nbOfFrets )).first + TOP_GUITAR_CHORD_MARGIN;    //    NOTATION_DEBUG << "NoteSymbols::drawFrets : " << m_nbOfFrets << endl;        // Horizontal lines    for ( unsigned int i = 0; i <= m_nbOfFrets; ++i ) {        /* This code borrowed from KGuitar 0.5 */        p->drawLine( getLeftBorder( imgWidth ),                     y_pos,                     endXPos.first,                     y_pos);//        NOTATION_DEBUG << "NoteSymbols::drawFrets : " << QPoint(getLeftBorder(imgWidth), y_pos)//                       << " to " << QPoint(endXPos.first, y_pos) << endl;                     

⌨️ 快捷键说明

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