add VBox to the top

This commit is contained in:
Liang Chen 2016-05-26 16:57:45 -04:00
parent 438fbd02f2
commit 54ed1c9081
2 changed files with 43 additions and 32 deletions

View file

@ -38,6 +38,8 @@
#include "libmscore/timesig.h"
#include "libmscore/keysig.h"
#include "libmscore/spacer.h"
#include "libmscore/box.h"
#include "libmscore/spatium.h"
namespace Ms {
@ -47,11 +49,11 @@ namespace Ms {
class OmrState {
public:
Score* score = 0;
MasterScore* score = 0;
Fraction timesig { 4, 4};
int tick = 0;
void importPdfPage(OmrPage* omrPage, int top);
void importPdfPage(OmrPage* omrPage, qreal top);
int importPdfSystem(OmrSystem* omrSystem);
void importPdfMeasure(OmrMeasure* m, const OmrSystem* omrSystem);
};
@ -185,13 +187,25 @@ int OmrState::importPdfSystem(OmrSystem* omrSystem)
// importPdfPage
//---------------------------------------------------------
void OmrState::importPdfPage(OmrPage* omrPage, int top)
void OmrState::importPdfPage(OmrPage* omrPage, qreal top)
{
TDuration d(TDuration::DurationType::V_MEASURE);
int tick = 0;
int nsystems = omrPage->systems().size();
if(nsystems == 0) return;
//add top margin for alignment
MeasureBase* first_measure = score->first();
if (first_measure == 0 || first_measure->type() != Element::Type::VBOX) {
VBox* vbox = new VBox(score);
vbox->setNext(score->first());
vbox->setTick(0);
vbox->setBoxHeight(Spatium(top));
vbox->setBottomMargin(0);
vbox->setBottomGap(0);
score->measures()->add(vbox);
}
//int n = nsystems == 0 ? 1 : nsystems;
for (int k = 0; k < nsystems; ++k) {
@ -245,10 +259,7 @@ void OmrState::importPdfPage(OmrPage* omrPage, int top)
sp->layout();
sp->setPos(sp->rxpos(), top);
}
}
//---------------------------------------------------------
// importPdf
@ -270,6 +281,7 @@ Score::FileError importPdf(MasterScore* score, const QString& path)
score->style()->set(StyleIdx::lastSystemFillLimit, 0.0);
score->style()->set(StyleIdx::staffLowerBorder, 0.0);
score->style()->set(StyleIdx::measureSpacing, 1.0);
score->style()->set(StyleIdx::frameSystemDistance, 0);
PageFormat pF;
pF.copy(*score->pageFormat());
@ -285,7 +297,6 @@ Score::FileError importPdf(MasterScore* score, const QString& path)
score->style()->set(StyleIdx::maxSystemDistance, Spatium(omr->systemDistance()));
score->style()->set(StyleIdx::akkoladeDistance, Spatium(omr->staffDistance()));
//incomplete implementation for musescore skeletion creation
Part* part = new Part(score);
OmrPage* omrPage = omr->pages().front();
@ -304,7 +315,7 @@ Score::FileError importPdf(MasterScore* score, const QString& path)
state.score = score;
foreach (OmrPage* omrPage, omr->pages()) {
OmrStaff staff = omrPage->systems().last().staves().first();
int top = staff.top();
qreal top = staff.top()/omr->spatium();
state.importPdfPage(omrPage, top);
}

View file

@ -34,19 +34,18 @@
#include "pattern.h"
namespace Ms {
//static const double noteTH = 1.0;
static const double timesigTH = 0.7;
//static const double clefTH = 0.7;
static const double keysigTH = 0.8;
struct Hv {
int x;
int val;
Hv(int a, int b) : x(a), val(b) {}
bool operator< (const Hv& a) const { return a.val < val; }
};
//static const double noteTH = 1.0;
static const double timesigTH = 0.7;
//static const double clefTH = 0.7;
static const double keysigTH = 0.8;
struct Hv {
int x;
int val;
Hv(int a, int b) : x(a), val(b) {}
bool operator< (const Hv& a) const { return a.val < val; }
};
struct Peak {
int x;
double val;
@ -231,10 +230,11 @@ float OmrPage::searchBarLines(int start_staff, int end_staff)
//---------------------------------------------------------
// identifySystems
//---------------------------------------------------------
void OmrPage::identifySystems(){
int numStaves = staves.size();
if (numStaves == 0) return;
void OmrPage::identifySystems()
{
int numStaves = staves.size();
if(numStaves == 0) return;
//memory allocation
float **temp_scores = new float*[numStaves];
for (int i = 0; i < numStaves; i++)
@ -487,11 +487,11 @@ OmrTimesig* OmrPage::searchTimeSig(OmrSystem* system)
double zval = 0;
double nval = 0;
QRect rz, rn;
int y = system->staves().front().y();
int y = system->staves().front().y();
OmrMeasure* m = &system->measures().front();
int x1 = m->x1();
int x1 = m->x1();
for (int i = 0; i < 10; ++i) {
Pattern* pattern = Omr::timesigPattern[i];
double val = 0.0;
@ -938,14 +938,14 @@ void OmrSystem::searchNotes()
qSort(r->notes().begin(), r->notes().end(), noteCompare);
}
}
//---------------------------------------------------------
// addText
//---------------------------------------------------------
#ifdef OCR
static void addText(Score* score, int subtype, const QString& s)
{
{
#if 0 //TODO-1
MeasureBase* measure = score->first();
if (measure == 0 || measure->type() != Element::VBOX) {