void View::DrawHorizontalLine ( DeviceContext *dc, int x1, int x2, int y1, int nbr) { assert( dc ); dc->SetPen( m_currentColour, std::max( 1, ToDeviceContextX(nbr) ), AxSOLID ); dc->SetBrush( m_currentColour, AxSOLID ); dc->DrawLine( ToDeviceContextX(x1) , ToDeviceContextY(y1), ToDeviceContextX(x2), ToDeviceContextY(y1) ); dc->ResetPen(); dc->ResetBrush(); return; }
void View::DrawMensurHalfCircle(DeviceContext *dc, int x, int yy, Staff *staff) { assert(dc); assert(staff); int lineWidth = m_doc->GetDrawingStaffLineWidth(staff->m_drawingStaffSize); dc->SetPen(m_currentColour, lineWidth, AxSOLID); dc->SetBrush(m_currentColour, AxTRANSPARENT); /* DrawEllipticArc expects x and y to specify the coordinates of the upper-left corner of the rectangle that contains the ellipse; y is not the center of the circle it's an arc of. */ double halfDistBelowTop = MSIGN_STAFFLINES_BELOW_TOP - (MSIGN_CIRCLE_DIAM / 2.0); int y = ToDeviceContextY(yy - m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * halfDistBelowTop); int r = ToDeviceContextX(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize)); r = (int)(MSIGN_CIRCLE_DIAM / 2.0 * r); x = ToDeviceContextX(x); x -= 3 * r / 3; dc->DrawEllipticArc(x, y, 2 * r, 2 * r, 45, 315); dc->ResetPen(); dc->ResetBrush(); return; }
void View::DrawLyricString ( DeviceContext *dc, int x, int y, std::wstring s, int staffSize) { assert( dc ); dc->StartText( ToDeviceContextX( x ), ToDeviceContextY( y ) ); std::wistringstream iss( s ); std::wstring token; while( std::getline( iss, token, L'_' )) { dc->DrawText( UTF16to8( token.c_str() ), token ); // no _ if (iss.eof()) break; FontInfo vrvTxt; vrvTxt.SetFaceName("VerovioText"); vrvTxt.SetPointSize( m_doc->GetDrawingLyricFont(staffSize)->GetPointSize() ); dc->SetFont( &vrvTxt ); dc->VrvTextFont(); std::wstring str; str.push_back(VRV_TEXT_E551); dc->DrawText( UTF16to8( str.c_str() ), str ); dc->ResetFont(); } //std::wcout << std::endl; dc->EndText( ); }
void View::DrawDot ( DeviceContext *dc, int x, int y, int staffSize ) { int r = std::max( ToDeviceContextX( m_doc->GetDrawingDoubleUnit( staffSize ) / 5 ), 2 ); dc->SetPen( m_currentColour, 1, AxSOLID ); dc->SetBrush( m_currentColour, AxSOLID ); dc->DrawCircle( ToDeviceContextX(x) , ToDeviceContextY(y), r ); dc->ResetPen(); dc->ResetBrush(); }
void View::DrawObliquePolygon ( DeviceContext *dc, int x1, int y1, int x2, int y2, int height) { Point p[4]; dc->SetPen( m_currentColour, 0, AxSOLID ); dc->SetBrush( m_currentColour, AxSOLID ); height = ToDeviceContextX(height); p[0].x = ToDeviceContextX(x1); p[0].y = ToDeviceContextY(y1); p[1].x = ToDeviceContextX(x2); p[1].y = ToDeviceContextY(y2); p[2].x = p[1].x; p[2].y = p[1].y - height; p[3].x = p[0].x; p[3].y = p[0].y - height; dc->DrawPolygon ( 4, p ); dc->ResetPen(); dc->ResetBrush(); }
void View::DrawFullRectangle( DeviceContext *dc, int x1, int y1, int x2, int y2 ) /* dessine rectangle plein */ { assert( dc ); SwapY( &y1, &y2 ); dc->SetPen( m_currentColour, 0, AxSOLID ); dc->SetBrush( m_currentColour, AxSOLID ); dc->DrawRectangle( ToDeviceContextX( x1 ), ToDeviceContextY(y1), ToDeviceContextX(x2 - x1) , ToDeviceContextX( y1 - y2 )); dc->ResetPen(); dc->ResetBrush(); return; }
void View::DrawMensurCircle(DeviceContext *dc, int x, int yy, Staff *staff) { assert(dc); assert(staff); int y = ToDeviceContextY(yy - m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * MSIGN_STAFFLINES_BELOW_TOP); int r = ToDeviceContextX(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize)); r = (int)(MSIGN_CIRCLE_DIAM / 2.0 * r); int lineWidth = m_doc->GetDrawingStaffLineWidth(staff->m_drawingStaffSize); dc->SetPen(m_currentColour, lineWidth, AxSOLID); dc->SetBrush(m_currentColour, AxTRANSPARENT); dc->DrawCircle(ToDeviceContextX(x), y, r); dc->ResetPen(); dc->ResetBrush(); }
void View::DrawMensurDot(DeviceContext *dc, int x, int yy, Staff *staff) { assert(dc); assert(staff); int y = ToDeviceContextY(yy - m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * MSIGN_STAFFLINES_BELOW_TOP); int r = m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * MSIGN_DOT_DIAM; dc->SetPen(m_currentColour, 1, AxSOLID); dc->SetBrush(m_currentColour, AxSOLID); dc->DrawCircle(ToDeviceContextX(x), y, r); dc->ResetPen(); dc->ResetBrush(); return; }
/* Draw rectangle partly filled in, as specified by <fillSection>: 1=top, 2=bottom, 3=left side, 4=right side; 0=don't fill in any part. ??SO FAR, <fillSection> IS IGNORED. */ void View::DrawPartFullRectangle( DeviceContext *dc, int x1, int y1, int x2, int y2, int fillSection ) { assert( dc ); // DC cannot be NULL SwapY( &y1, &y2 ); //dc->SetPen( m_currentColour, 0, AxSOLID ); //dc->SetBrush( AxWHITE, AxTRANSPARENT ); dc->SetPen( AxBLUE, 0, AxSOLID ); dc->SetBrush( AxRED, AxTRANSPARENT ); dc->DrawRectangle( ToDeviceContextX( x1 ), ToDeviceContextY(y1), ToDeviceContextX(x2 - x1) , ToDeviceContextX( y1 - y2 )); dc->ResetPen(); dc->ResetBrush(); return; }
void View::DrawSmuflString ( DeviceContext *dc, int x, int y, std::wstring s, bool center, int staffSize) { assert( dc ); int xDC = ToDeviceContextX(x); if ( center ) { int w, h; dc->GetSmuflTextExtent( s, &w, &h ); xDC -= w / 2; } dc->SetBrush( m_currentColour, AxSOLID ); dc->SetFont( m_doc->GetDrawingSmuflFont(staffSize, 0) ); dc->DrawMusicText( s, xDC, ToDeviceContextY(y) ); dc->ResetFont(); dc->ResetBrush(); }
void View::DrawSmuflCode ( DeviceContext *dc, int x, int y, wchar_t code, int staffSize, bool dimin ) { assert( dc ); dc->SetBackground( AxBLUE ); dc->SetBackgroundMode( AxTRANSPARENT ); std::wstring str; str.push_back(code); dc->SetBrush( m_currentColour, AxSOLID ); dc->SetFont( m_doc->GetDrawingSmuflFont(staffSize, dimin) ); dc->DrawMusicText( str, ToDeviceContextX(x), ToDeviceContextY(y) ); dc->ResetFont(); dc->ResetBrush(); return; }
void View::DrawMensurReversedHalfCircle(DeviceContext *dc, int x, int yy, Staff *staff) { assert(dc); assert(staff); dc->SetPen(m_currentColour, m_doc->GetDrawingStaffLineWidth(staff->m_drawingStaffSize), AxSOLID); dc->SetBrush(m_currentColour, AxTRANSPARENT); int y = ToDeviceContextY(yy - m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize)); int r = ToDeviceContextX(m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize)); // needs to be fixed x = ToDeviceContextX(x); x -= 4 * r / 3; dc->DrawEllipticArc(x, y, 2 * r, 2 * r, 225, 135); dc->ResetPen(); dc->ResetBrush(); return; }
void View::DrawMensurHalfCircle( DeviceContext *dc, int x, int yy, Staff *staff ) { assert( dc ); assert( staff ); dc->SetPen( m_currentColour, m_doc->GetDrawingStaffLineWidth(staff->m_drawingStaffSize), AxSOLID ); dc->SetBrush( m_currentColour, AxTRANSPARENT ); int y = ToDeviceContextY (yy - m_doc->GetDrawingDoubleUnit( staff->m_drawingStaffSize ) * MCIRCLE_STAFFLINES_BELOW_TOP); int r = ToDeviceContextX( m_doc->GetDrawingDoubleUnit( staff->m_drawingStaffSize )); r = (int)(MCIRCLE_RADIUS_FACTOR*r); x = ToDeviceContextX (x); x -= 3*r/3; dc->DrawEllipticArc( x, y, 2*r, 2*r, 45, 315 ); dc->ResetPen(); dc->ResetBrush(); return; }
void View::DrawThickBezierCurve(DeviceContext *dc, Point p1, Point p2, Point c1, Point c2, int thickness, int staffSize, float angle) { assert( dc ); int bez1[6], bez2[6]; // filled array with control points and end point Point c1Rotated = c1; Point c2Rotated = c2; c1Rotated.y += thickness / 2; c2Rotated.y += thickness / 2; if (angle != 0.0) { c1Rotated = CalcPositionAfterRotation(c1Rotated, angle, c1); c2Rotated = CalcPositionAfterRotation(c2Rotated, angle, c2); } // Points for first bez, they go from xy to x1y1 bez1[0] = ToDeviceContextX(c1Rotated.x); bez1[1] = ToDeviceContextY(c1Rotated.y); bez1[2] = ToDeviceContextX(c2Rotated.x); bez1[3] = ToDeviceContextY(c2Rotated.y); bez1[4] = ToDeviceContextX(p2.x); bez1[5] = ToDeviceContextY(p2.y); c1Rotated = c1; c2Rotated = c2; c1Rotated.y -= thickness / 2; c2Rotated.y -= thickness / 2; if (angle != 0.0) { c1Rotated = CalcPositionAfterRotation(c1Rotated, angle, c1); c2Rotated = CalcPositionAfterRotation(c2Rotated, angle, c2); } // second bez. goes back bez2[0] = ToDeviceContextX(c2Rotated.x); bez2[1] = ToDeviceContextY(c2Rotated.y); bez2[2] = ToDeviceContextX(c1Rotated.x); bez2[3] = ToDeviceContextY(c1Rotated.y); bez2[4] = ToDeviceContextX(p1.x); bez2[5] = ToDeviceContextY(p1.y); // Actually draw it dc->SetPen( m_currentColour, std::max( 1, m_doc->GetDrawingStemWidth(staffSize) / 2 ), AxSOLID ); dc->DrawComplexBezierPath(ToDeviceContextX(p1.x), ToDeviceContextY(p1.y), bez1, bez2); dc->ResetPen(); }
Point View::ToDeviceContext(Point p) { return Point(ToDeviceContextX(p.x), ToDeviceContextY(p.y)); }
void View::DrawTupletPostponed(DeviceContext *dc, Tuplet *tuplet, Layer *layer, Staff *staff) { assert(dc); assert(tuplet); assert(layer); assert(staff); if ((tuplet->GetBracketVisible() == BOOLEAN_false) && (tuplet->GetNumVisible() == BOOLEAN_false)) { tuplet->SetEmptyBB(); return; } tuplet->ResetList(tuplet); int txt_length = 0; int txt_height = 0; std::wstring notes; // dc->SetFont(m_doc->GetDrawingSmuflFont(staff->m_drawingStaffSize, tuplet->IsCueSize())); if (tuplet->GetNum() > 0) { notes = IntToTupletFigures((short int)tuplet->GetNum()); dc->GetSmuflTextExtent(notes, &txt_length, &txt_height); } Point start, end, center; data_STEMDIRECTION direction = GetTupletCoordinates(tuplet, layer, &start, &end, ¢er); // Calculate position for number 0x82 // since the number is slanted, move the center left // by 4 pixels so it seems more centered to the eye int txt_x = center.x - (txt_length / 2); // we need to move down the figure of half of it height, which is about an accid width; // also, cue size is not supported. Does it has to? int txt_y = center.y - m_doc->GetGlyphWidth(SMUFL_E262_accidentalSharp, staff->m_drawingStaffSize, tuplet->IsCueSize()); if (tuplet->GetNum() && (tuplet->GetNumVisible() != BOOLEAN_false)) { DrawSmuflString(dc, txt_x, txt_y, notes, false, staff->m_drawingStaffSize); } dc->ResetFont(); // Nothing to do if the bracket is not visible if (tuplet->GetBracketVisible() == BOOLEAN_false) { return; } int verticalLine = m_doc->GetDrawingUnit(100); dc->SetPen(m_currentColour, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize), AxSOLID); // Start is 0 when no line is necessary (i.e. beamed notes) if (start.x > 0) { // Draw the bracket, interrupt where the number is // get the slope double m = (double)(start.y - end.y) / (double)(start.x - end.x); // x = 10 pixels before the number int x = txt_x - 40; // xa = just after, the number is abundant so I do not add anything int xa = txt_x + txt_length + 20; // calculate the y coords in the slope double y1 = (double)start.y + m * (x - (double)start.x); double y2 = (double)start.y + m * (xa - (double)start.x); if (tuplet->GetNumVisible() == BOOLEAN_false) { // one single line dc->DrawLine(start.x, ToDeviceContextY(start.y), end.x, ToDeviceContextY((int)y1)); } else { // first line dc->DrawLine(start.x, ToDeviceContextY(start.y), (int)x, ToDeviceContextY((int)y1)); // second line after gap dc->DrawLine((int)xa, ToDeviceContextY((int)y2), end.x, ToDeviceContextY(end.y)); } // vertical bracket lines if (direction == STEMDIRECTION_up) { dc->DrawLine(start.x, ToDeviceContextY(start.y), start.x, ToDeviceContextY(start.y - verticalLine)); dc->DrawLine(end.x, ToDeviceContextY(end.y), end.x, ToDeviceContextY(end.y - verticalLine)); } else { dc->DrawLine(start.x, ToDeviceContextY(start.y), start.x, ToDeviceContextY(start.y + verticalLine)); dc->DrawLine(end.x, ToDeviceContextY(end.y), end.x, ToDeviceContextY(end.y + verticalLine)); } } dc->ResetPen(); }
void View::DrawTupletPostponed(DeviceContext *dc, Tuplet *tuplet, Layer *layer, Staff *staff) { assert(dc); assert(tuplet); assert(layer); assert(staff); if ((tuplet->GetBracketVisible() == BOOLEAN_false) && (tuplet->GetNumVisible() == BOOLEAN_false)) { tuplet->SetEmptyBB(); return; } tuplet->ResetList(tuplet); TextExtend extend; std::wstring notes; Point start, end, center; data_STEMDIRECTION direction = GetTupletCoordinates(tuplet, layer, &start, &end, ¢er); int x1 = center.x, x2 = center.x; // draw tuplet numerator if ((tuplet->GetNum() > 0) && (tuplet->GetNumVisible() != BOOLEAN_false)) { bool drawingCueSize = tuplet->GetDrawingCueSize(); dc->SetFont(m_doc->GetDrawingSmuflFont(staff->m_drawingStaffSize, drawingCueSize)); notes = IntToTupletFigures((short int)tuplet->GetNum()); if (tuplet->GetNumFormat() == tupletVis_NUMFORMAT_ratio) { notes.push_back(SMUFL_E88A_tupletColon); notes = notes + IntToTupletFigures((short int)tuplet->GetNumbase()); } dc->GetSmuflTextExtent(notes, &extend); // Calculate position for number 0x82 // since the number is slanted, move the center left int txtX = x1 - (extend.m_width / 2); // and move it further, when it is under the stave if (direction == STEMDIRECTION_down) { txtX -= staff->m_drawingStaffSize; } // we need to move down the figure of half of it height, which is about an accid width; // also, cue size is not supported. Does it has to? int txt_y = center.y - m_doc->GetGlyphWidth(SMUFL_E262_accidentalSharp, staff->m_drawingStaffSize, drawingCueSize); DrawSmuflString(dc, txtX, txt_y, notes, false, staff->m_drawingStaffSize); // x1 = 10 pixels before the number x1 = ((txtX - 40) > start.x) ? txtX - 40 : start.x; // x2 = just after, the number is abundant so I do not add anything x2 = txtX + extend.m_width + 20; dc->ResetFont(); } // Nothing to do if the bracket is not visible if (tuplet->GetBracketVisible() == BOOLEAN_false) { return; } // If all tuplets beamed draw no bracket by default if (OneBeamInTuplet(tuplet) && !(tuplet->GetBracketVisible() == BOOLEAN_true)) { return; } int verticalLine = m_doc->GetDrawingUnit(100); dc->SetPen(m_currentColour, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize), AxSOLID); // Draw the bracket, interrupt where the number is // get the slope double m = (double)(start.y - end.y) / (double)(start.x - end.x); // calculate the y coords in the slope double y1 = (double)start.y + m * (x1 - (double)start.x); double y2 = (double)start.y + m * (x2 - (double)start.x); if (tuplet->GetNumVisible() == BOOLEAN_false) { // one single line dc->DrawLine(start.x, ToDeviceContextY(start.y), end.x, ToDeviceContextY(end.y)); } else { // first line dc->DrawLine(start.x, ToDeviceContextY(start.y), (int)x1, ToDeviceContextY((int)y1)); // second line after gap dc->DrawLine((int)x2, ToDeviceContextY((int)y2), end.x, ToDeviceContextY(end.y)); } // vertical bracket lines if (direction == STEMDIRECTION_up) { dc->DrawLine(start.x + m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(start.y), start.x + m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(start.y - verticalLine)); dc->DrawLine(end.x - m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(end.y), end.x - m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(end.y - verticalLine)); } else { dc->DrawLine(start.x + m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(start.y), start.x + m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(start.y + verticalLine)); dc->DrawLine(end.x - m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(end.y), end.x - m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) / 2, ToDeviceContextY(end.y + verticalLine)); } dc->ResetPen(); }
void View::DrawTuplet( DeviceContext *dc, Tuplet *tuplet, Layer *layer, Staff *staff) { assert(layer); // Pointer to layer cannot be NULL" assert(staff); // Pointer to staff cannot be NULL" tuplet->ResetList(tuplet); int txt_lenght, txt_height; std::string notes = IntToObliqueFigures((short int)tuplet->GetNum()); dc->GetTextExtent(notes, &txt_lenght, &txt_height); MusPoint start, end, center; bool direction = GetTupletCoordinates(tuplet, layer, &start, &end, ¢er); // Calculate position for number 0x82 // since the number is slanted, move the center left // by 4 pixels so it seems more centered to the eye int txt_x = center.x - (txt_lenght / 2) - 4; //DrawLeipzigFont ( dc, txt_x, center.y, notes + 0x82, staff, false); DrawLeipzigString(dc, txt_x, center.y, notes, 0); //dc->SetPen(AxBLACK); dc->SetPen(AxBLACK, 2, AxSOLID); // Start is 0 when no line is necessary (i.e. beamed notes) if (start.x > 0) { // Draw the bracket, interrupt where the number is // get the slope double m = (double)(start.y - end.y) / (double)(start.x - end.x); // x = 10 pixels before the number double x = txt_x - 4; // xa = just after, the number is abundant so I do not add anything double xa = txt_x + txt_lenght + 2; // calculate the y coords in the slope double y1 = (double)start.y + m * (x - (double)start.x); double y2 = (double)start.y + m * (xa - (double)start.x); // first line dc->DrawLine(start.x, ToDeviceContextY(start.y), (int)x, ToDeviceContextY((int)y1)); // second line after gap dc->DrawLine((int)xa, ToDeviceContextY((int)y2), end.x, ToDeviceContextY(end.y)); // vertical bracket lines if (direction) { dc->DrawLine(start.x, ToDeviceContextY(start.y), start.x, ToDeviceContextY(start.y - 10)); dc->DrawLine(end.x, ToDeviceContextY(end.y), end.x, ToDeviceContextY(end.y - 10)); } else { dc->DrawLine(start.x, ToDeviceContextY(start.y), start.x, ToDeviceContextY(start.y + 10)); dc->DrawLine(end.x, ToDeviceContextY(end.y), end.x, ToDeviceContextY(end.y + 10)); } } //rz dc->EndGraphic(element, this ); }