//#define DEBUG void SymList::compute_subgroup() { Matrix2D<DOUBLE> I(4, 4); I.initIdentity(); Matrix2D<DOUBLE> L1(4, 4), R1(4, 4), L2(4, 4), R2(4, 4), newL(4, 4), newR(4, 4); Matrix2D<int> tried(true_symNo, true_symNo); int i, j; int new_chain_length; while (found_not_tried(tried, i, j, true_symNo)) { tried(i, j) = 1; get_matrices(i, L1, R1); get_matrices(j, L2, R2); newL = L1 * L2; newR = R1 * R2; new_chain_length = __chain_length(i) + __chain_length(j); Matrix2D<DOUBLE> newR3 = newR; newR3.resize(3,3); if (newL.isIdentity() && newR3.isIdentity()) continue; // Try to find it in current ones bool found; found = false; for (int l = 0; l < SymsNo(); l++) { get_matrices(l, L1, R1); if (newL.equal(L1) && newR.equal(R1)) { found = true; break; } } if (!found) { //#define DEBUG #ifdef DEBUG std::cout << "Matrix size " << tried.Xdim() << " " << "trying " << i << " " << j << " " << "chain length=" << new_chain_length << std::endl; std::cout << "Result R Sh\n" << newR; #endif #undef DEBUG newR.setSmallValuesToZero(); newL.setSmallValuesToZero(); add_matrices(newL, newR, new_chain_length); tried.resize(MAT_YSIZE(tried) + 1, MAT_XSIZE(tried) + 1); } } }
void Label::adjustzWindowRect() { Window::adjustzWindowRect(); zRect r( rectangle.x, rectangle.y, rectangle.x + rectangle.cx, rectangle.y + rectangle.cy ); // struct Rectangle border = getFormWindow()->getFormArea(); r += zPoint( 10, 25 ); zDialogUnit duA( r.left(), r.top() ); zDialogUnit duB( r.right(), r.bottom() ); zRect newR( duA.physical().x(), duA.physical().y(), duB.physical().x(), duB.physical().y() ); window->move( newR ); }
/** * In most cases it returns only single element list because subtracting can be resolved with only one rhythm value. */ void Trhythm::sub(const Trhythm& r, TrhythmList& remained) const { if (r.rhythm() == e_none) { remained << *this; qDebug() << "[Trhythm] subtracting null rhythm! IS IT REALLY NECESSARY?"; } else { if (r.isTriplet() != isTriplet()) { // TODO: It has to be solved by changing main note qDebug() << "[Trhythm] Subtracting triplets and no triplets unsupported"; return; } int baseDur = duration(); int subDur = r.duration(); if (subDur > baseDur) { qDebug() << "[Trhythm] Subtracting rhythm" << r.duration() << "is greater than" << duration(); return; } if (baseDur - subDur == 0) { // Return empty (null) rhythm when rhythms are the same remained << Trhythm(e_none); return; } Trhythm newR(baseDur - subDur, isRest()); if (newR.rhythm() != e_none) { // In most cases subtracting returns single rhythm remained << newR; return; } if (r.isTriplet() || isTriplet()) // There is no support for subtracting triplets into multiple notes return; if (baseDur == 4) // 16th triplet - nothing to subtract from return; // For the rest cases list will contain two Trhythm elements if (baseDur == 36 && subDur == 6) // quarter with dot (4.) minus 16th = 4 and 16th remained << Trhythm(e_quarter, isRest()) << Trhythm(e_eighth, isRest(), true); else if (baseDur == 48) { // subtracting form half note remained << Trhythm(e_quarter, isRest()); if (subDur == 6) // 2 - 16th = 4 and 8. remained << Trhythm(e_eighth, isRest(), true); else if (subDur == 18) // 2 - 8. = 4 and 16th remained << Trhythm(e_sixteenth, isRest()); } else if (baseDur == 72) { // subtracting from half with dot remained << Trhythm(e_whole, isRest()); // whole is always first if (baseDur == 6) // 2. - 16th = 2 and 8. remained << Trhythm(e_eighth, isRest(), true); else if (baseDur == 12) // 2. - 8 = 2 and 8 remained << Trhythm(e_eighth, isRest()); else if (baseDur == 18) // 2. - 8. = 2 and 16th remained << Trhythm(e_sixteenth, isRest()); } else if (baseDur == 96) { // subtracting from whole note remained << Trhythm(e_whole, isRest(), true); // whole wit dot is always first if (subDur == 6) // 1 - 16 = 2. and 8. remained << Trhythm(e_eighth, isRest(), true); else if (baseDur == 12) // 1 - 8 = 2. and 8 remained << Trhythm(e_eighth, isRest()); else if (baseDur == 18) // 1 - 8. = 2. and 16th remained << Trhythm(e_sixteenth, isRest()); else if (baseDur == 36) { // 1 - 4. = 2 and 16th remained[0].setDot(false); // revert a dot set above remained << Trhythm(e_sixteenth, isRest()); } } else if (baseDur == 144) { // subtracting from whole and dot if (subDur <= 48) { Trhythm half(e_half, isRest()); half.sub(r, remained); remained.prepend(Trhythm(e_whole, isRest())); } } } }
Bool DLinie :: AddGeoObj (DGeoObj *pDGO, AppMode AM) { if (pDGO == NULL) return TRUE; // falls leeres Objekt dazukommen soll switch (pDGO -> isA()) { case DGT_Punkt: { // erster bzw. letzter Punkt DPunkt *pPt = (DPunkt *)pDGO; if (pPt -> X() == -1 && pPt -> Y() == -1) // wenn ung�ltiger Punkt einfach wieder raus return TRUE; return _pDPL -> AddDPunkt (*(DPunkt *)pDGO); } case DGT_Linie: { if (Count() && ((DLinie *)pDGO) -> _pDPL -> Count()) { // wenn alte/neue Linien nicht leer sind // evtl. Relation weitergeben if (RelSatz() == 0) { _RelSatz = pDGO -> RelSatz(); } // die Linie mu� ggf. gedreht werden, um einen Anschlu� zu // gew�hrleisten DPunkt *oldFirst = _pDPL -> FirstDPunkt(); DPunkt *oldLast = _pDPL -> LastDPunkt(); DPunkt *newFirst = ((DLinie *)pDGO) -> _pDPL -> FirstDPunkt(); DPunkt *newLast = ((DLinie *)pDGO) -> _pDPL -> LastDPunkt(); CRing newR(*(((DLinie *)pDGO) -> _pDPL)); // neue PunktListe Bool RetVal = FALSE; if (!oldFirst || !oldLast || !newFirst || !newLast) { yyerror ("Kein Speicherplatz."); RetVal = FALSE; } else switch (AM) { case AM_Reverse: // Zwischenpunkte eines Polygones gedreht anh�ngen RetVal = AppendReverse (*_pDPL, newR, FALSE); break; case AM_NoReverse: // Zwischenpunkte eines Polygones direkt anh�ngen RetVal = Append (*_pDPL, newR, FALSE); break; case AM_NoSense: // sonstige F�lle, erzeugen zusammenh�ngender Polygone if (*oldLast == *newFirst) { // St�tzpunktfolge in richtiger Reihenfolge anh�ngen RetVal = Append (*_pDPL, newR); } else if (*oldLast == *newLast) { // St�tzpunktfolge in umgekehrter Reihenfolge anh�ngen RetVal = AppendReverse (*_pDPL, newR); } else if (*oldFirst == *newFirst) { // 1. Linie umdrehen, dann 2. rankopieren DPunktListe *newpDPL = new DPunktListe(); { CRing oldR (*_pDPL); // alte PunktListe AppendReverse (*newpDPL, oldR, FALSE); RetVal = Append (*newpDPL, newR); } if (_pDPL) delete _pDPL; _pDPL = newpDPL; } else if (*oldFirst == *newLast) { // 1. Linie umdrehen, dann 2. umgedreht rankopieren DPunktListe *newpDPL = new DPunktListe (); { CRing oldR (*_pDPL); // alte PunktListe AppendReverse (*newpDPL, oldR, FALSE); RetVal = AppendReverse (*newpDPL, newR); } if (_pDPL) delete _pDPL; _pDPL = newpDPL; } else { // es beginnt ein Loch: ersten Punkt noch mal anh�ngen, // dann einfach weitermachen // yyerror ("Kann keine geschlossene Linie bilden."); RetVal = FALSE; } } // Speicherbereiche wieder freigeben und raus if (oldFirst) delete oldFirst; if (oldLast) delete oldLast; if (newFirst) delete newFirst; if (newLast) delete newLast; return RetVal; } else if (Count() == 0) { // Linie umh�ngen, da alte Linie noch leer ist _pDPL = ((DLinie *)pDGO) -> _pDPL; ((DLinie *)pDGO) -> _pDPL = NULL; return TRUE; } // wenn lediglich die neue Linie leer ist, dann nichts machen } case DGT_Text: { // als BegleitObjekt anh�ngen _RelSatz = pDGO -> Enum(); } return TRUE; case DGT_Flaeche: case DGT_Unknown: default: // Fehler, kann nicht Objekt h�herer Ordnung anh�ngen yyerror ("Fragw�rdige Objektreihenfolge."); return FALSE; } }
void CanvasMode_EditArc::applyValues(double start, double end, double height, double width) { PageItem *currItem = m_doc->m_Selection->itemAt(0); QRectF oldR = currItem->getBoundingRect().adjusted(-5, -5, 10, 10); PageItem_Arc *item = currItem->asArc(); QTransform bb; bb.scale(height / width, 1.0); QLineF inp = QLineF(QPointF(width / 2.0, height / 2.0), QPointF(width, height / 2.0)); inp.setAngle(start); QLineF res = bb.map(inp); inp.setAngle(end); QLineF ena = bb.map(inp); m_startAngle = res.angle(); m_endAngle = ena.angle(); double nSweep = m_endAngle - m_startAngle; if (nSweep < 0) nSweep += 360; double oldX = currItem->xPos(); double oldY = currItem->yPos(); double newX = oldX + m_centerPoint.x() - (width / 2.0); double newY = oldY + m_centerPoint.y() - (height / 2.0); item->setXYPos(newX, newY, true); FPointArray old = item->PoLine; QPainterPath pp; pp.moveTo(width / 2.0, height / 2.0); pp.arcTo(QRectF(0, 0, width, height), m_startAngle, nSweep); pp.closeSubpath(); currItem->PoLine.fromQPainterPath(pp, true); FPoint wh = getMaxClipF(&currItem->PoLine); currItem->setWidthHeight(wh.x(),wh.y()); m_doc->adjustItemSize(currItem); currItem->OldB2 = currItem->width(); currItem->OldH2 = currItem->height(); if (UndoManager::undoEnabled()) { ScItemState<QPair<FPointArray, FPointArray> > *ss = new ScItemState<QPair<FPointArray, FPointArray> >(Um::EditArc,"",Um::IPolygon); ss->set("ARC"); ss->set("OLD_WIDTH",item->arcWidth); ss->set("NEW_WIDTH",width); ss->set("OLD_XPOS",oldX); ss->set("OLD_YPOS",oldY); ss->set("OLD_HEIGHT",item->arcHeight); ss->set("NEW_HEIGHT",height); ss->set("OLD_START",item->arcStartAngle); ss->set("NEW_START",m_startAngle); ss->set("OLD_SWEEP",item->arcSweepAngle); ss->set("NEW_SWEEP",nSweep); ss->setItem(qMakePair(old,item->PoLine)); ss->set("NEW_XPOS",item->xPos()); ss->set("NEW_YPOS",item->yPos()); undoManager->action(currItem,ss); } item->arcStartAngle = m_startAngle; item->arcSweepAngle = nSweep; item->arcWidth = width; item->arcHeight = height; m_startPoint = currItem->PoLine.pointQF(2); m_endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 4); m_centerPoint = currItem->PoLine.pointQF(0); m_widthPoint = QPointF(m_centerPoint.x() - item->arcWidth / 2.0, m_centerPoint.y()); m_heightPoint = QPointF(m_centerPoint.x(), m_centerPoint.y() - item->arcHeight / 2.0); m_doc->setRedrawBounding(currItem); QRectF newR(currItem->getBoundingRect()); m_doc->regionsChanged()->update(newR.united(oldR)); // QTransform itemMatrix = currItem->getTransform(); // m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height())); }