public static Rect calcolaDimensioni(Fascia qualeFascia, float ratioCarta, Geo imageGeo) { double l = calcolaDimensione(qualeFascia, Dimensione.Left, ratioCarta, imageGeo, imageGeo); double t = calcolaDimensione(qualeFascia, Dimensione.Top, ratioCarta, imageGeo, imageGeo); double w = calcolaDimensione(qualeFascia, Dimensione.Width, ratioCarta, imageGeo, imageGeo); double h = calcolaDimensione(qualeFascia, Dimensione.Height, ratioCarta, imageGeo, imageGeo); return(new Rect(l, t, w, h)); }
public static Bordi calcolcaLatiBordo(Fascia qualeFascia, float ratioCarta, Geo imageGeo, Geo imageActualGeo) { double w = calcolaDimensione(qualeFascia, Dimensione.Width, ratioCarta, imageGeo, imageActualGeo); double h = calcolaDimensione(qualeFascia, Dimensione.Height, ratioCarta, imageGeo, imageActualGeo); // TODO stabilire con Ciccio se meglio vedere area microscopica oppure non vederla per nulla. #if false if (w < 5 || h < 5) { return(null); } #endif Bordi bo = new Bordi(); if (qualeFascia == Fascia.FasciaA) { if (w > h) { bo.bottom = true; } else { bo.right = true; } } else if (qualeFascia == Fascia.FasciaB) { if (w > h) { bo.top = true; } else { bo.left = true; } } return(bo); }
/// <summary> /// Filter all the edges of the given element for fascia creation. /// </summary> /// <param name="elem">Element used to filter edges which fascia can be created on</param> private void FilterEdgesForFascia(Autodesk.Revit.DB.Element elem) { Transaction transaction = new Transaction(this.RvtDocument, "FilterEdgesForFascia"); transaction.Start(); // Note: This method will create a Fascia with no references. // In the future, API may not allow to create such Fascia with // no references, invoke this methods like this may throw exception. // Fascia fascia = m_rvtDoc.Create.NewFascia(null, new ReferenceArray()); List <Edge> roofEdges = m_roofFasciaEdges[elem]; foreach (Edge edge in m_elemGeom[elem].EdgeBindingDic.Keys) { if (edge.Reference == null) { continue; } try { fascia.AddSegment(edge.Reference); // AddSegment successfully, so this edge can be used to crate Fascia. roofEdges.Add(edge); } catch (Autodesk.Revit.Exceptions.ArgumentOutOfRangeException) { // Exception, this edge will be discard. } } // Delete this element, because we just use it to filter the edges. m_rvtDoc.Delete(fascia.Id); transaction.RollBack(); }
private void Stream( ArrayList data, Fascia fascia ) { data.Add( new Snoop.Data.ClassSeparator( typeof( Fascia ) ) ); data.Add( new Snoop.Data.Object( "Fascia type", fascia.FasciaType ) ); }
public static double calcolaDimensione(Fascia qualeFascia, Dimensione qualeDimens, float ratioCarta, Geo imageGeo, Geo imageActualGeo) { if (ratioCarta == 0) // probabilmente non è indicata nemmeno una stampante { return(0d); } if (imageGeo.w == 0d || imageGeo.h == 0d) { return(0d); } if (imageActualGeo.w == 0d || imageActualGeo.h == 0d) { return(0d); } // ----- float ratioImage = (float)(imageActualGeo.w / imageActualGeo.h); // I due rapporti mi indicano che sia la foto che l'area stampabile siano nella stesso verso (Orizzontali o Verticali entrambi) if (ratioImage < 1 && ratioCarta >= 1 || ratioImage >= 1 && ratioCarta < 1) { // non sono dello stesso verso. lo giro! ratioCarta = (1f / ratioCarta); } // Se la carta è più grande della foto (inteso come rapporto), allora devo tagliare sopra. // Questo mi garantisce il corretto funzionamento indipendentemente dal verso della foto. // Quindi le due bande colorate saranno sopra e sotto in orizzontale // Nel caso contrario saranno a sinistra e destra in verticale. bool eseguoTaglioOrizz = (ratioCarta > ratioImage); // ----- // Ora creo due rettangoli per poter usare il ProiettoreArea Int32Rect fotoSorgente = new Int32Rect(0, 0, (int)imageActualGeo.w, (int)imageActualGeo.h); // creo un area dello stesso orientamento int cartaW = (int)(1000 * ratioCarta); int cartaH = (int)(cartaW / ratioCarta); Int32Rect stampanteFinta = new Int32Rect(0, 0, cartaW, cartaH); // Eseguo proiezione per capire dove e quanto verrà tagliata la foto originale. ProiettoreArea proiettore = new ProiettoreArea(stampanteFinta, true); Proiezione proiezione = proiettore.calcola(fotoSorgente); // ----- // // Ora finalmente calcolo il valore da ritornare // // ----- double ret = 0d; // Width if (qualeDimens == Dimensione.Width) { if (eseguoTaglioOrizz) { ret = (double)proiezione.sorg.Width; } else { ret = (double)proiezione.sorg.X; } } // Height if (qualeDimens == Dimensione.Height) { if (eseguoTaglioOrizz) { ret = (double)proiezione.sorg.Y; } else { ret = (double)proiezione.sorg.Height; } } // Left (del canvas) if (qualeDimens == Dimensione.Left) { double offsetX = (imageGeo.w - imageActualGeo.w) / 2; if (qualeFascia == Fascia.FasciaB && eseguoTaglioOrizz == false) { offsetX += (imageActualGeo.w - proiezione.sorg.X); } ret = offsetX; } // Top (del canvas) if (qualeDimens == Dimensione.Top) { double offsetY = (imageGeo.h - imageActualGeo.h) / 2; if (qualeFascia == Fascia.FasciaB && eseguoTaglioOrizz == true) { offsetY += (imageActualGeo.h - proiezione.sorg.Y); } ret = offsetY; } return(ret); }
/// <summary> /// Create a Fascia. /// </summary> /// <param name="symbol">Fascia type</param> /// <param name="refArr">Fascia reference array</param> /// <returns>Created Fascia</returns> protected override HostedSweep CreateHostedSweep(ElementType symbol, ReferenceArray refArr) { Fascia fascia = m_rvtDoc.Create.NewFascia(symbol as FasciaType, refArr); return(fascia); }