From: <bma...@us...> - 2008-12-19 12:22:23
|
Revision: 4309 http://fudaa.svn.sourceforge.net/fudaa/?rev=4309&view=rev Author: bmarchan Date: 2008-12-19 11:34:55 +0000 (Fri, 19 Dec 2008) Log Message: ----------- Ticket#129 : Un calque cr?\195?\169?\195?\169 a un nom unique pour l'utilisateur. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BGroupeCalque.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/CalqueNewCalqueAction.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BGroupeCalque.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BGroupeCalque.java 2008-12-18 16:15:31 UTC (rev 4308) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BGroupeCalque.java 2008-12-19 11:34:55 UTC (rev 4309) @@ -171,7 +171,14 @@ * BCalqueAffichage) ((BCalqueAffichage)c[i]).setRapide(b); if(!isValid()) repaint(); } */ + /** + * Recherche un nom unique sous la forme _pref+"_"+_idx parmis les fils du calque parent. + * @param _pref le prefix pour le nom + * @param _parent le calque parent + * @return Le nom unique du style _pref+"_"+indice. + */ public static String findUniqueChildName(final BCalque _parent, final String _pref) { + // FIXME BM : Propriete layer.child.id get mais child.id put !!! Pas de correspondance possible. Integer idxSt = (Integer) _parent.getClientProperty("layer.child.id"); if (idxSt == null) { idxSt = new Integer(0); @@ -190,19 +197,21 @@ } /** - * @param _pref le prefix + * Construit un nom de calque sous la forme _pref+"_"+_idx + * @param _pref le prefix xxxx * @param _idx l'identifiant - * @return _pref+"_"+_idx + * @return Le nom du calque */ - public static String buildName(final String _pref, final int _idx) { + private static String buildName(final String _pref, final int _idx) { return _pref + '_' + _idx; } /** - * @param _cqName le nom de la forme "toto_"+idx + * Retourne l'indice idx pour un nom de calque de la forme "xxxx_"+idx + * @param _cqName le nom du calque * @return -1 si forme incorrect. Sinon, l'indice */ - public static int getIdx(final String _cqName) { + private static int getIdx(final String _cqName) { final int idxTmp = _cqName.lastIndexOf('_'); if (idxTmp < 0) { return -1; @@ -215,39 +224,47 @@ } /** - * @param _pref le prefix du nouveau nom + * Recherche un nom unique sous la forme _pref+"_"+_idx parmis les fils du calque parent. + * @param _pref le prefix pour le nom * @param _parent le calque parent - * @return l'identifiant unique du style _pref+"_"+entier + * @param _idx L'indice initial + * @return Le nom unique du style _pref+"_"+indice. Si le nom pass\xE9 est unique, il est retourn\xE9 + * tel quel. Sinon, un nouvel indice est choisit. */ private static String findUniqueName(final String _pref, final BCalque _parent, final int _idx) { final BCalque[] cqs = _parent.getCalques(); - final String defaultName = _pref + '_' + CtuluLibString.getString(_idx); + final String defaultName=buildName(_pref, _idx); +// final String defaultName = _pref + '_' + CtuluLibString.getString(_idx); + + // Aucun calque trouv\xE9 avec ce nom. if (cqs == null || cqs.length == 0) { return defaultName; } - final String[] name = new String[cqs.length]; - final int nb = name.length; + final String[] cqNames = new String[cqs.length]; + final int nb = cqNames.length; boolean found = false; for (int i = 0; i < nb; i++) { - name[i] = cqs[i].getName(); - if (defaultName.equals(name[i])) { + cqNames[i] = cqs[i].getName(); + if (defaultName.equals(cqNames[i])) { found = true; } } if (!found) { return defaultName; } + + // Un calque a \xE9t\xE9 trouv\xE9 avec ce nom => On en definit un nouveau avec un indice diff\xE9rent. int lastIdx = 0; String r = null; - Arrays.sort(name); + Arrays.sort(cqNames); for (int i = 0; i < nb && (r == null); i++) { - lastIdx = BGroupeCalque.getIdx(name[i]); + lastIdx = BGroupeCalque.getIdx(cqNames[i]); if (FuLog.isTrace()) { FuLog.trace("TRL: test for i=" + i); } if (lastIdx > i) { r = BGroupeCalque.buildName(_pref, i); - if (Arrays.binarySearch(name, r) >= 0) { + if (Arrays.binarySearch(cqNames, r) >= 0) { r = null; } } else { @@ -260,7 +277,7 @@ } r = BGroupeCalque.buildName(_pref, lastIdx + 1); } - if (Arrays.binarySearch(name, r) >= 0) { + if (Arrays.binarySearch(cqNames, r) >= 0) { throw new IllegalArgumentException("cant find unique name " + r); } if (FuLog.isTrace()) { @@ -270,6 +287,25 @@ } /** + * Retourne un titre de calque qui n'existe pas d\xE9j\xE0 parmis les fils du groupe de calques. + * @param _rootTitle La racine du titre. + * @return Le titre, sous la forme _title+" "+num + */ + public String findUniqueChildTitle(String _rootTitle) { + BCalque[] cqs=this.getCalques(); + int num=0; + for (BCalque cq : cqs) { + if (cq.getTitle().startsWith(_rootTitle)) { + try { + num=Math.max(num,Integer.parseInt(cq.getTitle().substring(_rootTitle.length()).trim())); + } + catch (NumberFormatException _exc) {} + } + } + return _rootTitle+" "+(num+1); + } + + /** * On force le mode visible dependant des sous calques, car les calques sont des components. * Les components fils ne sont affich\xE9s que si les components parents sont visibles. */ Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java 2008-12-18 16:15:31 UTC (rev 4308) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java 2008-12-19 11:34:55 UTC (rev 4309) @@ -273,7 +273,7 @@ BGroupeCalque cqBief=new BGroupeCalque(); cqBief.setTitleModifiable(true); String name=BGroupeCalque.findUniqueChildName(cqBiefs_); - cqBief.setTitle(MdlResource.MDL.getString("Bief")); + cqBief.setTitle(cqBiefs_.findUniqueChildTitle(MdlResource.MDL.getString("Bief"))); cqBief.setName(name); cqBief.putClientProperty(Action.SHORT_DESCRIPTION, TrResource.getS("Un bief")); cqBief.setDestructible(true); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/CalqueNewCalqueAction.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/CalqueNewCalqueAction.java 2008-12-18 16:15:31 UTC (rev 4308) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/CalqueNewCalqueAction.java 2008-12-19 11:34:55 UTC (rev 4309) @@ -31,14 +31,14 @@ /** Une op\xE9ration de construction d'un nouveau calque */ class OperationForLayerCreation implements CtuluNamedCommand { - private final BCalque parent_; + private final BGroupeCalque parent_; private final ZCalqueAffichageDonnees la_; /** * @param _parent le calque parent * @param _la le calque ajout\xE9 */ - OperationForLayerCreation(BCalque _parent, ZCalqueAffichageDonnees _la) { + OperationForLayerCreation(BGroupeCalque _parent, ZCalqueAffichageDonnees _la) { parent_ = _parent; la_ = _la; } @@ -57,7 +57,7 @@ } FSigEditor editor_; - BCalque parent_; + BGroupeCalque parent_; int cqType_; /** @@ -68,7 +68,7 @@ * @param _parent Le calque parent dans lequel sera cr\xE9\xE9 le calque. * @param _editor L'\xE9diteur. */ - public CalqueNewCalqueAction(String _title, Icon _icon, int _cqType, BCalque _parent, FSigEditor _editor) { + public CalqueNewCalqueAction(String _title, Icon _icon, int _cqType, BGroupeCalque _parent, FSigEditor _editor) { super(_title, _icon, "CREER"); editor_=_editor; parent_=_parent; @@ -78,6 +78,7 @@ public void actionPerformed(final ActionEvent _e) { ZCalqueAffichageDonnees cq=MdlLayerFactory.getInstance().createLayer(cqType_, editor_); cq.setName(BGroupeCalque.findUniqueChildName(parent_, ((MdlLayerInterface)cq).getExtName())); + cq.setTitle(parent_.findUniqueChildTitle(cq.getTitle())); CtuluCommand cmd=new OperationForLayerCreation(parent_,cq); cmd.redo(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2008-12-22 14:50:16
|
Revision: 4312 http://fudaa.svn.sourceforge.net/fudaa/?rev=4312&view=rev Author: emmanuel_martin Date: 2008-12-22 14:50:07 +0000 (Mon, 22 Dec 2008) Log Message: ----------- Ajout de l'export mascaret 1d et 2d ; r?\195?\169organisation du d?\195?\169coupage en package des sources modeleur 1d ; Construction d'une premi?\195?\168re version des vues des modules biefs et profils (les controleurs ne sont pas faits). Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretFileFormat.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretReader.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlProjectExportPanel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/MdlFille1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/testModeleur1d/TestDataGeometryAdapter.java Added Paths: ----------- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataError.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataIncomplete.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretProfilAbstractRepresentation.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/DataGeometry.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/DataGeometryAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/DataGeometryException.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/DataGeometryListener.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueBief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueContainerModules.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueCourbe.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueExport.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionBief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionProfil.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueTableau.java Removed Paths: ------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/Controller1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometry.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryListener.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueBief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueCourbe.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueTableau.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2008-12-22 14:20:55 UTC (rev 4311) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -11,11 +11,10 @@ import java.util.Arrays; import java.util.List; +import org.fudaa.ctulu.CtuluLib; import org.fudaa.ctulu.CtuluLibString; import org.fudaa.ctulu.gui.CtuluValueEditorChoice; -import org.fudaa.ctulu.CtuluLib; - import com.memoire.fu.FuLib; /** @@ -57,6 +56,10 @@ public final static String ATT_NATURE_CE="CE"; /** Nature axe hydraulique */ public final static String ATT_NATURE_AH="AH"; + /** Nature limite de stockage (gauche ou droite) */ + public final static String ATT_NATURE_LS="LS"; + /** Nature rive (gauche ou droite) */ + public final static String ATT_NATURE_RV="RV"; /** * Un attribut nom, global. @@ -263,4 +266,54 @@ } return false; } + + // Attributs 1D \\ + + /** + * Attribut contenant la coordonn\xE9e de l'intersection entre une rive gauche et + * un profil. La donn\xE9e sauvgard\xE9e est une coordonn\xE9e (Coordinate). + */ + public final static GISAttribute INTERSECTION_RIVE_GAUCHE=new GISAttribute(null, CtuluLib.getS("Intersection rive gauche"), false){ + @Override + public String getID() { + return "ATTRIBUTE_INTERSECTION_RIVE_GAUCHE"; + } + }; + + /** + * Attribut contenant la coordonn\xE9e de l'intersection entre une rive droite et + * un profil. La donn\xE9e sauvgard\xE9e est une coordonn\xE9e (Coordinate). + */ + public final static GISAttribute INTERSECTION_RIVE_DROITE=new GISAttribute(null, CtuluLib.getS("Intersection rive droite"), false){ + @Override + public String getID() { + return "ATTRIBUTE_INTERSECTION_RIVE_DROITE"; + } + }; + + /** + * Attribut contenant la coordonn\xE9e de l'intersection entre une limite de + * stockage gauche et un profil. La donn\xE9e sauvgard\xE9e est une coordonn\xE9e + * (Coordinate). + */ + public final static GISAttribute INTERSECTION_LIMITE_STOCKAGE_GAUCHE=new GISAttribute(null, CtuluLib + .getS("Intersection limite stockage gauche"), false){ + @Override + public String getID() { + return "ATTRIBUTE_INTERSECTION_LIMITE_STOCKAGE_GAUCHE"; + } + }; + + /** + * Attribut contenant la coordonn\xE9e de l'intersection entre une limite de + * stockage droite et un profil. La donn\xE9e sauvgard\xE9e est une coordonn\xE9e + * (Coordinate). + */ + public final static GISAttribute INTERSECTION_LIMITE_STOCKAGE_DROITE=new GISAttribute(null, CtuluLib + .getS("Intersection limite stockage droite"), false){ + @Override + public String getID() { + return "ATTRIBUTE_INTERSECTION_LIMITE_STOCKAGE_DROITE"; + } + }; } Copied: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataError.java (from rev 4305, branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java) =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataError.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataError.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -0,0 +1,22 @@ +/* + * @creation 19 d\xE9c. 2008 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.dodico.mascaret.io; + +/** + * Exception utilis\xE9 par MascaretWriter indiquant que des donn\xE9es sont + * incoh\xE9rentes et rendent ainsi impossible l'export. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class MascaretDataError extends Exception { + + public MascaretDataError(String _msg){ + super(_msg); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataError.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:mergeinfo + /branches/Br_FudaaModeleur_TF/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java:3445-3850 /branches/FudaaModeleur_TC1/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java:3861-3891 Added: svn:eol-style + native Copied: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataIncomplete.java (from rev 4305, branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java) =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataIncomplete.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataIncomplete.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -0,0 +1,22 @@ +/* + * @creation 19 d\xE9c. 2008 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.dodico.mascaret.io; + +/** + * Exception utilis\xE9 par MascaretWriter indiquant que des g\xE9om\xE9tries manque pour + * g\xE9n\xE9rer le fichier. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class MascaretDataIncomplete extends Exception { + + public MascaretDataIncomplete(String _msg){ + super(_msg); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataIncomplete.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:mergeinfo + /branches/Br_FudaaModeleur_TF/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java:3445-3850 /branches/FudaaModeleur_TC1/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java:3861-3891 Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretFileFormat.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretFileFormat.java 2008-12-22 14:20:55 UTC (rev 4311) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretFileFormat.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -1,6 +1,6 @@ /* * @creation 13 nov. 2008 - * @modification $Date:$ + * @modification $Date$ * @license GNU General Public License 2 * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne * @mail fud...@li... Copied: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretProfilAbstractRepresentation.java (from rev 4305, branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java) =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretProfilAbstractRepresentation.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretProfilAbstractRepresentation.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -0,0 +1,74 @@ +/* + * @creation 19 d\xE9c. 2008 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.dodico.mascaret.io; + +import java.util.ArrayList; +import java.util.List; + +/** + * Container des informations relative \xE0 un profil. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class MascaretProfilAbstractRepresentation { + public String nomBief; + public String nomProfil; + public List<Double> coordZ=new ArrayList<Double>(); // Bathy ou Topo + public List<Character> bathyOuTopoOuStockage=new ArrayList<Character>(); // B ou T ou S + // Info sp\xE9cifique 1D + public double abscisseCurvilingeAxeHydraulique; + public List<Double> coordCurviligneProfil=new ArrayList<Double>(); + // Info sp\xE9cifique 2D + public List<double[]> coordXYTraceProfil=new ArrayList<double[]>(); + public double[] coordIntersectionAxeHydraulique; + public List<double[]> coordXYProfil=new ArrayList<double[]>(); + + /** @return vrai si seul des informations 1d sont pr\xE9sentes. */ + public boolean is1d(){ + return coordCurviligneProfil.size()>0&&coordXYTraceProfil.size()==0&&coordIntersectionAxeHydraulique==null + &&coordXYProfil.size()==0; + } + + /** @return vrai si les informations 2d sont pr\xE9sentes. (les infos 1d peuvent \xEAtre \xE9galement pr\xE9sentes) */ + public boolean is2d(){ + return (coordXYTraceProfil.size()!=0||coordIntersectionAxeHydraulique!=null&&coordIntersectionAxeHydraulique.length!=0||coordXYProfil + .size()!=0); + } + + /** Check les attributs communs \xE0 1d et 2d. */ + private boolean checkCommon(){ + boolean check=nomBief.length()>0&&nomProfil.length()>0&&coordZ.size()>0&&bathyOuTopoOuStockage.size()==coordZ.size(); + int i=-1; + // Verifi que bathyOuTopo ne comporte que B ou T + while(check&&++i<bathyOuTopoOuStockage.size()) + check=bathyOuTopoOuStockage.get(i).equals('T')||bathyOuTopoOuStockage.get(i).equals('B')||bathyOuTopoOuStockage.get(i).equals('S'); + return check; + } + + /** @return vrai si les informations utile 1D sont compl\xE8tes et coh\xE9rentes. */ + public boolean check1D(){ + boolean check=checkCommon()&&abscisseCurvilingeAxeHydraulique>=0&&coordCurviligneProfil.size()==coordZ.size(); + int i=0; + // Verifi que l'ordre des coordonn\xE9es est croissant. + while(check&&++i<coordCurviligneProfil.size()) + check=coordCurviligneProfil.get(i-1)<=coordCurviligneProfil.get(i); + return check; + } + + /** @return vrai si les informations utile 2D sont compl\xE8tes et coh\xE9rentes. */ + public boolean check2D(){ + boolean check=checkCommon()&&coordXYTraceProfil.size()>=2&&coordXYTraceProfil.size()<=4 + &&coordIntersectionAxeHydraulique.length==2&&coordXYProfil.size()==coordZ.size(); + // Verification de la taille des coordonn\xE9es XY du profile + int i=-1; + while(check&&++i<coordXYProfil.size()) + check=coordXYProfil.get(i).length==2; + return check; + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretProfilAbstractRepresentation.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:mergeinfo + /branches/Br_FudaaModeleur_TF/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java:3445-3850 /branches/FudaaModeleur_TC1/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java:3861-3891 Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretReader.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretReader.java 2008-12-22 14:20:55 UTC (rev 4311) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretReader.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -32,66 +32,6 @@ */ public class MascaretReader extends FileReadOperationAbstract { - /** - * Container des informations relative \xE0 un profil. - */ - private class Profil{ - public String nomBief; - public String nomProfil; - public List<Double> coordZ=new ArrayList<Double>(); // Bathy ou Topo - public List<Character> bathyOuTopo=new ArrayList<Character>(); // B ou T - // Info sp\xE9cifique 1D - public double abscisseCurvilingeAxeHydraulique; - public List<Double> coordCurviligneProfil=new ArrayList<Double>(); - // Info sp\xE9cifique 2D - public List<double[]> coordXYTraceProfil=new ArrayList<double[]>(); - public double[] coordIntersectionAxeHydraulique; - public List<double[]> coordXYProfil=new ArrayList<double[]>(); - - /** @return vrai si seul des informations 1d sont pr\xE9sentes. */ - public boolean is1d(){ - return coordCurviligneProfil.size()>0&&coordXYTraceProfil.size()==0&&coordIntersectionAxeHydraulique==null - &&coordXYProfil.size()==0; - } - - /** @return vrai si les informations 2d sont pr\xE9sentes. (les infos 1d peuvent \xEAtre \xE9galement pr\xE9sentes) */ - public boolean is2d(){ - return (coordXYTraceProfil.size()!=0||coordIntersectionAxeHydraulique!=null&&coordIntersectionAxeHydraulique.length!=0||coordXYProfil - .size()!=0); - } - - /** Check les attributs communs \xE0 1d et 2d. */ - private boolean checkCommon(){ - boolean check=nomBief.length()>0&&nomProfil.length()>0&&coordZ.size()>0&&bathyOuTopo.size()==coordZ.size(); - int i=-1; - // Verifi que bathyOuTopo ne comporte que B ou T - while(check&&++i<bathyOuTopo.size()) - check=bathyOuTopo.get(i).equals('T')||bathyOuTopo.get(i).equals('B'); - return check; - } - - /** @return vrai si les informations utile 1D sont compl\xE8tes et coh\xE9rentes. */ - public boolean check1D(){ - boolean check=checkCommon()&&abscisseCurvilingeAxeHydraulique>=0&&coordCurviligneProfil.size()==coordZ.size(); - int i=0; - // Verifi que l'ordre des coordonn\xE9es est croissant. - while(check&&++i<coordCurviligneProfil.size()) - check=coordCurviligneProfil.get(i-1)<=coordCurviligneProfil.get(i); - return check; - } - - /** @return vrai si les informations utile 2D sont compl\xE8tes et coh\xE9rentes. */ - public boolean check2D(){ - boolean check=checkCommon()&&coordXYTraceProfil.size()>=2&&coordXYTraceProfil.size()<=4 - &&coordIntersectionAxeHydraulique.length==2&&coordXYProfil.size()==coordZ.size(); - // Verification de la taille des coordonn\xE9es XY du profile - int i=-1; - while(check&&++i<coordXYProfil.size()) - check=coordXYProfil.get(i).length==2; - return check; - } - } - /** Exception lev\xE9e quand une probl\xE8me est trouv\xE9 pendant le parsing. */ private class ParseError extends Exception{ public ParseError(String _message){ @@ -106,7 +46,7 @@ private char[] charSeparation_=new char[]{' ', '\t'}; private char charSeparationNewLigne_='\n'; /** Profiles extraits */ - List<Profil> profils_=new ArrayList<Profil>(); + List<MascaretProfilAbstractRepresentation> profils_=new ArrayList<MascaretProfilAbstractRepresentation>(); public MascaretReader() { rawData_=null; @@ -183,7 +123,7 @@ */ String token=nextWordToken(lineToken); while (lineToken!=null&&token.equalsIgnoreCase("profil")) { - Profil profil=new Profil(); + MascaretProfilAbstractRepresentation profil=new MascaretProfilAbstractRepresentation(); // Premi\xE8re ligne \\ // Extraction des informations commune \xE0 1d et 2d @@ -206,7 +146,7 @@ while (lineToken!=null&&!(token=nextWordToken(lineToken)).equalsIgnoreCase("profil")) { profil.coordCurviligneProfil.add(Double.parseDouble(token)); profil.coordZ.add(Double.parseDouble(nextWordToken(lineToken))); - profil.bathyOuTopo.add(nextWordToken(lineToken).charAt(0)); + profil.bathyOuTopoOuStockage.add(nextWordToken(lineToken).charAt(0)); // Coordonn\xE9es XY : non pr\xE9sent dans les fichiers 1d token=nextWordToken(lineToken); if (token!=null) @@ -245,7 +185,7 @@ // G\xE9n\xE9ration des profiles et des traces de profiles \\ for(int k=0;k<profils_.size();k++){ progress_.setProgression((int)((float)k/profils_.size()*100)); - Profil profil=profils_.get(k); + MascaretProfilAbstractRepresentation profil=profils_.get(k); CoordinateArraySequence coordSeq=new CoordinateArraySequence(profil.coordXYTraceProfil.size()); // Trace profil for(int i=0;i<profil.coordXYTraceProfil.size();i++){ Copied: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java (from rev 4303, branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryListener.java) =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -0,0 +1,372 @@ +/* + * @creation 19 d\xE9c. 2008 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.dodico.mascaret.io; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.fudaa.ctulu.CtuluAnalyze; +import org.fudaa.ctulu.fileformat.FileWriteOperationAbstract; +import org.fudaa.ctulu.fileformat.FortranInterface; +import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ctulu.gis.GISAttributeModelDoubleInterface; +import org.fudaa.ctulu.gis.GISGeometryFactory; +import org.fudaa.ctulu.gis.GISPoint; +import org.fudaa.ctulu.gis.GISPolyligne; +import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; + +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.Geometry; + +/** + * Ecrit au format mascaret 1d et 2d. + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class MascaretWriter extends FileWriteOperationAbstract { + + /** Le flux de sorti. */ + private Writer out_; + /** Les profils \xE0 \xE9crire. */ + private MascaretProfilAbstractRepresentation[] profils_; + /** Version du fichier mascaret de destination. */ + private String version_; + + /** + * Cette classe permet \xE0 l'exporteur de selectionner les + * profils \xE0 exporter. G\xE9n\xE9ralement les profiles invalides sont ignor\xE9s. + * @author Emmanuel MARTIN + * @version $Id:$ + */ + public interface FunctorSelectProfil { + public boolean exportProfil(GISZoneCollectionLigneBrisee _zone, int _idxProfil); + } + + public MascaretWriter() {} + + /** + * L'argument doit \xEAtre un tableau contenant : + * 0 : string : le nom du bief + * 1 : GISZoneCollectionLigneBrisee[] : les zones dans lesquelles trouver les g\xE9om\xE9tries + * 2 : FunctorSelectProfil : pour selectionner les profils \xE0 exporter + * 3 : string : la version du fichier mascaret g\xE9n\xE9r\xE9 + * + * On passe en param\xE8tre les diff\xE9rentes GISZoneCollectionLigneBrisee qui + * contiennent les g\xE9om\xE9tries n\xE9c\xE9ssaires \xE0 l'exportation. Ces zone peuvent + * contenir des g\xE9om\xE9tries incompatible avec l'export (comme des polygones), + * elles seront simplement ignor\xE9es. Dans le cas o\xF9 des g\xE9om\xE9tries manqueront, + * une exception du type MascaretDataIncomplete est lev\xE9e. Les profils invalides + * sont \xE9galements ignor\xE9s. Si certaines donn\xE9es sont incoh\xE9rentes une exception + * du type MascaretDataError est lev\xE9e. La version du fichier de destination ('1d' + * ou '2d'). Si un des trois param\xE8tres est null une exception de type + * {@link IllegalArgumentException} est lev\xE9e, si version n'est pas soit '1d' + * soit '2d' (case ignor\xE9e) la m\xEAme exception est lev\xE9e. + */ + @Override + protected void internalWrite(Object _o) { + try { + if(((Object[])_o).length!=4) + throw new IllegalArgumentException("Il doit y avoir 4 param\xE8tres dans _o."); + String nomBief=(String)((Object[])_o)[0]; + GISZoneCollectionLigneBrisee[] zones=(GISZoneCollectionLigneBrisee[])((Object[])_o)[1]; + FunctorSelectProfil selectorProfil=(FunctorSelectProfil)((Object[])_o)[2]; + version_=(String)((Object[])_o)[3]; + if (nomBief==null) + throw new IllegalArgumentException("nomBief ne doit pas \xEAtre null"); + if (zones==null) + throw new IllegalArgumentException("zones mustn't be null"); + if (version_==null||!version_.equalsIgnoreCase("1d")&&!version_.equalsIgnoreCase("2d")) + throw new IllegalArgumentException("version doit \xEAtre \xE9gale \xE0 1d ou 2d"); + generateMascaretProfilAbstractRepresentations(nomBief, zones, selectorProfil); + + for (int i=0; i<profils_.length; i++) { + MascaretProfilAbstractRepresentation profil=profils_[i]; + // Premi\xE8re ligne + out_.write("Profil "+profil.nomBief+" "+profil.nomProfil+" "+profil.abscisseCurvilingeAxeHydraulique); + if (version_.equals("1d")) + out_.write('\n'); + else { + out_.write(' '); + for (int j=0; j<profil.coordXYTraceProfil.size(); j++) { + out_.write(profil.coordXYTraceProfil.get(j)[0]+" "); + out_.write(profil.coordXYTraceProfil.get(j)[1]+" "); + } + out_.write("AXE "+profil.coordIntersectionAxeHydraulique[0]+" "+profil.coordIntersectionAxeHydraulique[1]); + out_.write('\n'); + } + // Les autres lignes + for (int j=0; j<profil.coordXYProfil.size(); j++) { + out_.write(profil.coordCurviligneProfil.get(j)+" "+profil.coordZ.get(j)+" "+profil.bathyOuTopoOuStockage.get(j)); + if (version_.equals("1d")) + out_.write('\n'); + else + out_.write(" "+profil.coordXYProfil.get(j)[0]+" "+profil.coordXYProfil.get(j)[1]+"\n"); + } + } + } + catch (Exception _exp) { + analyze_.manageException(_exp); + } + } + + @Override + protected FortranInterface getFortranInterface() { + return new FortranInterface() { + public void close() throws IOException { + if (out_ != null) { + out_.close(); + } + } + }; + } + + @Override + public void setFile(File _f) { + analyze_ = new CtuluAnalyze(); + analyze_.setResource(_f.getAbsolutePath()); + FileWriter out = null; + try { + out = new FileWriter(_f); + } catch (final IOException _e) { + analyze_.manageException(_e); + } + if (out != null) { + out_ = out; + } + } + + /** + * G\xE9n\xE8re les repr\xE9sentatino interm\xE9diaires des profils. + * @param zones_ + * @throws MascaretDataError + * @throws MascaretDataIncomplete + */ + private void generateMascaretProfilAbstractRepresentations(String _nomBief, GISZoneCollectionLigneBrisee[] _zones, FunctorSelectProfil _selectorProfil) throws MascaretDataError, MascaretDataIncomplete{ + // Recherche de l'axe hydraulique \\ + GISZoneCollectionLigneBrisee zoneAxeHydraulique=null; + int indexAxeHydraulique=-1; + for (int i=0; i<_zones.length; i++) { + int idxAttNature=_zones[i].getIndiceOf(GISAttributeConstants.NATURE); + if (idxAttNature!=-1) + for (int j=0; j<_zones[i].getNbGeometries(); j++) + if (_zones[i].getValue(idxAttNature, j)==GISAttributeConstants.ATT_NATURE_AH) + if (zoneAxeHydraulique==null) { + zoneAxeHydraulique=_zones[i]; + indexAxeHydraulique=j; + } + else + throw new MascaretDataError("Il existe plusieurs axes hydrauliques."); + } + if(zoneAxeHydraulique==null) + throw new MascaretDataIncomplete("Il n'y a pas d'axes hydrauliques."); + + // Recherche des profils \\ + List<GISZoneCollectionLigneBrisee> profils=new ArrayList<GISZoneCollectionLigneBrisee>(); + List<Integer> indexProfils=new ArrayList<Integer>(); + for (int i=0; i<_zones.length; i++) { + int idxAttNature=_zones[i].getIndiceOf(GISAttributeConstants.NATURE); + if (idxAttNature!=-1) + for (int j=0; j<_zones[i].getNbGeometries(); j++) + if (_zones[i].getValue(idxAttNature, j)==GISAttributeConstants.ATT_NATURE_PF&&_selectorProfil.exportProfil(_zones[i], i)) { + profils.add(_zones[i]); + indexProfils.add(j); + } + } + + // G\xE9n\xE9ration des MascaretProfilAbstractRepresentations \\ + profils_=new MascaretProfilAbstractRepresentation[profils.size()]; + int countNoName=1; + GISPolyligne axeHydraulique=(GISPolyligne)zoneAxeHydraulique.getGeometry(indexAxeHydraulique); + for (int i=0;i<profils.size();i++) { + GISZoneCollectionLigneBrisee zoneProfil=profils.get(i); + int idxProfil=indexProfils.get(i); + GISPolyligne profil=(GISPolyligne) zoneProfil.getGeometry(idxProfil); + MascaretProfilAbstractRepresentation profilAbs=new MascaretProfilAbstractRepresentation(); + + // Information globales sur le profil \\ + // Nom bief + if(_nomBief.contains(" ")) + throw new MascaretDataError("Le nom du bief ne doit pas contenir d'espace."); + profilAbs.nomBief=_nomBief; + // Nom profil + int idxTitle=zoneProfil.getIndiceOf(GISAttributeConstants.TITRE); + if(idxTitle!=-1){ + String nomProfil=(String) zoneProfil.getValue(idxTitle, idxProfil); + if(nomProfil.contains(" ")) + throw new MascaretDataError("Le nom du profil ne doit pas contenir d'espace."); + profilAbs.nomProfil=nomProfil; + } + else + profilAbs.nomProfil="No_Name_"+countNoName++; + // Intersection axe hydraulique + Geometry intersection=axeHydraulique.intersection(profil); + if(intersection.getNumPoints()!=1) + throw new MascaretDataError("Un profil \xE0 plusieurs ou aucun point(s) d'intersection(s) avec l'axe hydraulique."); + profilAbs.coordIntersectionAxeHydraulique=new double[]{intersection.getCoordinate().x, intersection.getCoordinate().y}; + // Abscisse curviligne axe hydraulique + CoordinateSequence coordSeq=axeHydraulique.getCoordinateSequence(); + profilAbs.abscisseCurvilingeAxeHydraulique=absCurv(coordSeq, intersection.getCoordinate()); + // Trace profil + coordSeq=profil.getCoordinateSequence(); + profilAbs.coordXYTraceProfil.add(new double[]{coordSeq.getX(0), coordSeq.getY(0)}); + profilAbs.coordXYTraceProfil.add(new double[]{coordSeq.getX(coordSeq.size()-1), coordSeq.getY(coordSeq.size()-1)}); + + // Information atomiques sur le profil \\ + coordSeq=profil.getCoordinateSequence(); + int idxZ=zoneProfil.getIndiceOf(zoneProfil.getAttributeIsZ()); + for(int j=0;j<profil.getNumPoints();j++){ + // Valeur curviligne + profilAbs.coordCurviligneProfil.add(absCurv(coordSeq, j)); + // Coordonn\xE9es X Y + profilAbs.coordXYProfil.add(new double[]{coordSeq.getCoordinate(j).x, coordSeq.getCoordinate(j).y}); + // Coordinate Z + if(idxZ!=-1) + profilAbs.coordZ.add(((GISAttributeModelDoubleInterface)zoneProfil.getValue(idxZ, idxProfil)).getValue(j)); + } + // Extraction des valeurs d'intersection + ArrayList<Integer> seps=new ArrayList<Integer>(); + //INTERSECTION_RIVE_GAUCHE + int idxInterRiveG=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); + Coordinate intersectionRiveGauche; + Integer idxRG=-1; + if(idxInterRiveG!=-1) { + intersectionRiveGauche=(Coordinate) zoneProfil.getValue(idxInterRiveG, idxProfil); + idxRG=idxIntersection(coordSeq, intersectionRiveGauche); + seps.add(idxRG); + } + //INTERSECTION_RIVE_DROITE + int idxInterRiveD=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); + Coordinate intersectionRiveDroite; + Integer idxRD=-1; + if(idxInterRiveD!=-1) { + intersectionRiveDroite=(Coordinate) zoneProfil.getValue(idxInterRiveD, idxProfil); + idxRD=idxIntersection(coordSeq, intersectionRiveDroite); + seps.add(idxRD); + } + //INTERSECTION_LIMITE_STOCKAGE_GAUCHE + int idxInterStockageG=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); + Coordinate intersectionStockageGauche; + Integer idxSG=-1; + if(idxInterStockageG!=-1) { + intersectionStockageGauche=(Coordinate) zoneProfil.getValue(idxInterStockageG, idxProfil); + idxSG=idxIntersection(coordSeq, intersectionStockageGauche); + seps.add(idxSG); + } + //INTERSECTION_LIMITE_STOCKAGE_DROITE + int idxInterStockageD=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); + Coordinate intersectionStockageDroit; + Integer idxSD=-1; + if(idxInterStockageD!=-1) { + intersectionStockageDroit=(Coordinate) zoneProfil.getValue(idxInterStockageD, idxProfil); + idxSD=idxIntersection(coordSeq, intersectionStockageDroit); + seps.add(idxSD); + } + if(idxRG==-1&&idxRD!=-1||idxRG!=-1&&idxRD==-1) + throw new MascaretDataIncomplete("Il y a une seule rive (il doit y en avoir soit 0 soit 2)"); + if(idxSG==-1&&idxSD!=-1||idxSG!=-1&&idxSD==-1) + throw new MascaretDataIncomplete("Il y a une seule limite de stockage (il doit y en avoir soit 0 soit 2)"); + Integer[] sepsT=seps.toArray(new Integer[0]); + Arrays.sort(sepsT); + // Bathy Topo ou Stockage + if(sepsT.length==4){ + int j; + for(j=0;j<sepsT[0];j++) + profilAbs.bathyOuTopoOuStockage.add('S'); + for(;j<sepsT[1];j++) + profilAbs.bathyOuTopoOuStockage.add('T'); + for(;j<sepsT[2];j++) + profilAbs.bathyOuTopoOuStockage.add('B'); + for(;j<sepsT[3];j++) + profilAbs.bathyOuTopoOuStockage.add('T'); + for(;j<coordSeq.size();j++) + profilAbs.bathyOuTopoOuStockage.add('S'); + } + if(sepsT.length==2) { + if(sepsT[0]==idxRG||sepsT[0]==idxRD){ + int j; + for(j=0;j<sepsT[0];j++) + profilAbs.bathyOuTopoOuStockage.add('T'); + for(;j<sepsT[1];j++) + profilAbs.bathyOuTopoOuStockage.add('B'); + for(;j<coordSeq.size();j++) + profilAbs.bathyOuTopoOuStockage.add('T'); + } + else{ + int j; + for(j=0;j<sepsT[0];j++) + profilAbs.bathyOuTopoOuStockage.add('S'); + for(;j<sepsT[1];j++) + profilAbs.bathyOuTopoOuStockage.add('B'); + for(;j<coordSeq.size();j++) + profilAbs.bathyOuTopoOuStockage.add('S'); + } + } + else + for(int j=0;j<coordSeq.size();j++) + profilAbs.bathyOuTopoOuStockage.add('B'); + + // Verification de la coh\xE9rence des r\xE9sultats + if(version_.equals("1d")) + if(!profilAbs.check1D()) + throw new MascaretDataError("Erreur de programmation : les donn\xE9es g\xE9n\xE9r\xE9es ne sont pas coh\xE9rente pour le 1d."); + else + if(!profilAbs.check2D()) + throw new MascaretDataError("Erreur de programmation : les donn\xE9es g\xE9n\xE9r\xE9es ne sont pas coh\xE9rente pour le 2d."); + + // Stockage avec les autres \\ + profils_[i]=profilAbs; + } + } + + /** + * Calcul l'abscisse curviligne du point indiqu\xE9 en param\xE8tre + */ + private double absCurv(CoordinateSequence _coordSeq, Coordinate _point){ + int k=idxIntersection(_coordSeq, _point); + // Calcule de l'abscisse curviligne + double valueCurviligne=0; + for (int j=1; j<=k; j++) + valueCurviligne+=_coordSeq.getCoordinate(j).distance(_coordSeq.getCoordinate(j-1)); + // Mise \xE0 jour de l'abscisse curviligne + valueCurviligne+=_coordSeq.getCoordinate(k).distance(_point); + return valueCurviligne; + } + + /** + * Calcul l'abscisse curviligne du point indiqu\xE9 en param\xE8tre + */ + private double absCurv(CoordinateSequence _coordSeq, int _idxPoint){ + if(_idxPoint==0) + return 0; + double valueCurviligne=0; + for (int j=1; j<=_idxPoint; j++) + valueCurviligne+=_coordSeq.getCoordinate(j).distance(_coordSeq.getCoordinate(j-1)); + return valueCurviligne; + } + + /** + * Retourne l'indice pr\xE9c\xE9dent d'un point d'intersectin avec une geometrie. + */ + private int idxIntersection(CoordinateSequence _coordSeq, Coordinate _point){ + /* Recherche de l'index du dernier point de la polyligne \xE0 prendre en + * compte. */ + boolean fini=false; + int k=-1; + GISPoint point= new GISPoint(_point); + while (!fini&&++k<_coordSeq.size()-1) + fini=(GISGeometryFactory.INSTANCE + .createLineString(new Coordinate[]{_coordSeq.getCoordinate(k), _coordSeq.getCoordinate(k+1)})).intersects(point); + return k; + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:mergeinfo + /branches/Br_FudaaModeleur_TF/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryListener.java:3445-3850 /branches/FudaaModeleur_TC1/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryListener.java:3861-3891 Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlProjectExportPanel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlProjectExportPanel.java 2008-12-22 14:20:55 UTC (rev 4311) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlProjectExportPanel.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -284,7 +284,7 @@ nbFiles++; } String name=CtuluLibFile.getSansExtension(f.getName()); - // Teste sur l'existance des fichier. Dans le cas d'un enregistrement en + // Test sur l'existence des fichier. Dans le cas d'un enregistrement en // rubar, il faut aussi tester avec les extensions .sem et .cn et aussi <nom>_autres.st if (CtuluLibFile.getExtension(f.getName()).equalsIgnoreCase("st")) { if ((new File(f.getParent()+File.separatorChar+name+".sem")).exists()) { Deleted: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/Controller1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/Controller1d.java 2008-12-22 14:20:55 UTC (rev 4311) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/Controller1d.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -1,262 +0,0 @@ -/* - * @creation 9 d\xE9c. 2008 - * @modification $Date:$ - * @license GNU General Public License 2 - * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne - * @mail fud...@li... - */ -package org.fudaa.fudaa.modeleur.modeleur1d; - -import java.awt.Color; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -import javax.swing.Action; -import javax.swing.JComponent; -import javax.swing.JDesktopPane; -import javax.swing.event.InternalFrameAdapter; -import javax.swing.event.InternalFrameEvent; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import org.fudaa.ctulu.CtuluCommandManager; -import org.fudaa.ctulu.CtuluListSelectionEvent; -import org.fudaa.ctulu.CtuluListSelectionListener; -import org.fudaa.ctulu.gis.GISAttributeConstants; -import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; -import org.fudaa.ebli.calque.BArbreCalqueModel; -import org.fudaa.ebli.calque.ZCalqueAffichageDonneesInterface; -import org.fudaa.ebli.calque.ZScene; -import org.fudaa.ebli.calque.ZSelectionEvent; -import org.fudaa.ebli.calque.ZSelectionListener; -import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; -import org.fudaa.ebli.commun.EbliActionInterface; -import org.fudaa.ebli.commun.EbliFormatter; -import org.fudaa.ebli.commun.EbliFormatterInterface; -import org.fudaa.ebli.commun.EbliLib; -import org.fudaa.fudaa.commun.FudaaLib; -import org.fudaa.fudaa.modeleur.MdlImplementation; - -import com.memoire.bu.BuDesktop; -import com.memoire.bu.BuLabel; - -/** - * Cette classe a la charge et la responsabilit\xE9 de g\xE9rer toutes les actions, - * interactions et r\xE9actions de la fen\xEAtre 1d dans son ensemble. - * - * @author Emmanuel MARTIN - * @version $Id$ - */ -public class Controller1d extends InternalFrameAdapter implements ZSelectionListener, ListSelectionListener, CtuluListSelectionListener { - - /** La vue du bief. */ - private VueBief vueBief_; - /** La vue d'un profil par tableau. */ - private VueTableau vueTableau_; - /** La vue d'un profil via une courbe. */ - private VueCourbe vueCourbe_; - /** Un label pour afficher les erreurs. */ - private BuLabel vueError_; - /** Le lien avec le reste de l'application. */ - private MdlImplementation appli_; - /** La frame contenant tous les widgets 1d. */ - private MdlFille1d frame1d_; - /** Indique si on doit \xE9couter les \xE9venements de selection. */ - private boolean listenEventSelection_=true; - /** L'adapter des donn\xE9es de la geometry en cours de manipulation. */ - private DataGeometryAdapter dataGeomAdapter_; - /** Formater */ - private EbliFormatterInterface formater_=new EbliFormatter(); - /** Le commande manager pour le undo/redo */ - private CtuluCommandManager mng_; - - public Controller1d(MdlImplementation _appli, MdlFille1d _frame1d){ - if(_appli==null||_frame1d==null) - throw new IllegalArgumentException("Les param\xE8tres ne doivent pas \xEAtre null."); - appli_=_appli; - frame1d_=_frame1d; - frame1d_.addInternalFrameListener(this); - mng_=new CtuluCommandManager(); - vueBief_=new VueBief(appli_, this); - vueBief_.getScene().addSelectionListener(this); - treeModel_=vueBief_.getArbreCalqueModel(); - try { - dataGeomAdapter_=new DataGeometryAdapter(null, -1); - } - catch (DataGeometryException _exc) { - _exc.printStackTrace(); - } - vueTableau_=new VueTableau(this, dataGeomAdapter_); - vueTableau_.addSelectionListener(this); - vueCourbe_=new VueCourbe(this, dataGeomAdapter_); - vueCourbe_.addSelectionListener(this); - vueError_=new BuLabel(); - vueError_.setForeground(Color.RED); - clearError(); - } - - public VueBief getVueBief(){ - return vueBief_; - } - public VueTableau getVueTableau(){ - return vueTableau_; - } - public VueCourbe getVueCourbe(){ - return vueCourbe_; - } - public JComponent getVueError(){ - return vueError_; - } - - public EbliFormatterInterface getFormater(){ - return formater_; - } - - public CtuluCommandManager getCommandManager(){ - return mng_; - } - - // Gestion de l'affichage des erreurs. \\ - - public void showError(String _message){ - if(_message==null||_message.length()==0) - clearError(); - vueError_.setText(_message); - } - - public void clearError(){ - vueError_.setText(" "); - } - - // Gestion de l'arbre \\ - - /** Le model de l'arbre a afficher sur la droite de l'\xE9cran. */ - private BArbreCalqueModel treeModel_; - - /** Retourne le model de l'abre a afficher sur la droite de l'\xE9can. */ - public BArbreCalqueModel getTreeModel(){ - return treeModel_; - } - - /** - * Mise \xE0 jour de l'arbre des calques a chaque activation de la fen\xEAtre 1d. La - * mise \xE0 jour s'effectue en fonction des calques 2d. - */ - public void internalFrameActivated(InternalFrameEvent e) { - vueBief_.updateTree(); - } - - // Gestion des actions \\ - - /** Les action \xE0 la fen\xEAtre 1d. */ - JComponent[] specificTools_; - - /** - * Renvoie les actions sp\xE9cifiques \xE0 la fen\xEAtre 1d. Ils seront affiches dans la - * tool bar de l'application. - * - * @return specificTools_ - */ - public JComponent[] getToolsActions() { - if (specificTools_==null) { - final JDesktopPane j=frame1d_.getDesktopPane(); - BuDesktop buJ=null; - if (j instanceof BuDesktop) - buJ=(BuDesktop)j; - List<EbliActionInterface> actionAbs=vueBief_.getController().getActions(); - // Selection des actions - String[] tmpAction=new String[]{"RECTANGLE_SELECTION", "POLYGON_SELECTION", "RESTORE", "ZOOM", "ZOOM_ON_SELECTED", - "LAST_VIEW", "MOVE_VIEW", "CHANGE_REFERENCE", "NAVIGATE"}; - // info : Actions not kept : "CHOOSE_COLOR_PALET", "EDIT_LEGEND", "CONFIGURE", "INFOS", "TABLE" - HashSet<String> actionsKept=new HashSet<String>(); - for (int i=0; i<tmpAction.length; i++) - actionsKept.add(tmpAction[i]); - List<EbliActionInterface> actions=new ArrayList<EbliActionInterface>(); - for (int i=0; i<actionAbs.size(); i++) - if (actionAbs.get(i)==null) - actions.add(actionAbs.get(i)); - else if (actionsKept.contains(actionAbs.get(i).getValue(Action.ACTION_COMMAND_KEY))) - actions.add(actionAbs.get(i)); - // Construction des boutons - final List<?> l=EbliLib.updateToolButtons(actions, buJ); - specificTools_=new JComponent[l.size()]; - l.toArray(specificTools_); - } - if (specificTools_==null) - return null; - final JComponent[] r=new JComponent[specificTools_.length]; - System.arraycopy(specificTools_, 0, r, 0, r.length); - return r; - } - - // Gestion de la selection entre les trois widgets (tableau, bief et courbe) \\ - - /** - * Changement de la selection dans le widget de bief. - */ - public void selectionChanged(ZSelectionEvent _evt) { - clearError(); - ZScene scene=vueBief_.getScene(); - int sceneIdSelected=scene.getSelectionHelper().getUniqueSelectedIdx(); - boolean ok=true; // Indique si tout s'est bien pass\xE9. - if (sceneIdSelected==-1) - try {dataGeomAdapter_.setData(null, -1);} - catch (DataGeometryException _exc) {_exc.printStackTrace();} - else { - int idSelected=scene.sceneId2LayerId(sceneIdSelected); - // Extraction des diff\xE9rentes informations n\xE9c\xE9ssaires au changement de - // courbe \\ - ZCalqueAffichageDonneesInterface calque=scene.getLayerForId(sceneIdSelected); - if (calque.modeleDonnees() instanceof ZModeleLigneBriseeEditable) { - GISZoneCollectionLigneBrisee zone=((ZModeleLigneBriseeEditable)calque.modeleDonnees()).getGeomData(); - if (zone.getIndiceOf(GISAttributeConstants.NATURE)!=-1) { - if (zone.getValue(zone.getIndiceOf(GISAttributeConstants.NATURE), idSelected)==GISAttributeConstants.ATT_NATURE_PF) { - try { - dataGeomAdapter_.setData(zone, idSelected); - } - catch (DataGeometryException _exc) { - showError(_exc.getMessage()); - } - } - else - // On a pas selectionn\xE9 un profil, on annule la selection - ok=false; - } - else - // Il n'y a pas d'attribut Nature, on annule la selection - ok=false; - } - else - // Le type de model ne correspond pas, on annule la selection - ok=false; - } - if(!ok) { - //dataGeomAdapter_.setData(null, -1); - scene.clearSelection(); - showError(FudaaLib.getS("Seuls les profils sont selectionnables.")); - } - } - - /** - * Changement de la selection dans le widget du tableau. - */ - public void valueChanged(ListSelectionEvent e) { - if (listenEventSelection_) { - listenEventSelection_=false; - vueCourbe_.setSelection(vueTableau_.getSelection()); - listenEventSelection_=true; - } - } - - /** - * Changement de la selection dans le widget de la courbe. - */ - public void listeSelectionChanged(CtuluListSelectionEvent _e) { - if (listenEventSelection_) { - listenEventSelection_=false; - vueTableau_.setSelection(vueCourbe_.getSelection()); - listenEventSelection_=true; - } - } -} Deleted: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometry.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometry.java 2008-12-22 14:20:55 UTC (rev 4311) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometry.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -1,68 +0,0 @@ -/* - * @creation 10 d\xE9c. 2008 - * @modification $Date:$ - * @license GNU General Public License 2 - * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne - * @mail fud...@li... - */ -package org.fudaa.fudaa.modeleur.modeleur1d; - -import org.fudaa.ctulu.CtuluCommandContainer; - -/** - * Une interface permettant d'acc\xE9der aux informations manipul\xE9es par les - * widgets tableau et courbe. - * - * @author Emmanuel MARTIN - * @version $Id$ - */ -public interface DataGeometry { - - /** Ajout d'un nouveau listener. */ - public void addDataGeometryListener(DataGeometryListener _listener); - - /** Supprime le listener. */ - public void removeDataGeometryListener(DataGeometryListener _listener); - - /** Retourne le nombre de points total de la geometry. */ - public int getNbPoint(); - - /** Retourne l'abcisse curviligne du point indiqu\xE9 en param\xE8tre. */ - public double getCurv(int _idxPoint); - - /** Retourne la valeur maximal de l'abcisse curviligne. */ - public double getCurvMax(); - - /** Retourne la valeur minimal de l'abcisse curvilgne. */ - public double getCurvMin(); - - /** Retourne la valeur de z du point indiqu\xE9 en param\xE8tre. */ - public double getZ(int _idxPoint); - - /** Retourne la valeur maximal de z. */ - public double getZMax(); - - /** Retourne la valeur minimal de z. */ - public double getZMin(); - - /** - * Enregistre l'abcisse curviligne du point indiqu\xE9 en param\xE8tre. - * Ce changement d'abscisse curviligne fonctionne sur tout les points. - * Si un points extr\xE9mit\xE9 est chang\xE9, le point 2D est d\xE9plac\xE9 sur son axe, - * la longueur globale n'est pas concerv\xE9e dans l'op\xE9ration. - * Si c'est un point de rupture le point 2D est d\xE9plac\xE9 de telle mani\xE8re - * que la longueur globale soit concerv\xE9e. - * Pour les autres points, le point 2D est d\xE9plac\xE9 sur son axe en concervant - * la longeur globale. - */ - public void setCurv(int _idxPoint, double _value, CtuluCommandContainer _cmd) throws DataGeometryException; - - /** Enregistre la valeur de z du point indiqu\xE9 en param\xE8tre. */ - public void setZ(int _idxPoint, double _value, CtuluCommandContainer _cmd); - - /** Enregistre l'abcisse curviligne et la valeur de z du point indiqu\xE9 en param\xE8tre. */ - public void setValues(int _idxPoint, double _valueCurv, double _valueZ, CtuluCommandContainer _cmd) throws DataGeometryException; - - /** Supprime le point indiqu\xE9 en param\xE8tre. */ - public void remove(int _idxPoint, CtuluCommandContainer _cmd) throws DataGeometryException; -} Deleted: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryAdapter.java 2008-12-22 14:20:55 UTC (rev 4311) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryAdapter.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -1,737 +0,0 @@ -/* - * @creation 10 d\xE9c. 2008 - * @modification $Date:$ - * @license GNU General Public License 2 - * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne - * @mail fud...@li... - */ -package org.fudaa.fudaa.modeleur.modeleur1d; - -import java.util.ArrayList; -import java.util.List; - -import org.fudaa.ctulu.CtuluCommand; -import org.fudaa.ctulu.CtuluCommandComposite; -import org.fudaa.ctulu.CtuluCommandContainer; -import org.fudaa.ctulu.CtuluListSelection; -import org.fudaa.ctulu.CtuluNamedCommand; -import org.fudaa.ctulu.collection.CtuluCollection; -import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; -import org.fudaa.ctulu.gis.GISGeometryFactory; -import org.fudaa.ctulu.gis.GISPolyligne; -import org.fudaa.ctulu.gis.GISZoneCollection; -import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; -import org.fudaa.fudaa.commun.FudaaLib; - -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.CoordinateSequence; -import com.vividsolutions.jts.geom.Geometry; - -/** - * Cette classe permet d'adapter une GISZoneCollection en un model manipulable - * simplement. Cette simplification se fait en cachant toutes les informations - * inutils et en ajoutant une information d'abcisse curviligne. - * - * @author Emmanuel MARTIN - * @version $Id$ - */ -public class DataGeometryAdapter implements DataGeometry { - - /** - * Un command container pour le undo/redo. - * Fonctionnement : - * Deux \xE9l\xE9ments sont \xE0 prendre en compte lors du undo/redo : - * 1) Il peut \xEAtre n\xE9c\xE9ssaire de mettre a jour le z et/ou le curv. - * 2) Le undo/redo peut \xEAtre d\xE9clanch\xE9 alors que le DataGeometryAdapter g\xE9re actuellement une autre g\xE9om\xE9try. - * Pour g\xE9rer ces deux cas : - * 1) Deux booleans sont pris par le constructeur indiquant si il faut mettre \xE0 jour les valeurs de z et/ou de curv. - * 2) La zone et l'index de la g\xE9om\xE9trie g\xE9r\xE9 au moment de l'action sont m\xE9moris\xE9s pour g\xE9rer le cas 2. Dans le cas - * o\xF9 un autre g\xE9om\xE9trie est g\xE9r\xE9e au moment du undo/redo aucun update n'est d\xE9clanch\xE9. - * Ainsi m\xEAme si la g\xE9om\xE9trie selectionn\xE9 change plein de fois, revient sur la selection pr\xE9c\xE9dente etc...La mise \xE0 - * jour visuelle se fera correctement. - * Information suppl\xE9mentaire : pour fonctionner correctement le CtuluCommandContainer prit en param\xE8tre contenant - * le undo/redo ne doit pas d\xE9pendre de DataGeometryAdapter mais seulement de la zone. - */ - protected class DGCommandUndoRedo implements CtuluCommand, CtuluNamedCommand { - private CtuluCommand cmd_; - private boolean updateZ_; - private boolean updateCurv_; - private GISZoneCollectionLigneBrisee oldZone_; - private int oldIdxGeom_; - - public DGCommandUndoRedo(CtuluCommand _cmd, boolean _updateZ, boolean _updateCurv){ - cmd_=_cmd; - updateZ_=_updateZ; - updateCurv_=_updateCurv; - oldZone_=zone_; - oldIdxGeom_=idxGeom_; - } - - private void updateIfNeeded(){ - if(oldZone_==zone_&&oldIdxGeom_==idxGeom_) { - if(updateZ_) updateCacheZ(); - if(updateCurv_) updateCacheCurv(); - fireDataGeometryChanged(); - } - } - - public void redo() { - cmd_.redo(); - updateIfNeeded(); - } - - public void undo() { - cmd_.undo(); - updateIfNeeded(); - } - - public String getName() { - if(cmd_ instanceof CtuluNamedCommand) - return ((CtuluNamedCommand) cmd_).getName(); - else - return null; - } - } - - private GISZoneCollectionLigneBrisee zone_; - private int idxGeom_; - private CtuluCollection z_; - private List<Double> curv_; - // Caches \\ - int idxZMax_; - int idxZMin_; - // Le profil est potentiellement coup\xE9 en trois, les deux indices qui suivent - // indique l'index de chacune de ces ruptures. - int idxRupture1_; - int idxRupture2_; - - public DataGeometryAdapter(GISZoneCollectionLigneBrisee _zone, int _idxGeom) throws IllegalArgumentException, DataGeometryException { - setData(_zone, _idxGeom); - } - - /** - * Met \xE0 jour les valeurs zMin et zMax. - * Si z_ est null, zMin et zMax sont mises \xE0 -1. - */ - protected void updateCacheZ(){ - if(z_!=null) { - idxZMax_=0; - idxZMin_=0; - for (int i=1; i<z_.getSize(); i++) { - double val=(Double)z_.getObjectValueAt(i); - if (val>(Double)z_.getObjectValueAt(idxZMax_)) - idxZMax_=i; - else if (val<(Double)z_.getObjectValueAt(idxZMin_)) - idxZMin_=i; - } - } - else { - idxZMax_=-1; - idxZMin_=-1; - } - } - - /** - * Met \xE0 jour les valeurs curv_. - * Si curv_ ou zone_ sont null, rien n'est fait. - */ - protected void updateCacheCurv(){ - if(curv_!=null&&zone_!=null) { - CoordinateSequence seq=((GISCoordinateSequenceContainerInterface)zone_.getGeometry(idxGeom_)).getCoordinateSequence(); - curv_.clear(); - double curvPre=0; - curv_.add((double)0); - for (int i=1; i<seq.size(); i++) { - double partialCurv=Math.sqrt(Math.pow(seq.getX(i)-seq.getX(i-1), 2)+Math.pow(seq.getY(i)-seq.getY(i-1), 2)); - curvPre=curvPre+partialCurv; - curv_.add(curvPre); - } - } - } - - /** - * Permet de choisir la g\xE9om\xE9trie sur lequel l'instance va travailler. - * Hypoth\xE8se importante : les points de la g\xE9om\xE9tries sont correctement - * ordonn\xE9s (les points sont ordonn\xE9s en ordre croissant de leur abscisse - * curviligne). La veracit\xE9 de cette hypoth\xE8se n'est PAS v\xE9rifi\xE9 dans setData. - * - * @param _zone la zone contenant la g\xE9om\xE9trie - * @param _idxGeom l'indice de la g\xE9om\xE9trie dans _zone - * @throws DataGeometryException - */ - public void setData(GISZoneCollectionLigneBrisee _zone, int _idxGeom) throws IllegalArgumentException, DataGeometryException { - if (_zone==null&&_idxGeom==-1) { - zone_=null; - idxGeom_=-1; - z_=null; - curv_=null; - } - else if (_zone!=null&&_idxGeom>=0&&_idxGeom<_zone.getNbGeometries()&&_zone.getAttributeIsZ()!=null) { - try { - zone_=_zone; - idxGeom_=_idxGeom; - z_=(CtuluCollection)zone_.getValue(zone_.getIndiceOf(zone_.getAttributeIsZ()), idxGeom_); - curv_=new ArrayList<Double>(); - CoordinateSequence seq=((GISCoordinateSequenceContainerInterface)zone_.getGeometry(idxGeom_)).getCoordinateSequence(); - // Verifie qu'on a bien au minimum deux points. \\ - if (seq.size()<2) - throw new DataGeometryException(FudaaLib.getS("Le profil doit avoir au minimum deux points.")); - // Verifie que deux points cons\xE9cutifs ne sont pas confondus. \\ - for (int i=1; i<seq.size(); i++) - if (seq.getX(i-1)==seq.getX(i)&&seq.getY(i-1)==seq.getY(i)) - throw new DataGeometryException(FudaaLib.getS("Au moins deux points dans le profil sont confondus.")); - // Calcul des acbscisses curvilignes => hypoth\xE8se d'ordonnancement correcte des points \\ - updateCacheCurv(); - // Remplissage du cache Z \\ - updateCacheZ(); - - // Verifie que le profil donn\xE9 ne poss\xE8de pas des axes qui se coupent entre eux \\ - for(int i=1;i<seq.size();i++){ - Geometry mainAxe=GISGeometryFactory.INSTANCE.createLineString(new Coordinate[]{seq.getCoordinate(i-1), seq.getCoordinate(i)}); - boolean ok=true; - // Un seul point d'intersection avec l'axe qui suit - if(i+1<seq.size()&&mainAxe.intersectio... [truncated message content] |
From: <emm...@us...> - 2009-01-06 18:07:59
|
Revision: 4326 http://fudaa.svn.sourceforge.net/fudaa/?rev=4326&view=rev Author: emmanuel_martin Date: 2009-01-06 18:07:57 +0000 (Tue, 06 Jan 2009) Log Message: ----------- modeleur 1d : Les intersections sont d?\195?\169placables, les modifications des gis de rives et de limites de stockages sont r?\195?\169percut?\195?\169es dans le 2d ; plus divers autres trucs Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/collection/CtuluCollectionObjectAbstract.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleLigneBriseeEditable.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerProfil.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueTableau.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/collection/CtuluCollectionObjectAbstract.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/collection/CtuluCollectionObjectAbstract.java 2009-01-06 18:04:41 UTC (rev 4325) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/collection/CtuluCollectionObjectAbstract.java 2009-01-06 18:07:57 UTC (rev 4326) @@ -186,9 +186,8 @@ */ public final boolean set(final int _i, final Object _newObj, final CtuluCommandContainer _c) { // verif basique - if (_i < 0 || _i > getSize() || getValueAt(_i) == _newObj) { + if (_i < 0 || _i >= getSize() || getValueAt(_i) == _newObj) return false; - } final Object old = getValueAt(_i); internalSet(_i, _newObj); fireObjectChanged(_i, _newObj); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-01-06 18:04:41 UTC (rev 4325) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-01-06 18:07:57 UTC (rev 4326) @@ -266,12 +266,12 @@ } // Attributs 1D \\ - + /** - * Attribut contenant la coordonn\xE9e de l'intersection entre une rive gauche et - * un profil. La donn\xE9e sauvgard\xE9e est une coordonn\xE9e (Coordinate). + * Attribut contenant l'index du point correspondant \xE0 l'intersection entre + * une rive gauche et un profil. */ - public final static GISAttribute INTERSECTION_RIVE_GAUCHE=new GISAttribute(null, CtuluLib.getS("Intersection rive gauche"), false){ + public final static GISAttributeInteger INTERSECTION_RIVE_GAUCHE=new GISAttributeInteger(CtuluLib.getS("Intersection rive gauche"), false){ @Override public String getID() { return "ATTRIBUTE_INTERSECTION_RIVE_GAUCHE"; @@ -279,10 +279,10 @@ }; /** - * Attribut contenant la coordonn\xE9e de l'intersection entre une rive droite et - * un profil. La donn\xE9e sauvgard\xE9e est une coordonn\xE9e (Coordinate). + * Attribut contenant l'index du point correspondant \xE0 l'intersection entre + * une rive droite et un profil. */ - public final static GISAttribute INTERSECTION_RIVE_DROITE=new GISAttribute(null, CtuluLib.getS("Intersection rive droite"), false){ + public final static GISAttributeInteger INTERSECTION_RIVE_DROITE=new GISAttributeInteger(CtuluLib.getS("Intersection rive droite"), false){ @Override public String getID() { return "ATTRIBUTE_INTERSECTION_RIVE_DROITE"; @@ -290,11 +290,10 @@ }; /** - * Attribut contenant la coordonn\xE9e de l'intersection entre une limite de - * stockage gauche et un profil. La donn\xE9e sauvgard\xE9e est une coordonn\xE9e - * (Coordinate). + * Attribut contenant l'index du point correspondant \xE0 l'intersection entre + * une limite de stockage gauche et un profil. */ - public final static GISAttribute INTERSECTION_LIMITE_STOCKAGE_GAUCHE=new GISAttribute(null, CtuluLib + public final static GISAttributeInteger INTERSECTION_LIMITE_STOCKAGE_GAUCHE=new GISAttributeInteger(CtuluLib .getS("Intersection limite stockage gauche"), false){ @Override public String getID() { @@ -303,11 +302,10 @@ }; /** - * Attribut contenant la coordonn\xE9e de l'intersection entre une limite de - * stockage droite et un profil. La donn\xE9e sauvgard\xE9e est une coordonn\xE9e - * (Coordinate). + * Attribut contenant l'index du point correspondant \xE0 l'intersection entre + * une limite de stockage droite et un profil. */ - public final static GISAttribute INTERSECTION_LIMITE_STOCKAGE_DROITE=new GISAttribute(null, CtuluLib + public final static GISAttributeInteger INTERSECTION_LIMITE_STOCKAGE_DROITE=new GISAttributeInteger(CtuluLib .getS("Intersection limite stockage droite"), false){ @Override public String getID() { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleLigneBriseeEditable.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleLigneBriseeEditable.java 2009-01-06 18:04:41 UTC (rev 4325) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleLigneBriseeEditable.java 2009-01-06 18:07:57 UTC (rev 4326) @@ -564,7 +564,7 @@ if (zAtt!=null) { if (getGeomData().getModel(zAtt)!=null) { Object oldvalue=getGeomData().getModel(zAtt).getObjectValueAt(i); - Object newvalue=zAtt.createDataForGeom(oldvalue, geometries_.getGeometry(i).getNumPoints()); + Object newvalue=zAtt.createDataForGeom(oldvalue, getGeomData().getGeometry(i).getNumPoints()); if (oldvalue instanceof GISAttributeModelDoubleArray) { GISAttributeModelDoubleArray newvals=(GISAttributeModelDoubleArray)newvalue; GISAttributeModelDoubleArray oldvals=(GISAttributeModelDoubleArray)oldvalue; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java 2009-01-06 18:04:41 UTC (rev 4325) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java 2009-01-06 18:07:57 UTC (rev 4326) @@ -67,7 +67,7 @@ /** La vue d'un profil via une courbe. */ private VueCourbe vueCourbe_; /** Un label pour afficher les erreurs. */ - private BuLabel vueError_; + private BuLabel vueError_=new BuLabel(); /** La vue des modules contenu dans la colonne \xE0 droite. */ private VueContainerModules vueContainerModules_; /** La frame contenant tous les widgets 1d. */ @@ -118,7 +118,6 @@ vueCourbe_=new VueCourbe(this, controllerProfil_.getDataGeometry()); vueCourbe_.addSelectionListener(this); // Vue error - vueError_=new BuLabel(); vueError_.setForeground(Color.RED); vueError_.setHorizontalAlignment(JLabel.CENTER); clearError(); @@ -346,7 +345,15 @@ @Override public void internalFrameActivated(InternalFrameEvent e) { - mng_.clean(); controllerBief_.updateFrom2d(); } + + /* (non-Javadoc) + * @see javax.swing.event.InternalFrameAdapter#internalFrameDeactivated(javax.swing.event.InternalFrameEvent) + */ + @Override + public void internalFrameDeactivated(InternalFrameEvent e) { + mng_.clean(); + controllerBief_.disableSynchronisers(); + } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java 2009-01-06 18:04:41 UTC (rev 4325) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java 2009-01-06 18:07:57 UTC (rev 4326) @@ -61,6 +61,15 @@ } /** + * D\xE9sactive tous les synchroniseurs. + */ + public void disableSynchronisers() { + String[] names=biefSet_.getBiefNames(); + for(int i=0;i<names.length;i++) + biefSet_.getBief(names[i]).enableSynchroniser(false); + } + + /** * Importe les biefs du 2d vers le 1d. */ private void importBiefsFrom2d(BCalque _rootCalque) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerProfil.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerProfil.java 2009-01-06 18:04:41 UTC (rev 4325) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerProfil.java 2009-01-06 18:07:57 UTC (rev 4326) @@ -21,7 +21,7 @@ /** * Controller permettant de g\xE9rer (cr\xE9er, modifier, supprimer, selectionner) les profils. * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public class ControllerProfil { @@ -122,11 +122,12 @@ * Met \xE0 jour dataGeomAdapter_ pour qu'il tienne compte de la nouvelle selection. */ private void updateProfil() { + controller1d_.clearError(); try { profilContainerAdapter_.setSelectedProfil(getMinSelectionIndex()); } catch (ProfilContainerException _exc) { - _exc.printStackTrace(); + controller1d_.showError(_exc.getMessage()); } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-01-06 18:04:41 UTC (rev 4325) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-01-06 18:07:57 UTC (rev 4326) @@ -7,8 +7,10 @@ */ package org.fudaa.fudaa.modeleur.modeleur1d.model; +import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; +import java.util.List; import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ctulu.gis.GISAttributeInterface; @@ -16,8 +18,11 @@ import org.fudaa.ctulu.gis.GISCoordinateSequenceFactory; import org.fudaa.ctulu.gis.GISPolyligne; import org.fudaa.ctulu.gis.GISZoneCollection; +import org.fudaa.ctulu.gis.GISZoneCollectionGeometry; import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; +import org.fudaa.ebli.calque.ZModelGeometryListener; import org.fudaa.ebli.calque.ZModeleLigneBrisee; +import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; import org.fudaa.fudaa.modeleur.layer.MdlModel1dAxe; import org.fudaa.fudaa.modeleur.layer.MdlModel1dBank; import org.fudaa.fudaa.modeleur.layer.MdlModel2dConstraintLine; @@ -40,6 +45,9 @@ public ZModeleLigneBrisee limitesStockages_; public ZModeleLigneBrisee lignesDirectrices_; + /** Le synchroniser de gis. */ + private GisZoneSynchroniser gisSynchroniser_=new GisZoneSynchroniser(); + public Bief(){} public Bief(ZModeleLigneBrisee[] _models){ @@ -214,58 +222,81 @@ seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); } double abscisseCurvIntersectionAxe=UtilsProfil1d.abscisseCurviligne(seqProfil, interAxeProfil); - // D\xE9tection des croisements rives gauches et rives droites \\ - // valeur par defaut - zone.setAttributValue(idxAttRiveGauche, k, seqProfil.getCoordinate(0), null); - zone.setAttributValue(idxAttRiveDroite, k, seqProfil.getCoordinate(seqProfil.size()-1), null); - for (int l=0; l<rives_.getNombre(); l++) { - Geometry inter=((Geometry)rives_.getObject(l)).intersection(profil); - if (inter.getNumPoints()>0) - if (abscisseCurvIntersectionAxe>UtilsProfil1d.abscisseCurviligne(seqProfil, inter.getCoordinate())) - zone.setAttributValue(idxAttRiveGauche, k, inter.getCoordinate(), null); - else - zone.setAttributValue(idxAttRiveDroite, k, inter.getCoordinate(), null); - } - // D\xE9tection des croisements zones de stockage droite et gauche \\ - // Valeur par defaut - zone.setAttributValue(idxAttlsGauche, k, seqProfil.getCoordinate(0), null); - zone.setAttributValue(idxAttlsDroite, k, seqProfil.getCoordinate(seqProfil.size()-1), null); - for (int l=0; l<limitesStockages_.getNombre(); l++) { - Geometry inter=((Geometry)limitesStockages_.getObject(l)).intersection(profil); - if (inter.getNumPoints()>0) - if (abscisseCurvIntersectionAxe>UtilsProfil1d.abscisseCurviligne(seqProfil, inter.getCoordinate())) - zone.setAttributValue(idxAttlsGauche, k, inter.getCoordinate(), null); - else - zone.setAttributValue(idxAttlsDroite, k, inter.getCoordinate(), null); - } + // Ajout des points au profil si n\xE9c\xE9ssaire pour les intersections \\ + // Rives + for (int l=0; l<rives_.getNombre(); l++) + createPointIfNeeded(k, (GISPolyligne) rives_.getObject(l)); + // Limites de stockages + for (int l=0; l<limitesStockages_.getNombre(); l++) + createPointIfNeeded(k, (GISPolyligne) limitesStockages_.getObject(l)); + profil=(Geometry)profils_.getGeomData().getGeometry(k); + seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); + // Valuation des attributs avec les index des points des intersections \\ + // Rives + zone.setAttributValue(idxAttRiveGauche, k, seqProfil.size()-1, null); + zone.setAttributValue(idxAttRiveDroite, k, 0, null); + for (int l=0; l<rives_.getNombre(); l++) + valuateProfilIntersection(k, (Geometry) rives_.getObject(l), idxAttRiveGauche, idxAttRiveDroite, abscisseCurvIntersectionAxe); + // D\xE9tection des croisements zones de stockages droite et gauche \\ + // Limites de stockages + zone.setAttributValue(idxAttlsGauche, k, seqProfil.size()-1, null); + zone.setAttributValue(idxAttlsDroite, k, 0, null); + for (int l=0; l<limitesStockages_.getNombre(); l++) + valuateProfilIntersection(k, (Geometry) limitesStockages_.getObject(l), idxAttlsGauche, idxAttlsDroite, abscisseCurvIntersectionAxe); } } - // Simplification des rives \\ - rives_=new MdlModel1dBank(null, null); - Coordinate[] riveGauche=new Coordinate[profils_.getNombre()]; - Coordinate[] riveDroite=new Coordinate[profils_.getNombre()]; - for (int i=0; i<profils_.getNombre(); i++) { - riveGauche[i]=(Coordinate)zone.getValue(idxAttRiveGauche, i); - riveDroite[i]=(Coordinate)zone.getValue(idxAttRiveDroite, i); + // Suppression des anciennes g\xE9om\xE9tries de rives, limites de stockage et lignes directrices \\ + int[] idxRives=new int[rives_.getNombre()]; + for(int i=0;i<rives_.getNombre();i++) + idxRives[i]=i; + ((ZModeleLigneBriseeEditable) rives_).removeLigneBrisee(idxRives, null); + int[] idxLimiteStockage=new int[limitesStockages_.getNombre()]; + for(int i=0;i<limitesStockages_.getNombre();i++) + idxLimiteStockage[i]=i; + limitesStockages_.getGeomData().removeGeometries(idxLimiteStockage, null); + // Activation du synchroniser + gisSynchroniser_.enable(); + } + + /** + * Valuation des attributs *gauche et *droite des profils. + * + * @param _idxProfil l'index du profil concern\xE9. + * @param _ligne la ligne qui est sens\xE9 crois\xE9 le profil. + * @param _idxAttrGauche l'index de l'attribut gauche o\xF9 sera mit l'information en cas de croisement \xE0 gauche. + * @param _idxAttrDroite l'index de l'attribut gauche o\xF9 sera mit l'information en cas de croisement \xE0 droite. + * @param _absCurvAxeHydrau la valeur de l'abscisse curviligne de l'axe hydrau sur le profil. + */ + private void valuateProfilIntersection(int _idxProfil, Geometry _ligne, int _idxAttrGauche, int _idxAttrDroite, + double _absCurvAxeHydrau) { + Geometry inter=_ligne.intersection((Geometry)profils_.getObject(_idxProfil)); + if (inter.getNumPoints()==1) { + Coordinate coord= inter.getCoordinate(); + int idxIntersection=UtilsProfil1d.getIndex(profils_.getGeomData().getCoordinateSequence(_idxProfil), coord); + if (_absCurvAxeHydrau>UtilsProfil1d.abscisseCurviligne(profils_.getGeomData().getCoordinateSequence(_idxProfil), coord)) + profils_.getGeomData().setAttributValue(_idxAttrDroite, _idxProfil, idxIntersection, null); + else + profils_.getGeomData().setAttributValue(_idxAttrGauche, _idxProfil, idxIntersection, null); } - if (riveGauche.length>1&&riveGauche[0]!=null) - rives_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(riveGauche)), null, null); - if (riveDroite.length>1&&riveDroite[0]!=null) - rives_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(riveDroite)), null, null); - // Simplification des zones de stockages \\ - limitesStockages_=new MdlModel2dConstraintLine(null, null); - Coordinate[] lsGauche=new Coordinate[profils_.getNombre()]; - Coordinate[] lsDroite=new Coordinate[profils_.getNombre()]; - for (int i=0; i<profils_.getNombre(); i++) { - lsGauche[i]=(Coordinate)zone.getValue(idxAttlsGauche, i); - lsDroite[i]=(Coordinate)zone.getValue(idxAttlsDroite, i); + } + + /** + * Cr\xE9e un point \xE0 l'intersection du profil indiqu\xE9 par _idxProfil et de + * _ligne. + */ + private void createPointIfNeeded(int _idxProfil, GISPolyligne _ligne) { + Geometry inter=_ligne.intersection((Geometry)profils_.getObject(_idxProfil)); + CoordinateSequence seq=profils_.getGeomData().getCoordinateSequence(_idxProfil); + if (inter.getNumPoints()==1) { + Coordinate coord=inter.getCoordinate(); + int previousIdx=UtilsProfil1d.getPreviousIndex(seq, coord); + int nextIdx=UtilsProfil1d.getNextIndex(seq, coord); + // Le point n'appartient pas au profil ou La coordonn\xE9e correspond d\xE9j\xE0 \xE0 un point + if (previousIdx==-2||nextIdx==-2||previousIdx+1==nextIdx-1||previousIdx==seq.size()-2&&nextIdx==-1||previousIdx==-1&&nextIdx==1) + return; + // La coordonn\xE9e correspond \xE0 aucun point connu + ((GISZoneCollectionGeometry)profils_.getGeomData()).addAtomic(_idxProfil, previousIdx, coord.x, coord.y, null); } - if (lsGauche.length>0&&lsGauche[0]!=null) - limitesStockages_.getGeomData() - .addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(lsGauche)), null, null); - if (lsDroite.length>0&&lsDroite[0]!=null) - limitesStockages_.getGeomData() - .addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(lsDroite)), null, null); } /** @@ -309,5 +340,212 @@ // Tout est ok return true; } + + /** + * Active ou d\xE9active la synchronisation des gis. (G\xE9n\xE9ration et r\xE9g\xE9n\xE9ration + * des g\xE9om\xE9tries volatiles du type rives, limites et lignes directrices). + */ + public void enableSynchroniser(boolean _bool) { + if(_bool) + gisSynchroniser_.enable(); + else + gisSynchroniser_.disable(); + } + + /** + * Indique au synchroniser que les models du bief ont potentiellement chang\xE9. + * L'appelle \xE0 cette m\xE9thode active automatiquement le synchroniser. + * Note : + * Une fois activ\xE9 le synchroniser met automatiquement \xE0 jour les gis. Cette + * m\xE9thode n'est utile que si les instances des models ont \xE9t\xE9 manuellement + * chang\xE9, auquel cas le synchroniser continuea sa synchronisation sur les + * anciens models. + */ + public void updateSynchroniser() { + gisSynchroniser_.enable(); + } + /** + * Cette classe g\xE8re la g\xE9n\xE9ration et r\xE9g\xE9n\xE9ration des g\xE9om\xE9tries volatiles + * (comme les rives, les limites de stockages et des lignes directrices). + */ + protected class GisZoneSynchroniser implements ZModelGeometryListener { + /** Le model de profil \xE9cout\xE9. */ + private ZModeleLigneBrisee profilsListen_; + /** Le model de rives modifi\xE9. */ + private ZModeleLigneBrisee rivesModified_; + /** Le model de limites de stockages modifi\xE9. */ + private ZModeleLigneBrisee limitesStockagsesModified_; + /** Le model de lignes directrices modifi\xE9. */ + private ZModeleLigneBrisee lignesDirectricesModified_; + // Les index des g\xE9om\xE9tries. \\ + private int idxRiveGauche_=-1; + private int idxRiveDroite_=-1; + private int idxLimiteStockageGauche_=-1; + private int idxLimiteStockageDroite_=-1; + private List<Integer> idxLignesDirectrices_=new ArrayList<Integer>(); + // Les index des attributs \\ + private int idxAttRiveGauche_=-1; + private int idxAttRiveDroite_=-1; + private int idxAttlsGauche_=-1; + private int idxAttlsDroite_=-1; + // TODO lignes directrices + + /** + * Active/met \xE0 jour le synchroniser. + */ + public void enable() { + if(profilsListen_!=null&&profilsListen_!=profils_) + profilsListen_.removeModelListener(this); + if(profils_!=null) { + profils_.addModelListener(this); + profilsListen_=profils_; + rivesModified_=rives_; + limitesStockagsesModified_=limitesStockages_; + lignesDirectricesModified_=lignesDirectrices_; + idxAttRiveGauche_=profilsListen_.getGeomData().getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); + idxAttRiveDroite_=profilsListen_.getGeomData().getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); + idxAttlsGauche_=profilsListen_.getGeomData().getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); + idxAttlsDroite_=profilsListen_.getGeomData().getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); + // TODO lignes directrices + } + regenerateAll(); + } + + /** + * D\xE9active le synchroniser. + */ + public void disable() { + if(profilsListen_!=null) { + profilsListen_.removeModelListener(this); + profilsListen_=null; + rivesModified_=null; + limitesStockagsesModified_=null; + lignesDirectricesModified_=null; + idxRiveGauche_=-1; + idxRiveDroite_=-1; + idxLimiteStockageGauche_=-1; + idxLimiteStockageDroite_=-1; + idxLignesDirectrices_.clear(); + idxAttRiveGauche_=-1; + idxAttRiveDroite_=-1; + idxAttlsGauche_=-1; + idxAttlsDroite_=-1; + // TODO lignes directrices + } + } + + public void attributeAction(Object _source, int att, GISAttributeInterface _att, int _action) {} + + public void attributeValueChangeAction(Object _source, int att, GISAttributeInterface _att, int _idxGeom, Object value) { + if(_att==GISAttributeConstants.INTERSECTION_RIVE_GAUCHE) + updateGeom(_idxGeom, rivesModified_, idxRiveGauche_, idxAttRiveGauche_); + else if(_att==GISAttributeConstants.INTERSECTION_RIVE_DROITE) + updateGeom(_idxGeom, rivesModified_, idxRiveDroite_, idxAttRiveDroite_); + else if(_att==GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE) + updateGeom(_idxGeom, limitesStockagsesModified_, idxLimiteStockageGauche_, idxAttlsGauche_); + else if(_att==GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE) + updateGeom(_idxGeom, limitesStockagsesModified_, idxLimiteStockageDroite_, idxAttlsDroite_); + // TODO lignes directrices + } + + public void geometryAction(Object _source, int _idxGeom, Geometry _geom, int _action) { + if(_action==ZModelGeometryListener.GEOMETRY_ACTION_MODIFY) { + updateGeom(_idxGeom, rivesModified_, idxRiveGauche_, idxAttRiveGauche_); + updateGeom(_idxGeom, rivesModified_, idxRiveDroite_, idxAttRiveDroite_); + updateGeom(_idxGeom, limitesStockagsesModified_, idxLimiteStockageGauche_, idxAttlsGauche_); + updateGeom(_idxGeom, limitesStockagsesModified_, idxLimiteStockageDroite_, idxAttlsDroite_); + // TODO lignes directrices + } + } + + /** + * R\xE9g\xE9n\xE8re toutes les g\xE9om\xE9tries volatiles. + */ + private void regenerateAll() { + GISZoneCollection zone=profilsListen_.getGeomData(); + // Suppression des anciennes g\xE9om\xE9tries \\ + // Rives + int[] idxRives=new int[0]; + if(idxRiveGauche_!=-1&&idxRiveDroite_!=-1) + idxRives=new int[]{idxRiveGauche_, idxRiveDroite_}; + else if(idxRiveGauche_!=-1) + idxRives=new int[]{idxRiveGauche_}; + else if(idxRiveDroite_!=-1) + idxRives=new int[]{idxRiveDroite_}; + rivesModified_.getGeomData().removeGeometries(idxRives, null); + idxRiveGauche_=-1; + idxRiveDroite_=-1; + // Limites stockages + int[] idxLimiteStockages=new int[0]; + if(idxLimiteStockageGauche_!=-1&&idxLimiteStockageDroite_!=-1) + idxLimiteStockages=new int[]{idxLimiteStockageGauche_, idxLimiteStockageDroite_}; + else if(idxLimiteStockageGauche_!=-1) + idxLimiteStockages=new int[]{idxLimiteStockageGauche_}; + else if(idxLimiteStockageDroite_!=-1) + idxLimiteStockages=new int[]{idxLimiteStockageDroite_}; + limitesStockagsesModified_.getGeomData().removeGeometries(idxLimiteStockages, null); + idxLimiteStockageGauche_=-1; + idxLimiteStockageDroite_=-1; + // Lignes directrices + if (idxLignesDirectrices_.size()>0) { + int[] idxLD=new int[idxLignesDirectrices_.size()]; + for (int i=0; i<idxLignesDirectrices_.size(); i++) + idxLD[i]=idxLignesDirectrices_.get(i); + lignesDirectricesModified_.getGeomData().removeGeometries(idxLD, null); + idxLignesDirectrices_.clear(); + } + // Cr\xE9ation des nouvelles g\xE9om\xE9tries \\ + // Rives + Coordinate[] riveGauche=new Coordinate[profilsListen_.getNombre()]; + Coordinate[] riveDroite=new Coordinate[profilsListen_.getNombre()]; + for (int i=0; i<profilsListen_.getNombre(); i++) { + riveGauche[i]=zone.getCoordinateSequence(i).getCoordinate((Integer)zone.getValue(idxAttRiveGauche_, i)); + riveDroite[i]=zone.getCoordinateSequence(i).getCoordinate((Integer)zone.getValue(idxAttRiveDroite_, i)); + } + // Limites de stockages + Coordinate[] lsGauche=new Coordinate[profilsListen_.getNombre()]; + Coordinate[] lsDroite=new Coordinate[profilsListen_.getNombre()]; + for (int i=0; i<profilsListen_.getNombre(); i++) { + lsGauche[i]=zone.getCoordinateSequence(i).getCoordinate((Integer)zone.getValue(idxAttlsGauche_, i)); + lsDroite[i]=zone.getCoordinateSequence(i).getCoordinate((Integer)zone.getValue(idxAttlsDroite_, i)); + } + // Lignes directrices + //TODO + // Ajout des nouvelles g\xE9o\xE9mtries \\ + //Rives + if (riveGauche.length>1&&riveGauche[0]!=null&&rivesModified_!=null) + idxRiveGauche_=rivesModified_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(riveGauche)), null, null); + if (riveDroite.length>1&&riveDroite[0]!=null&&rivesModified_!=null) + idxRiveDroite_=rivesModified_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(riveDroite)), null, null); + // Limites de stockages + if (lsGauche.length>0&&lsGauche[0]!=null&&limitesStockagsesModified_!=null) + idxLimiteStockageGauche_=limitesStockagsesModified_.getGeomData().addGeometry( + new GISPolyligne(new GISCoordinateSequenceFactory().create(lsGauche)), null, null); + if (lsDroite.length>0&&lsDroite[0]!=null&&limitesStockagsesModified_!=null) + idxLimiteStockageDroite_=limitesStockagsesModified_.getGeomData().addGeometry( + new GISPolyligne(new GISCoordinateSequenceFactory().create(lsDroite)), null, null); + // Lignes directrices + // TODO + } + + /** + * Met \xE0 jour la geometrie volatile indiqu\xE9. Le param\xE8tre pass\xE9 est l'index du point \xE0 + * mettre \xE0 jour (qui correspond \xE9galement \xE0 la g\xE9om\xE9trie modifi\xE9). + */ + private void updateGeom(int _idxPoint, ZModeleLigneBrisee _model, int _idxGeomVolatile, int _idxAtt) { + if(_idxGeomVolatile==-1||_idxAtt==-1) + return; + CoordinateSequence seqGeomV=_model.getGeomData().getCoordinateSequence(_idxGeomVolatile); + CoordinateSequence seqProf=profilsListen_.getGeomData().getCoordinateSequence(_idxPoint); + Coordinate coord=seqProf.getCoordinate((Integer) profilsListen_.getGeomData().getValue(_idxAtt, _idxPoint)); + if (!UtilsProfil1d.egal(seqGeomV.getCoordinate(_idxPoint), coord)) { + seqGeomV.setOrdinate(_idxPoint, 0, coord.x); + seqGeomV.setOrdinate(_idxPoint, 1, coord.y); + seqGeomV.setOrdinate(_idxPoint, 2, coord.z); + _model.getGeomData().setCoordinateSequence(_idxGeomVolatile, seqGeomV, null); + } + } + } + } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java 2009-01-06 18:04:41 UTC (rev 4325) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java 2009-01-06 18:07:57 UTC (rev 4326) @@ -23,6 +23,9 @@ */ public class UtilsProfil1d { + /** Tol\xE9rance pour les calcules de comparaison avec des doubles. */ + static private double tolerance_=0.0001; + /** * Retourne vrai si le profil est correct. */ @@ -140,36 +143,66 @@ _a.z=_a.z/normeA; return _a; } - + /** - * Compars les deux vecteurs avec la tol\xE9rance donn\xE9e. - * Le dernier param\xE8tre indique si un normalisation des - * deux vecteurs doit \xEAtre faite avec la comparaison. - * Les vecteurs ne sont pas modif\xE9s dans l'op\xE9ration. + * Compars les deux vecteurs avec la tol\xE9rance donn\xE9e. Le dernier param\xE8tre + * indique si un normalisation des deux vecteurs doit \xEAtre faite avec la + * comparaison. Les vecteurs ne sont pas modif\xE9s dans l'op\xE9ration. _testZ doit + * \xEAtre mit \xE0 vrai pour que la comparaison tienne compte du z. */ - static public boolean egal(Coordinate _a, Coordinate _b, double _tolerance, boolean _normalisation) { + static public boolean egal(Coordinate _a, Coordinate _b, double _tolerance, boolean _normalisation, boolean _testZ) { if(_normalisation){ normalisation(_a); normalisation(_b); } Coordinate diff=vec(_a, _b); - return Math.abs(diff.x)<_tolerance&&Math.abs(diff.y)<_tolerance&&Math.abs(diff.z)<_tolerance; + return Math.abs(diff.x)<_tolerance&&Math.abs(diff.y)<_tolerance&&(!_testZ||Math.abs(diff.z)<_tolerance); } /** + * Comme 'egal' sauf que _tolerance _normalisation et _testZ sont valu\xE9s. + */ + static public boolean egalSansZ(Coordinate _a, Coordinate _b) { + return egal(_a, _b, tolerance_, false, false); + } + + /** + * Comme 'egal' sans l'attribut _testZ qui est mit \xE0 vrai. + */ + static public boolean egal(Coordinate _a, Coordinate _b, double _tolerance, boolean _normalisation) { + return egal(_a, _b, _tolerance, _normalisation, true); + } + + /** + * Comme 'egal' sans le dernier param\xE8tre qui n'a de sens que lorsque les + * Coordinates sont des vecteurs. + */ + static public boolean egal(Coordinate _a, Coordinate _b, double _tolerance) { + return egal(_a, _b, _tolerance, false); + } + + /** + * Comme 'egal' sans la tolerance (la tolerance par defaut est utilis\xE9) ni la + * normalisation. + */ + static public boolean egal(Coordinate _a, Coordinate _b) { + return egal(_a, _b, tolerance_); + } + + /** * Retourne l'index du point pr\xE9c\xE9dent la coordonn\xE9e indiqu\xE9e sur la coordinateSequence donn\xE9e. * Retourne -1 si la coordonn\xE9e donn\xE9e correspond \xE0 l'index 0. * Retourne -2 si la coordonn\xE9e n'appartient pas \xE0 la g\xE9om\xE9trie. */ static public int getPreviousIndex(CoordinateSequence _geom, Coordinate _point) { - if(_point==null||_geom.size()<=0||_point.equals(_geom.getCoordinate(0))) + if(_point==null||_geom.size()<=0||egal(_point, _geom.getCoordinate(0))) return -1; boolean fini=false; int i=-1; GISPoint point=new GISPoint(_point); while (!fini&&++i<_geom.size()-1) fini=(GISGeometryFactory.INSTANCE - .createLineString(new Coordinate[]{_geom.getCoordinate(i), _geom.getCoordinate(i+1)})).distance(point)<0.0001; + .createLineString(new Coordinate[]{_geom.getCoordinate(i), _geom.getCoordinate(i+1)})).distance(point)<tolerance_; if(!fini) return -2; else @@ -182,19 +215,35 @@ * Retourne -2 si la coordonn\xE9e n'appartient pas \xE0 la g\xE9om\xE9trie. */ static public int getNextIndex(CoordinateSequence _geom, Coordinate _point) { - if(_point==null||_geom.size()<=0||_point.equals(_geom.getCoordinate(_geom.size()-1))) + if(_point==null||_geom.size()<=0||egal(_point, _geom.getCoordinate(_geom.size()-1))) return -1; boolean fini=false; - int i=_geom.size()-1; + int i=_geom.size(); GISPoint point=new GISPoint(_point); while (!fini&&--i>0) fini=(GISGeometryFactory.INSTANCE - .createLineString(new Coordinate[]{_geom.getCoordinate(i-1), _geom.getCoordinate(i)})).distance(point)<0.0001; + .createLineString(new Coordinate[]{_geom.getCoordinate(i-1), _geom.getCoordinate(i)})).distance(point)<tolerance_; if(!fini) return -2; else return i; } + + /** + * Retourne l'index de la coordonn\xE9e pass\xE9e en param\xE8tre. Si le point n'existe + * pas -1 est retourn\xE9. + */ + static public int getIndex(CoordinateSequence _geom, Coordinate _point) { + if(_geom==null||_point==null) + return -1; + boolean found=false; + int i=-1; + while(!found&&++i<_geom.size()) + found=egalSansZ(_geom.getCoordinate(i), _point); + if(found) + return i; + return -1; + } /** * Retourne l'abscisse curviligne du point '_point' de la polyligne '_geom'. Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueTableau.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueTableau.java 2009-01-06 18:04:41 UTC (rev 4325) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueTableau.java 2009-01-06 18:07:57 UTC (rev 4326) @@ -57,7 +57,7 @@ } /** - * Met \xE0 jour l'affichage de l'abscisse curviligne d + * Met \xE0 jour l'affichage de l'abscisse curviligne du profil sur l'axe hydraulique. */ private void updateAbscisseCurvAxeHydraulique() { double abscCurv=data_.getAbsCurvProfilOnAxeHydraulique(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2008-12-30 15:19:57
|
Revision: 4316 http://fudaa.svn.sourceforge.net/fudaa/?rev=4316&view=rev Author: emmanuel_martin Date: 2008-12-30 15:19:53 +0000 (Tue, 30 Dec 2008) Log Message: ----------- L'import des rives gauches et droites et des limites de stockages gauches et droites depuis le 2d est fait correctement. Une simplification pour le 1d est fait, sans d?\195?\169truire les donn?\195?\169es 2d. Des modifications dans la partie 2d entrainent une mise ?\195?\160 jour dans la partie 1d. ATTENTION actuellement la mise ?\195?\160 jour depuis la partie 2d provoque la destruction de toutes les modifications faites dans la partie 1D ! Un comportement plus fin sera mise en place dans un commit ult?\195?\169rieur. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/SceneAbscisseCurviligneAction.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dBank.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueBief.java Added Paths: ----------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/persistence/MdlLayer2dBankPersistence.java Removed Paths: ------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dStorageLimit.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dStorageLimit.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2008-12-24 15:09:43 UTC (rev 4315) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2008-12-30 15:19:53 UTC (rev 4316) @@ -56,8 +56,6 @@ public final static String ATT_NATURE_CE="CE"; /** Nature axe hydraulique */ public final static String ATT_NATURE_AH="AH"; - /** Nature limite de stockage (gauche ou droite) */ - public final static String ATT_NATURE_LS="LS"; /** Nature rive (gauche ou droite) */ public final static String ATT_NATURE_RV="RV"; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java 2008-12-24 15:09:43 UTC (rev 4315) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java 2008-12-30 15:19:53 UTC (rev 4316) @@ -23,6 +23,7 @@ import org.fudaa.fudaa.modeleur.action.CalqueDeleteCalqueAction; import org.fudaa.fudaa.modeleur.action.CalqueNewCalqueAction; import org.fudaa.fudaa.modeleur.layer.MdlLayer1dAxe; +import org.fudaa.fudaa.modeleur.layer.MdlLayer1dBank; import org.fudaa.fudaa.modeleur.layer.MdlLayer1dTrace; import org.fudaa.fudaa.modeleur.layer.MdlLayer2dCloud; import org.fudaa.fudaa.modeleur.layer.MdlLayer2dConstraintLine; @@ -296,6 +297,10 @@ MdlLayer2dConstraintLine cqConst=new MdlLayer2dConstraintLine(getEditor()); cqConst.setName(BGroupeCalque.findUniqueChildName(cqBief, cqConst.getExtName())); cqBief.add(cqConst); + + MdlLayer1dBank cqBank=new MdlLayer1dBank(getEditor()); + cqBank.setName(BGroupeCalque.findUniqueChildName(cqBief, cqBank.getExtName())); + cqBief.add(cqBank); } /** Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/SceneAbscisseCurviligneAction.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/SceneAbscisseCurviligneAction.java 2008-12-24 15:09:43 UTC (rev 4315) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/SceneAbscisseCurviligneAction.java 2008-12-30 15:19:53 UTC (rev 4316) @@ -160,11 +160,9 @@ */ public Coordinate coordinateClicked(Coordinate _coord, double tolerance){ Point ptClick=new GeometryFactory().createPoint(_coord); - boolean returnValue=false; if (selectedGeometry_!=null&&selectedGeometry_.distance(ptClick)<tolerance) { // Recherche de l'index du dernier point de la polyligne \xE0 prendre en // compte. - returnValue=true; boolean fini=false; int i=-1; CoordinateSequence coordSeq=selectedGeometry_.getCoordinateSequence(); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dBank.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dBank.java 2008-12-24 15:09:43 UTC (rev 4315) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dBank.java 2008-12-30 15:19:53 UTC (rev 4316) @@ -15,13 +15,13 @@ import org.fudaa.ebli.trace.TraceLigne; import org.fudaa.ebli.trace.TraceLigneModel; import org.fudaa.fudaa.modeleur.MdlResource; -import org.fudaa.fudaa.modeleur.persistence.MdlLayer2dDirectionLinePersistence; +import org.fudaa.fudaa.modeleur.persistence.MdlLayer2dBankPersistence; import org.fudaa.fudaa.sig.layer.FSigEditor; /** * Un calque pour le stockage et la manipulation des rives. * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public class MdlLayer1dBank extends MdlLayer2dLine { @@ -43,7 +43,7 @@ } public BCalquePersistenceInterface getPersistenceMng() { - return new MdlLayer2dDirectionLinePersistence(); + return new MdlLayer2dBankPersistence(); } /** Deleted: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dStorageLimit.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dStorageLimit.java 2008-12-24 15:09:43 UTC (rev 4315) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dStorageLimit.java 2008-12-30 15:19:53 UTC (rev 4316) @@ -1,60 +0,0 @@ -/* - * @creation 23 d\xE9c. 2008 - * @modification $Date:$ - * @license GNU General Public License 2 - * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne - * @mail fud...@li... - */ -package org.fudaa.fudaa.modeleur.layer; - -import java.awt.Color; - -import org.fudaa.ebli.calque.BCalquePersistenceInterface; -import org.fudaa.ebli.calque.dessin.DeForme; -import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; -import org.fudaa.ebli.trace.TraceLigne; -import org.fudaa.ebli.trace.TraceLigneModel; -import org.fudaa.fudaa.modeleur.MdlResource; -import org.fudaa.fudaa.modeleur.persistence.MdlLayer2dDirectionLinePersistence; -import org.fudaa.fudaa.sig.layer.FSigEditor; - -/** - * Un calque pour le stockage et la manipulation des limites de stockage. - * @author Emmanuel MARTIN - * @version $Id$ - */ -public class MdlLayer2dStorageLimit extends MdlLayer2dLine { - - /** - * Constructeur. Utilise un mod\xE8le de donn\xE9es et un editeur. - * @param _model Modele - * @param _editor Editeur. - */ - private MdlLayer2dStorageLimit(ZModeleLigneBriseeEditable _model, final FSigEditor _editor) { - super(_model,_editor); - setLineModel(0, new TraceLigneModel(TraceLigne.LISSE, 1.5f, new Color(102,102,255))); - setLineModelOuvert(getLineModel(0)); - setName(getExtName()); - setTitle(MdlResource.MDL.getString("Limites de stockage")); - } - - public MdlLayer2dStorageLimit(FSigEditor _editor) { - this(new MdlModel1dStorageLimit(_editor,_editor.getMng()),_editor); - } - - public BCalquePersistenceInterface getPersistenceMng() { - return new MdlLayer2dDirectionLinePersistence(); - } - - /** - * Retourne le nom par defaut du calque. - * @return Le nom. - */ - public String getExtName() { - return "stockage"; - } - - public boolean canAddForme(int _typeForme) { - return _typeForme==DeForme.LIGNE_BRISEE; - } -} Deleted: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dStorageLimit.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dStorageLimit.java 2008-12-24 15:09:43 UTC (rev 4315) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dStorageLimit.java 2008-12-30 15:19:53 UTC (rev 4316) @@ -1,40 +0,0 @@ -/* - * @creation 23 d\xE9c. 2008 - * @modification $Date:$ - * @license GNU General Public License 2 - * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne - * @mail fud...@li... - */ -package org.fudaa.fudaa.modeleur.layer; - -import org.fudaa.ctulu.CtuluCommandContainer; -import org.fudaa.ctulu.gis.GISAttribute; -import org.fudaa.ctulu.gis.GISAttributeConstants; -import org.fudaa.ebli.calque.ZModelGeometryListener; - -/** - * Un mod\xE8le de gestion de limite de stockage. - * @author Emmanuel MARTIN - * @version $Id:$ - */ -public class MdlModel1dStorageLimit extends MdlModel2dLine { - - /** - * Construction d'un modele de profil avec pile de commandes. - * @param _cmd La pile de commandes pour le undo/redo. - */ - public MdlModel1dStorageLimit(final ZModelGeometryListener _listener, final CtuluCommandContainer _cmd) { - super(_listener); - GISAttribute[] attrs=new GISAttribute[]{ - GISAttributeConstants.BATHY, - GISAttributeConstants.ETAT_GEOM, - GISAttributeConstants.TITRE, - GISAttributeConstants.NATURE, - GISAttributeConstants.VISIBILITE - }; - // Pas de container de commande pour cette op\xE9ration, sinon conserv\xE9 en undo/redo. - getGeomData().setAttributes(attrs, null); - getGeomData().setAttributeIsZ(GISAttributeConstants.BATHY); - getGeomData().setFixedAttributeValue(GISAttributeConstants.NATURE, GISAttributeConstants.ATT_NATURE_LS); - } -} \ No newline at end of file Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java 2008-12-24 15:09:43 UTC (rev 4315) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java 2008-12-30 15:19:53 UTC (rev 4316) @@ -26,7 +26,7 @@ /** * Controller permettant de g\xE9rer (cr\xE9er, modifier, supprimer, selectionner) les biefs. * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public class ControllerBief { @@ -57,20 +57,20 @@ * Se r\xE9g\xE9n\xE8re par rapport aux 2d. */ public void updateFrom2d(){ - // Suppression des biefs pr\xE9c\xE9dents - String[] names=biefSet_.getBiefNames(); - for(int i=0;i<names.length;i++) - biefSet_.removeBief(names[i], null); - // Ajout des nouveaux importBiefsFrom2d(controller1d_.getImplementation().get2dFrame().getVisuPanel().getArbreCalqueModel().getRootCalque().getCalqueParNom("gcBiefs")); } /** - * Import les biefs du 2d vers le 1d. + * Importe les biefs du 2d vers le 1d. */ private void importBiefsFrom2d(BCalque _rootCalque) { if (_rootCalque==null) return; + int selectedValue=biefSelectionModel_.getMinSelectionIndex(); + // Suppression des biefs pr\xE9c\xE9dents + String[] names=biefSet_.getBiefNames(); + for(int i=0;i<names.length;i++) + biefSet_.removeBief(names[i], null); BCalque[] calques=_rootCalque.getCalques(); // It\xE9ration du chaque bief for (int i=0; i<calques.length; i++) { @@ -82,11 +82,11 @@ if (sousCalques[j] instanceof FSigLayerLineEditable) modelsDuFutureBief.add(((FSigLayerLineEditable)sousCalques[j]).getModele()); // Ajout du bief - biefSet_.addBief(calqueBief.getTitle(), modelsDuFutureBief.toArray(new ZModeleLigneBrisee[0]), controller1d_.getCommandManager()); + biefSet_.addBief(calqueBief.getTitle(), modelsDuFutureBief.toArray(new ZModeleLigneBrisee[0]), null); } // Selection d'office du premier Bief si il y en a un - if(biefSet_.getNbBief()>0) - biefSelectionModel_.addSelectionInterval(0, 0); + if(biefSet_.getNbBief()>0&&selectedValue!=-1) + biefSelectionModel_.addSelectionInterval(selectedValue, selectedValue); } /** Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2008-12-24 15:09:43 UTC (rev 4315) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2008-12-30 15:19:53 UTC (rev 4316) @@ -7,19 +7,31 @@ */ package org.fudaa.fudaa.modeleur.modeleur1d.model; +import java.util.Arrays; +import java.util.Comparator; + import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ctulu.gis.GISAttributeInterface; +import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; +import org.fudaa.ctulu.gis.GISCoordinateSequenceFactory; +import org.fudaa.ctulu.gis.GISPolyligne; +import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; import org.fudaa.ebli.calque.ZModeleLigneBrisee; import org.fudaa.fudaa.modeleur.layer.MdlModel1dAxe; import org.fudaa.fudaa.modeleur.layer.MdlModel1dBank; -import org.fudaa.fudaa.modeleur.layer.MdlModel1dStorageLimit; +import org.fudaa.fudaa.modeleur.layer.MdlModel2dConstraintLine; import org.fudaa.fudaa.modeleur.layer.MdlModel2dDirectionLine; import org.fudaa.fudaa.modeleur.layer.MdlModel2dProfile; +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.Geometry; + /** * Contient les informations relatives \xE0 un bief. * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public class Bief { public ZModeleLigneBrisee axeHydraulique_; @@ -31,39 +43,47 @@ public Bief(){} public Bief(ZModeleLigneBrisee[] _models){ - if(_models==null) + if (_models==null) throw new IllegalArgumentException("_models ne peut pas \xEAtre null."); - for(int i=0;i<_models.length;i++) { - if(_models[i]==null) + for (int i=0; i<_models.length; i++) { + if (_models[i]==null) throw new IllegalArgumentException("_models ne doit pas contenir de valeurs null"); - if(_models[i].getGeomData()==null) + if (_models[i].getGeomData()==null) throw new IllegalArgumentException("Certain model n'ont pas de GSIZone."); - if(!(_models[i].getGeomData() instanceof GISZoneCollectionLigneBrisee)) - throw new IllegalArgumentException("Toutes les GISZOne doivent \xEAtre des GISZoneCollectionLigneBrisee."); - String nature=(String) _models[i].getGeomData().getFixedAttributValue(GISAttributeConstants.NATURE); - if(nature==GISAttributeConstants.ATT_NATURE_AH) - if(axeHydraulique_!=null) + if (!(_models[i].getGeomData() instanceof GISZoneCollectionLigneBrisee)) + throw new IllegalArgumentException("Toutes les GISZone doivent \xEAtre des GISZoneCollectionLigneBrisee."); + String nature=(String)_models[i].getGeomData().getFixedAttributValue(GISAttributeConstants.NATURE); + if (nature==null) + throw new IllegalArgumentException("Une des GISZone ne contient pas l'attribut NATURE."); + if (nature==GISAttributeConstants.ATT_NATURE_AH) + if (axeHydraulique_!=null) throw new IllegalArgumentException("Plusieurs models d'axe hydrauliques sont donn\xE9es."); + else if (_models[i].getGeomData().getNbGeometries()>1) + throw new IllegalArgumentException("Il ne peut pas y avoir plusieurs Axes hydrauliques dans le bief."); else axeHydraulique_=_models[i]; - else if(nature==GISAttributeConstants.ATT_NATURE_LD) - if(lignesDirectrices_!=null) + else if (nature==GISAttributeConstants.ATT_NATURE_LD) + if (lignesDirectrices_!=null) throw new IllegalArgumentException("Plusieurs models de lignes directrices sont donn\xE9es."); else lignesDirectrices_=_models[i]; - else if(nature==GISAttributeConstants.ATT_NATURE_LS) - if(limitesStockages_!=null) + else if (nature==GISAttributeConstants.ATT_NATURE_LC) + if (limitesStockages_!=null) throw new IllegalArgumentException("Plusieurs models de limites de stockage sont donn\xE9es."); + else if (_models[i].getGeomData().getNbGeometries()>2) + throw new IllegalArgumentException("Il ne peut pas y avoir plus de 2 limites de stockage."); else limitesStockages_=_models[i]; - else if(nature==GISAttributeConstants.ATT_NATURE_PF) - if(profils_!=null) + else if (nature==GISAttributeConstants.ATT_NATURE_PF) + if (profils_!=null) throw new IllegalArgumentException("Plusieurs models de profils sont donn\xE9es."); else profils_=_models[i]; - else if(nature==GISAttributeConstants.ATT_NATURE_RV) - if(rives_!=null) + else if (nature==GISAttributeConstants.ATT_NATURE_RV) + if (rives_!=null) throw new IllegalArgumentException("Plusieurs models de rives sont donn\xE9es."); + else if (_models[i].getGeomData().getNbGeometries()>2) + throw new IllegalArgumentException("Il ne peut pas y avoir plus de 2 rives."); else rives_=_models[i]; } @@ -75,15 +95,184 @@ if (rives_==null) rives_=new MdlModel1dBank(null, null); if (limitesStockages_==null) - limitesStockages_=new MdlModel1dStorageLimit(null, null); + limitesStockages_=new MdlModel2dConstraintLine(null, null); if (lignesDirectrices_==null) lignesDirectrices_=new MdlModel2dDirectionLine(null, null); + // Valuation des attributs sp\xE9cifiques au 1d \\ + // Verification de la pr\xE9sences des attributs + GISZoneCollection zone=profils_.getGeomData(); + int attToAdd=0; + int idxIlsd=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); + if (idxIlsd==-1) + attToAdd++; + int idxIlsg=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); + if (idxIlsg==-1) + attToAdd++; + int idxRd=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); + if (idxRd==-1) + attToAdd++; + int idxRg=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); + if (idxRg==-1) + attToAdd++; + // Ajout des attributs manquant \\ + if (attToAdd>0) { + GISAttributeInterface[] atts=new GISAttributeInterface[zone.getNbAttributes()+attToAdd]; + int k=0; + for (k=0; k<zone.getNbAttributes(); k++) + atts[k]=zone.getAttribute(k); + if (idxIlsd==-1) + atts[k++]=GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE; + if (idxIlsg==-1) + atts[k++]=GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE; + if (idxRd==-1) + atts[k++]=GISAttributeConstants.INTERSECTION_RIVE_DROITE; + if (idxRg==-1) + atts[k++]=GISAttributeConstants.INTERSECTION_RIVE_GAUCHE; + zone.setAttributes(atts, null); + } + int idxAttRiveGauche=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); + int idxAttRiveDroite=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); + int idxAttlsGauche=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); + int idxAttlsDroite=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); + if (axeHydraulique_.getNombre()==0) + for (int i=0; i<profils_.getNombre(); i++) { + profils_.getGeomData().setAttributValue(idxAttRiveGauche, i, null, null); + profils_.getGeomData().setAttributValue(idxAttRiveDroite, i, null, null); + profils_.getGeomData().setAttributValue(idxAttlsGauche, i, null, null); + profils_.getGeomData().setAttributValue(idxAttlsDroite, i, null, null); + } + if (axeHydraulique_.getNombre()==1) { + Geometry axeHydraulique=(Geometry)axeHydraulique_.getObject(0); + CoordinateSequence seqAxeHydraulique=((GISCoordinateSequenceContainerInterface)axeHydraulique).getCoordinateSequence(); + // R\xE9ordonnancement des profils selon leur placement sur l'axe hydaulique (abs curv) \\ + // Calcul des abscisses curvilignes + Object[][] idxAbsCurv=new Object[profils_.getNombre()][]; + for(int j=0;j<profils_.getNombre();j++) { + Geometry intersection=axeHydraulique.intersection((Geometry) profils_.getObject(j)); + if(intersection.getNumPoints()!=1) + throw new IllegalArgumentException("Au moins un des profils est coup\xE9 plusieurs fois ou jamais."); + idxAbsCurv[j]=new Object[]{j, UtilsProfil1d.abscisseCurviligne(seqAxeHydraulique, intersection.getCoordinate())}; + } + // Tri en fonctino des abcsisses curvilignes + Arrays.sort((Object[])idxAbsCurv, new Comparator<Object>(){ + public int compare(Object o1, Object o2) { + double absCurvO1=(Double)((Object[])o1)[1]; + double absCurvO2=(Double)((Object[])o2)[1]; + if(absCurvO1<absCurvO2) return -1; + if(absCurvO1==absCurvO2) return 0; + else return 1; + } + }); + // R\xE9odonnancement en fonction du nouvel ordre + for (int i=0; i<idxAbsCurv.length; i++) { + if(i!=(Integer)idxAbsCurv[i][0]) { + // Mise \xE0 jour de la table de correspondance + boolean found=false; + int k=i; + while(!found&&++k<idxAbsCurv.length) + found=(Integer) idxAbsCurv[k][0]==i; + if(found) + idxAbsCurv[k][0]=idxAbsCurv[i][0]; + // Mise \xE0 jour de la gis + profils_.getGeomData().switchGeometries((Integer) idxAbsCurv[i][0], i, null); + + } + } + // Construction des rives et limites de stockages \\ + for (int k=0; k<profils_.getNombre(); k++) { + Geometry profil=zone.getGeometry(k); + CoordinateSequence seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); + // Normalisation du sens (gauche/droite) du profil \\ + Coordinate interAxeProfil=profil.intersection(axeHydraulique).getCoordinate(); + // Cr\xE9ation du vecteur contenant le sens de l'axe hydraulique + Coordinate vAxeH; + int idxPrevious=UtilsProfil1d.getPreviousIndex(seqAxeHydraulique, interAxeProfil); + int idxNext=UtilsProfil1d.getNextIndex(seqAxeHydraulique, interAxeProfil); + if(idxPrevious!=-1) + vAxeH=new Coordinate(interAxeProfil.x-seqAxeHydraulique.getCoordinate(idxPrevious).x, interAxeProfil.y-seqAxeHydraulique.getCoordinate(idxPrevious).y, 0); + else + vAxeH=new Coordinate(seqAxeHydraulique.getCoordinate(idxNext).x-interAxeProfil.x, seqAxeHydraulique.getCoordinate(idxNext).y-interAxeProfil.y, 0); + // Cr\xE9ation du vecteur contenant le sens du profil + Coordinate vProfilH; + idxPrevious=UtilsProfil1d.getPreviousIndex(seqProfil, interAxeProfil); + idxNext=UtilsProfil1d.getNextIndex(seqProfil, interAxeProfil); + if(idxPrevious!=-1) + vProfilH=new Coordinate(interAxeProfil.x-seqProfil.getCoordinate(idxPrevious).x, interAxeProfil.y-seqProfil.getCoordinate(idxPrevious).y, 0); + else + vProfilH=new Coordinate(seqProfil.getCoordinate(idxNext).x-interAxeProfil.x, seqProfil.getCoordinate(idxNext).y-interAxeProfil.y, 0); + // Inversion du sens du profil si besoin + double produitVectorielCoordZ=vAxeH.x*vProfilH.y-vAxeH.y*vProfilH.x; + if (produitVectorielCoordZ<0) { + Coordinate[] coords=((Geometry)profil).getCoordinates(); + for (int l=0; l<coords.length/2; l++) { + Coordinate tmp=coords[l]; + coords[l]=coords[coords.length-1-l]; + coords[coords.length-1-l]=tmp; + } + zone.setCoordinateSequence(k, new GISCoordinateSequenceFactory().create(coords), null); + profil=(Geometry)profils_.getGeomData().getGeometry(k); + seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); + } + double abscisseCurvIntersectionAxe=UtilsProfil1d.abscisseCurviligne(seqProfil, interAxeProfil); + // D\xE9tection des croisements rives gauches et rives droites \\ + // valeur par defaut + zone.setAttributValue(idxAttRiveGauche, k, seqProfil.getCoordinate(0), null); + zone.setAttributValue(idxAttRiveDroite, k, seqProfil.getCoordinate(seqProfil.size()-1), null); + for (int l=0; l<rives_.getNombre(); l++) { + Geometry inter=((Geometry)rives_.getObject(l)).intersection(profil); + if (inter.getNumPoints()>0) + if (abscisseCurvIntersectionAxe>UtilsProfil1d.abscisseCurviligne(seqProfil, inter.getCoordinate())) + zone.setAttributValue(idxAttRiveGauche, k, inter.getCoordinate(), null); + else + zone.setAttributValue(idxAttRiveDroite, k, inter.getCoordinate(), null); + } + // D\xE9tection des croisements zones de stockage droite et gauche \\ + // Valeur par defaut + zone.setAttributValue(idxAttlsGauche, k, seqProfil.getCoordinate(0), null); + zone.setAttributValue(idxAttlsDroite, k, seqProfil.getCoordinate(seqProfil.size()-1), null); + for (int l=0; l<limitesStockages_.getNombre(); l++) { + Geometry inter=((Geometry)limitesStockages_.getObject(l)).intersection(profil); + if (inter.getNumPoints()>0) + if (abscisseCurvIntersectionAxe>UtilsProfil1d.abscisseCurviligne(seqProfil, inter.getCoordinate())) + zone.setAttributValue(idxAttlsGauche, k, inter.getCoordinate(), null); + else + zone.setAttributValue(idxAttlsDroite, k, inter.getCoordinate(), null); + } + } + } + // Simplification des rives \\ + rives_=new MdlModel1dBank(null, null); + Coordinate[] riveGauche=new Coordinate[profils_.getNombre()]; + Coordinate[] riveDroite=new Coordinate[profils_.getNombre()]; + for (int i=0; i<profils_.getNombre(); i++) { + riveGauche[i]=(Coordinate)zone.getValue(idxAttRiveGauche, i); + riveDroite[i]=(Coordinate)zone.getValue(idxAttRiveDroite, i); + } + if (riveGauche.length>1&&riveGauche[0]!=null) + rives_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(riveGauche)), null, null); + if (riveDroite.length>1&&riveDroite[0]!=null) + rives_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(riveDroite)), null, null); + // Simplification des zones de stockages \\ + limitesStockages_=new MdlModel2dConstraintLine(null, null); + Coordinate[] lsGauche=new Coordinate[profils_.getNombre()]; + Coordinate[] lsDroite=new Coordinate[profils_.getNombre()]; + for (int i=0; i<profils_.getNombre(); i++) { + lsGauche[i]=(Coordinate)zone.getValue(idxAttlsGauche, i); + lsDroite[i]=(Coordinate)zone.getValue(idxAttlsDroite, i); + } + if (lsGauche.length>0&&lsGauche[0]!=null) + limitesStockages_.getGeomData() + .addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(lsGauche)), null, null); + if (lsDroite.length>0&&lsDroite[0]!=null) + limitesStockages_.getGeomData() + .addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(lsDroite)), null, null); } /** * Retourne vrai si les donn\xE9es contenues dans les champs sont coh\xE9rentes. */ public boolean checkCoherence(){ + // TODO ajouter la verification de la pr\xE9sences des attribtus n\xE9c\xE9ssaires if (axeHydraulique_==null||profils_==null||rives_==null||limitesStockages_==null||lignesDirectrices_==null) return false; // Axe hydraulique @@ -101,7 +290,7 @@ // Limite de stockage if (limitesStockages_.getGeomData()==null||!(limitesStockages_.getGeomData() instanceof GISZoneCollectionLigneBrisee)) return false; - if ((String)limitesStockages_.getGeomData().getFixedAttributValue(GISAttributeConstants.NATURE)!=GISAttributeConstants.ATT_NATURE_LS) + if ((String)limitesStockages_.getGeomData().getFixedAttributValue(GISAttributeConstants.NATURE)!=GISAttributeConstants.ATT_NATURE_LC) return false; if(limitesStockages_.getNbPolyligne()>2) return false; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java 2008-12-24 15:09:43 UTC (rev 4315) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java 2008-12-30 15:19:53 UTC (rev 4316) @@ -100,12 +100,12 @@ private CtuluCollection z_; private List<Double> curv_; // Caches \\ - int idxZMax_; - int idxZMin_; + private int idxZMax_; + private int idxZMin_; // Le profil est potentiellement coup\xE9 en trois, les deux indices qui suivent // indique l'index de chacune de ces ruptures. - int idxRupture1_; - int idxRupture2_; + private int idxRupture1_; + private int idxRupture2_; public ProfilContainerAdapter(BiefContainer _biefContainer) { biefContainer_=_biefContainer; @@ -514,14 +514,14 @@ Coordinate aZ0=new Coordinate(a.x, a.y, 0); Coordinate bZ0=new Coordinate(b.x, b.y, 0); Coordinate cZ0=new Coordinate(c.x, c.y, 0); - Coordinate vecReference=vec(cZ0, proj(cZ0, aZ0, bZ0)); - Coordinate cProj=proj(new Coordinate(x1, y1, 0), aZ0, bZ0); - assert(egal(cProj, proj(new Coordinate(x2, y2, 0), aZ0, bZ0), 0.0001, false)); - if(egal(vecReference, vec(new Coordinate(x1, y1, 0), cProj), 0.0001, true)){ + Coordinate vecReference=UtilsProfil1d.vec(cZ0, UtilsProfil1d.proj(cZ0, aZ0, bZ0)); + Coordinate cProj=UtilsProfil1d.proj(new Coordinate(x1, y1, 0), aZ0, bZ0); + assert(UtilsProfil1d.egal(cProj, UtilsProfil1d.proj(new Coordinate(x2, y2, 0), aZ0, bZ0), 0.0001, false)); + if(UtilsProfil1d.egal(vecReference, UtilsProfil1d.vec(new Coordinate(x1, y1, 0), cProj), 0.0001, true)){ newX=x1; newY=y1; } - else if(egal(vecReference, vec(new Coordinate(x2, y2, 0), cProj), 0.0001, true)) { + else if(UtilsProfil1d.egal(vecReference, UtilsProfil1d.vec(new Coordinate(x2, y2, 0), cProj), 0.0001, true)) { newX=x2; newY=y2; } @@ -724,55 +724,4 @@ for(ProfilContainerListener listener:listeners_) listener.profilContainerSelectedChanged(_idxOldProfil, _idxNewProfil); } - - // Quelques fonctions m\xE9th\xE9matiques \\ - - /** - * retourne le vecteur _a, _b sous forme de Coordinate. - */ - private Coordinate vec(Coordinate _a, Coordinate _b){ - return new Coordinate(_b.x-_a.x, _b.y-_a.y, _b.z-_a.z); - } - - /** - * Retourne la projection de _a sur la droite _b_c. - * Attention : Il s'agit bien d'une projection sur une - * droite et non un segment de droite : le r\xE9sultat - * peut \xEAtre en dehors de [_b, _c] - */ - private Coordinate proj(Coordinate _a, Coordinate _b, Coordinate _c){ - Coordinate vBC=vec(_b, _c); - Coordinate vBA=vec(_b, _a); - double normeBC=Math.sqrt(vBC.x*vBC.x+vBC.y*vBC.y+vBC.z*vBC.z); - double produitScalaireBCBA=vBC.x*vBA.x+vBC.y*vBA.y+vBC.z*vBA.z; - double rapportSurBC=produitScalaireBCBA/(normeBC*normeBC); - return new Coordinate(vBC.x*rapportSurBC+_b.x, vBC.y*rapportSurBC+_b.y, vBC.z*rapportSurBC+_b.z); - } - - /** - * Normalise le vecteur pass\xE9 en param\xE8tre. - */ - private Coordinate normalisation(Coordinate _a){ - double normeA=Math.sqrt(_a.x*_a.x+_a.y*_a.y+_a.z*_a.z); - _a.x=_a.x/normeA; - _a.y=_a.y/normeA; - _a.z=_a.z/normeA; - return _a; - } - - /** - * Compars les deux vecteurs avec la tol\xE9rance donn\xE9e. - * Le dernier param\xE8tre indique si un normalisation des - * deux vecteurs doit \xEAtre faite avec la comparaison. - * Les vecteurs ne sont pas modif\xE9s dans l'op\xE9ration. - */ - private boolean egal(Coordinate _a, Coordinate _b, double _tolerance, boolean _normalisation) { - if(_normalisation){ - normalisation(_a); - normalisation(_b); - } - Coordinate diff=vec(_a, _b); - return Math.abs(diff.x)<_tolerance&&Math.abs(diff.y)<_tolerance&&Math.abs(diff.z)<_tolerance; - } - } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java 2008-12-24 15:09:43 UTC (rev 4315) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java 2008-12-30 15:19:53 UTC (rev 4316) @@ -9,6 +9,7 @@ import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; import org.fudaa.ctulu.gis.GISGeometryFactory; +import org.fudaa.ctulu.gis.GISPoint; import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; import com.vividsolutions.jts.geom.Coordinate; @@ -18,7 +19,7 @@ /** * Quelques fonctions aidant pour la manipulation des profils en 1d. * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public class UtilsProfil1d { @@ -105,4 +106,112 @@ return true; } + // Quelques fonctions m\xE9th\xE9matiques \\ + + /** + * retourne le vecteur _a, _b sous forme de Coordinate. + */ + static public Coordinate vec(Coordinate _a, Coordinate _b){ + return new Coordinate(_b.x-_a.x, _b.y-_a.y, _b.z-_a.z); + } + + /** + * Retourne la projection de _a sur la droite _b_c. + * Attention : Il s'agit bien d'une projection sur une + * droite et non un segment de droite : le r\xE9sultat + * peut \xEAtre en dehors de [_b, _c] + */ + static public Coordinate proj(Coordinate _a, Coordinate _b, Coordinate _c){ + Coordinate vBC=vec(_b, _c); + Coordinate vBA=vec(_b, _a); + double normeBC=Math.sqrt(vBC.x*vBC.x+vBC.y*vBC.y+vBC.z*vBC.z); + double produitScalaireBCBA=vBC.x*vBA.x+vBC.y*vBA.y+vBC.z*vBA.z; + double rapportSurBC=produitScalaireBCBA/(normeBC*normeBC); + return new Coordinate(vBC.x*rapportSurBC+_b.x, vBC.y*rapportSurBC+_b.y, vBC.z*rapportSurBC+_b.z); + } + + /** + * Normalise le vecteur pass\xE9 en param\xE8tre. + */ + static public Coordinate normalisation(Coordinate _a){ + double normeA=Math.sqrt(_a.x*_a.x+_a.y*_a.y+_a.z*_a.z); + _a.x=_a.x/normeA; + _a.y=_a.y/normeA; + _a.z=_a.z/normeA; + return _a; + } + + /** + * Compars les deux vecteurs avec la tol\xE9rance donn\xE9e. + * Le dernier param\xE8tre indique si un normalisation des + * deux vecteurs doit \xEAtre faite avec la comparaison. + * Les vecteurs ne sont pas modif\xE9s dans l'op\xE9ration. + */ + static public boolean egal(Coordinate _a, Coordinate _b, double _tolerance, boolean _normalisation) { + if(_normalisation){ + normalisation(_a); + normalisation(_b); + } + Coordinate diff=vec(_a, _b); + return Math.abs(diff.x)<_tolerance&&Math.abs(diff.y)<_tolerance&&Math.abs(diff.z)<_tolerance; + } + + /** + * Retourne l'index du point pr\xE9c\xE9dent la coordonn\xE9e indiqu\xE9e sur la coordinateSequence donn\xE9e. + * Retourne -1 si la coordonn\xE9e donn\xE9e correspond \xE0 l'index 0. + * Retourne -2 si la coordonn\xE9e n'appartient pas \xE0 la g\xE9om\xE9trie. + */ + static public int getPreviousIndex(CoordinateSequence _geom, Coordinate _point) { + if(_geom.size()>0&&_point.equals(_geom.getCoordinate(0))) + return -1; + boolean fini=false; + int i=-1; + GISPoint point=new GISPoint(_point); + while (!fini&&++i<_geom.size()-1) + fini=(GISGeometryFactory.INSTANCE + .createLineString(new Coordinate[]{_geom.getCoordinate(i), _geom.getCoordinate(i+1)})).distance(point)<0.0001; + if(!fini) + return -2; + else + return i; + } + + /** + * Retourne l'index du point suivant la coordonn\xE9e indiqu\xE9e sur la coordinateSequence donn\xE9e. + * Retourne -1 si la coordonn\xE9e donn\xE9e correspond au dernier l'index. + * Retourne -2 si la coordonn\xE9e n'appartient pas \xE0 la g\xE9om\xE9trie. + */ + static public int getNextIndex(CoordinateSequence _geom, Coordinate _point) { + if(_geom.size()>0&&_point.equals(_geom.getCoordinate(_geom.size()-1))) + return -1; + boolean fini=false; + int i=_geom.size()-1; + GISPoint point=new GISPoint(_point); + while (!fini&&--i>0) + fini=(GISGeometryFactory.INSTANCE + .createLineString(new Coordinate[]{_geom.getCoordinate(i-1), _geom.getCoordinate(i)})).distance(point)<0.0001; + if(!fini) + return -2; + else + return i; + } + + /** + * Retourne l'abscisse curviligne du point '_point' de la polyligne '_geom'. + * Si la coordonn\xE9e n'appartient pas \xE0 la geometry, -1 est retourn\xE9. + */ + static public double abscisseCurviligne(CoordinateSequence _geom, Coordinate _point){ + int i=getPreviousIndex(_geom, _point); + if(i==-1) + return 0; + if(i==-2) + return -1; + // Calcule de l'abscisse curviligne + double valueCurviligne=0; + for (int j=1; j<=i; j++) + valueCurviligne+=_geom.getCoordinate(j).distance(_geom.getCoordinate(j-1)); + // Mise \xE0 jour de l'abscisse curviligne + valueCurviligne+=_geom.getCoordinate(i).distance(_point); + return valueCurviligne; + } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueBief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueBief.java 2008-12-24 15:09:43 UTC (rev 4315) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueBief.java 2008-12-30 15:19:53 UTC (rev 4316) @@ -18,9 +18,9 @@ import org.fudaa.fudaa.modeleur.MdlImplementation; import org.fudaa.fudaa.modeleur.layer.MdlLayer1dAxe; import org.fudaa.fudaa.modeleur.layer.MdlLayer1dBank; +import org.fudaa.fudaa.modeleur.layer.MdlLayer2dConstraintLine; import org.fudaa.fudaa.modeleur.layer.MdlLayer2dDirectionLine; import org.fudaa.fudaa.modeleur.layer.MdlLayer2dProfile; -import org.fudaa.fudaa.modeleur.layer.MdlLayer2dStorageLimit; import org.fudaa.fudaa.modeleur.modeleur1d.controller.ControllerBief; import org.fudaa.fudaa.modeleur.modeleur1d.model.Bief; import org.fudaa.fudaa.sig.layer.FSigEditor; @@ -78,7 +78,7 @@ lignesDirectrices.modele(bief.lignesDirectrices_); groupeCalque.add(lignesDirectrices); // Ajout du calque de limites de stockage - MdlLayer2dStorageLimit limitesStockage=new MdlLayer2dStorageLimit((FSigEditor)gisEditor_); + MdlLayer2dConstraintLine limitesStockage=new MdlLayer2dConstraintLine((FSigEditor)gisEditor_); limitesStockage.modele(bief.limitesStockages_); groupeCalque.add(limitesStockage); // Ajout du calque de profils Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/persistence/MdlLayer2dBankPersistence.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/persistence/MdlLayer2dBankPersistence.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/persistence/MdlLayer2dBankPersistence.java 2008-12-30 15:19:53 UTC (rev 4316) @@ -0,0 +1,30 @@ +/* + * @creation 29 d\xE9c. 2008 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.fudaa.modeleur.persistence; + +import org.fudaa.fudaa.modeleur.layer.MdlLayer1dBank; +import org.fudaa.fudaa.modeleur.layer.MdlLayer2dLine; +import org.fudaa.fudaa.modeleur.layer.MdlLayer2dProfile; +import org.fudaa.fudaa.sig.layer.FSigEditor; + +/** + * Gestion de la persistance pour un calque de lignes de rive. + * @author Emmanuel MARTIN + * @see MdlLayer2dProfile + */ +public class MdlLayer2dBankPersistence extends MdlLayer2dLinePersistence { + + /* (non-Javadoc) + * @see org.fudaa.fudaa.modeleur.persistence.MdlLayer2dLinePersistence#createNewLayer(org.fudaa.fudaa.sig.layer.FSigEditor) + */ + @Override + protected MdlLayer2dLine createNewLayer(FSigEditor _editor) { + return new MdlLayer1dBank(_editor); + } + +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/persistence/MdlLayer2dBankPersistence.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2009-01-08 09:39:12
|
Revision: 4332 http://fudaa.svn.sourceforge.net/fudaa/?rev=4332&view=rev Author: emmanuel_martin Date: 2009-01-08 09:39:03 +0000 (Thu, 08 Jan 2009) Log Message: ----------- Correction d'un bug lors de l'ajout d'un point ?\195?\160 un profil. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionGeometry.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/MdlFille1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionGeometry.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionGeometry.java 2009-01-08 09:22:51 UTC (rev 4331) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionGeometry.java 2009-01-08 09:39:03 UTC (rev 4332) @@ -131,6 +131,8 @@ Geometry geom = (Geometry)super.geometry_.getValueAt(_idxGeom); final Coordinate[] oldcs = geom.getCoordinates(); final int initSize = oldcs.length; + if(_idxBefore<0||_idxBefore>=initSize) + throw new IllegalArgumentException("L'index du point \xE0 ajouter doit appartenir \xE0 la g\xE9om\xE9trie."); final Coordinate[] cs = new Coordinate[initSize + 1]; int idx = 0; for (int i = 0; i < initSize; i++) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/MdlFille1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/MdlFille1d.java 2009-01-08 09:22:51 UTC (rev 4331) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/MdlFille1d.java 2009-01-08 09:39:03 UTC (rev 4332) @@ -15,7 +15,6 @@ import javax.swing.JComponent; import javax.swing.JSplitPane; -import javax.swing.SwingUtilities; import org.fudaa.ctulu.CtuluCommandManager; import org.fudaa.ctulu.CtuluExportDataInterface; @@ -38,7 +37,6 @@ import com.db4o.ObjectSet; import com.db4o.query.Query; import com.memoire.bu.BuBorderLayout; -import com.memoire.bu.BuCommonImplementation; import com.memoire.bu.BuUndoRedoInterface; import com.memoire.fu.FuLog; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java 2009-01-08 09:22:51 UTC (rev 4331) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java 2009-01-08 09:39:03 UTC (rev 4332) @@ -12,7 +12,6 @@ import java.util.HashSet; import java.util.List; import java.util.Observable; -import java.util.Observer; import javax.swing.Action; import javax.swing.DefaultListModel; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-01-08 09:22:51 UTC (rev 4331) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-01-08 09:39:03 UTC (rev 4332) @@ -264,7 +264,7 @@ int previousIdx=UtilsProfil1d.getPreviousIndex(seq, coord); int nextIdx=UtilsProfil1d.getNextIndex(seq, coord); // Le point n'appartient pas au profil ou La coordonn\xE9e correspond d\xE9j\xE0 \xE0 un point - if (previousIdx==-2||nextIdx==-2||previousIdx+1==nextIdx-1||previousIdx==seq.size()-2&&nextIdx==-1||previousIdx==-1&&nextIdx==1) + if (previousIdx==-2||nextIdx==-2||previousIdx+1==nextIdx-1||nextIdx==-1||previousIdx==-1) return; // La coordonn\xE9e correspond \xE0 aucun point connu ((GISZoneCollectionGeometry)profils_.getGeomData()).addAtomic(_idxProfil, previousIdx, coord.x, coord.y, null); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2009-01-08 16:45:27
|
Revision: 4337 http://fudaa.svn.sourceforge.net/fudaa/?rev=4337&view=rev Author: emmanuel_martin Date: 2009-01-08 16:45:23 +0000 (Thu, 08 Jan 2009) Log Message: ----------- Mise ?\195?\160 jour de l'exporteur mascaret. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java 2009-01-08 15:58:18 UTC (rev 4336) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java 2009-01-08 16:45:23 UTC (rev 4337) @@ -23,7 +23,7 @@ import org.fudaa.ctulu.gis.GISGeometryFactory; import org.fudaa.ctulu.gis.GISPoint; import org.fudaa.ctulu.gis.GISPolyligne; -import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; +import org.fudaa.ctulu.gis.GISZoneCollection; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateSequence; @@ -32,7 +32,7 @@ /** * Ecrit au format mascaret 1d et 2d. * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public class MascaretWriter extends FileWriteOperationAbstract { @@ -47,10 +47,10 @@ * Cette classe permet \xE0 l'exporteur de selectionner les * profils \xE0 exporter. G\xE9n\xE9ralement les profiles invalides sont ignor\xE9s. * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public interface FunctorSelectProfil { - public boolean exportProfil(GISZoneCollectionLigneBrisee _zone, int _idxProfil); + public boolean exportProfil(GISZoneCollection _zone, int _idxProfil); } public MascaretWriter() {} @@ -79,7 +79,7 @@ if(((Object[])_o).length!=4) throw new IllegalArgumentException("Il doit y avoir 4 param\xE8tres dans _o."); String nomBief=(String)((Object[])_o)[0]; - GISZoneCollectionLigneBrisee[] zones=(GISZoneCollectionLigneBrisee[])((Object[])_o)[1]; + GISZoneCollection[] zones=(GISZoneCollection[])((Object[])_o)[1]; FunctorSelectProfil selectorProfil=(FunctorSelectProfil)((Object[])_o)[2]; version_=(String)((Object[])_o)[3]; if (nomBief==null) @@ -152,9 +152,9 @@ * @throws MascaretDataError * @throws MascaretDataIncomplete */ - private void generateMascaretProfilAbstractRepresentations(String _nomBief, GISZoneCollectionLigneBrisee[] _zones, FunctorSelectProfil _selectorProfil) throws MascaretDataError, MascaretDataIncomplete{ + private void generateMascaretProfilAbstractRepresentations(String _nomBief, GISZoneCollection[] _zones, FunctorSelectProfil _selectorProfil) throws MascaretDataError, MascaretDataIncomplete{ // Recherche de l'axe hydraulique \\ - GISZoneCollectionLigneBrisee zoneAxeHydraulique=null; + GISZoneCollection zoneAxeHydraulique=null; int indexAxeHydraulique=-1; for (int i=0; i<_zones.length; i++) { int idxAttNature=_zones[i].getIndiceOf(GISAttributeConstants.NATURE); @@ -172,7 +172,7 @@ throw new MascaretDataIncomplete("Il n'y a pas d'axes hydrauliques."); // Recherche des profils \\ - List<GISZoneCollectionLigneBrisee> profils=new ArrayList<GISZoneCollectionLigneBrisee>(); + List<GISZoneCollection> profils=new ArrayList<GISZoneCollection>(); List<Integer> indexProfils=new ArrayList<Integer>(); for (int i=0; i<_zones.length; i++) { int idxAttNature=_zones[i].getIndiceOf(GISAttributeConstants.NATURE); @@ -189,23 +189,19 @@ int countNoName=1; GISPolyligne axeHydraulique=(GISPolyligne)zoneAxeHydraulique.getGeometry(indexAxeHydraulique); for (int i=0;i<profils.size();i++) { - GISZoneCollectionLigneBrisee zoneProfil=profils.get(i); + GISZoneCollection zoneProfil=profils.get(i); int idxProfil=indexProfils.get(i); GISPolyligne profil=(GISPolyligne) zoneProfil.getGeometry(idxProfil); MascaretProfilAbstractRepresentation profilAbs=new MascaretProfilAbstractRepresentation(); // Information globales sur le profil \\ // Nom bief - if(_nomBief.contains(" ")) - throw new MascaretDataError("Le nom du bief ne doit pas contenir d'espace."); - profilAbs.nomBief=_nomBief; + profilAbs.nomBief=_nomBief.replace(' ', '_'); // Nom profil int idxTitle=zoneProfil.getIndiceOf(GISAttributeConstants.TITRE); if(idxTitle!=-1){ String nomProfil=(String) zoneProfil.getValue(idxTitle, idxProfil); - if(nomProfil.contains(" ")) - throw new MascaretDataError("Le nom du profil ne doit pas contenir d'espace."); - profilAbs.nomProfil=nomProfil; + profilAbs.nomProfil=nomProfil.replace(' ', '_'); } else profilAbs.nomProfil="No_Name_"+countNoName++; @@ -238,38 +234,30 @@ ArrayList<Integer> seps=new ArrayList<Integer>(); //INTERSECTION_RIVE_GAUCHE int idxInterRiveG=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); - Coordinate intersectionRiveGauche; Integer idxRG=-1; if(idxInterRiveG!=-1) { - intersectionRiveGauche=(Coordinate) zoneProfil.getValue(idxInterRiveG, idxProfil); - idxRG=idxIntersection(coordSeq, intersectionRiveGauche); + idxRG=(Integer) zoneProfil.getValue(idxInterRiveG, idxProfil); seps.add(idxRG); } //INTERSECTION_RIVE_DROITE int idxInterRiveD=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); - Coordinate intersectionRiveDroite; Integer idxRD=-1; if(idxInterRiveD!=-1) { - intersectionRiveDroite=(Coordinate) zoneProfil.getValue(idxInterRiveD, idxProfil); - idxRD=idxIntersection(coordSeq, intersectionRiveDroite); + idxRD=(Integer) zoneProfil.getValue(idxInterRiveD, idxProfil); seps.add(idxRD); } //INTERSECTION_LIMITE_STOCKAGE_GAUCHE int idxInterStockageG=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); - Coordinate intersectionStockageGauche; Integer idxSG=-1; if(idxInterStockageG!=-1) { - intersectionStockageGauche=(Coordinate) zoneProfil.getValue(idxInterStockageG, idxProfil); - idxSG=idxIntersection(coordSeq, intersectionStockageGauche); + idxSG=(Integer) zoneProfil.getValue(idxInterStockageG, idxProfil); seps.add(idxSG); } //INTERSECTION_LIMITE_STOCKAGE_DROITE int idxInterStockageD=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); - Coordinate intersectionStockageDroit; Integer idxSD=-1; if(idxInterStockageD!=-1) { - intersectionStockageDroit=(Coordinate) zoneProfil.getValue(idxInterStockageD, idxProfil); - idxSD=idxIntersection(coordSeq, intersectionStockageDroit); + idxSD=(Integer) zoneProfil.getValue(idxInterStockageD, idxProfil); seps.add(idxSD); } if(idxRG==-1&&idxRD!=-1||idxRG!=-1&&idxRD==-1) @@ -281,9 +269,9 @@ // Bathy Topo ou Stockage if(sepsT.length==4){ int j; - for(j=0;j<sepsT[0];j++) + for(j=0;j<=sepsT[0];j++) profilAbs.bathyOuTopoOuStockage.add('S'); - for(;j<sepsT[1];j++) + for(;j<=sepsT[1];j++) profilAbs.bathyOuTopoOuStockage.add('T'); for(;j<sepsT[2];j++) profilAbs.bathyOuTopoOuStockage.add('B'); @@ -292,10 +280,10 @@ for(;j<coordSeq.size();j++) profilAbs.bathyOuTopoOuStockage.add('S'); } - if(sepsT.length==2) { + else if(sepsT.length==2) { if(sepsT[0]==idxRG||sepsT[0]==idxRD){ int j; - for(j=0;j<sepsT[0];j++) + for(j=0;j<=sepsT[0];j++) profilAbs.bathyOuTopoOuStockage.add('T'); for(;j<sepsT[1];j++) profilAbs.bathyOuTopoOuStockage.add('B'); @@ -304,7 +292,7 @@ } else{ int j; - for(j=0;j<sepsT[0];j++) + for(j=0;j<=sepsT[0];j++) profilAbs.bathyOuTopoOuStockage.add('S'); for(;j<sepsT[1];j++) profilAbs.bathyOuTopoOuStockage.add('B'); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java 2009-01-08 15:58:18 UTC (rev 4336) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java 2009-01-08 16:45:23 UTC (rev 4337) @@ -32,6 +32,7 @@ import org.fudaa.ctulu.CtuluListSelectionListener; import org.fudaa.ctulu.CtuluNamedCommand; import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; import org.fudaa.dodico.mascaret.io.MascaretWriter; import org.fudaa.ebli.calque.ZCalqueAffichageDonneesInterface; @@ -367,13 +368,13 @@ mascaretWriter.setFile(vueExport.getFile()); Bief bief=controllerBief_.getSelectedBief(); if(bief==null) { - appli_.warn(FudaaLib.getS("Attention"), FudaaLib.getS("Il n'y a pas de bief \xE0 exporter.")); + appli_.warn(FudaaLib.getS("Attention"), FudaaLib.getS("Il n'y a pas de bief selectionn\xE9.")); return; } - Object[] zones=new Object[]{bief.axeHydraulique_.getGeomData(), bief.lignesDirectrices_.getGeomData(), + GISZoneCollection[] zones=new GISZoneCollection[]{bief.axeHydraulique_.getGeomData(), bief.lignesDirectrices_.getGeomData(), bief.limitesStockages_.getGeomData(), bief.profils_.getGeomData(), bief.rives_.getGeomData()}; MascaretWriter.FunctorSelectProfil functorSelectProfil=new MascaretWriter.FunctorSelectProfil() { - public boolean exportProfil(GISZoneCollectionLigneBrisee _zone, int _idxProfil) { + public boolean exportProfil(GISZoneCollection _zone, int _idxProfil) { return UtilsProfil1d.isProfilCorrect(_zone, _idxProfil); } }; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java 2009-01-08 15:58:18 UTC (rev 4336) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java 2009-01-08 16:45:23 UTC (rev 4337) @@ -10,7 +10,7 @@ import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; import org.fudaa.ctulu.gis.GISGeometryFactory; import org.fudaa.ctulu.gis.GISPoint; -import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; +import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.fudaa.commun.FudaaLib; import com.vividsolutions.jts.geom.Coordinate; @@ -30,7 +30,7 @@ /** * Retourne vrai si le profil est correct. */ - static public boolean isProfilCorrect(GISZoneCollectionLigneBrisee _zone, int _idxProfil) { + static public boolean isProfilCorrect(GISZoneCollection _zone, int _idxProfil) { CoordinateSequence seq=((GISCoordinateSequenceContainerInterface)_zone.getGeometry(_idxProfil)).getCoordinateSequence(); // Verifie qu'on a bien au minimum deux points. \\ if (seq.size()<2) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bma...@us...> - 2009-01-09 10:59:51
|
Revision: 4339 http://fudaa.svn.sourceforge.net/fudaa/?rev=4339&view=rev Author: bmarchan Date: 2009-01-09 10:59:45 +0000 (Fri, 09 Jan 2009) Log Message: ----------- Task#141 : Possibilit?\195?\169 de rendre selectionnable/non des calques. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BArbreCalque.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BArbreCalqueModel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonnees.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesAbstract.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesInterface.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dLine.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dMultiPoint.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueBief.java Added Paths: ----------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/ressource/non-selectionnable.png Property Changed: ---------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesAbstract.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BArbreCalque.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BArbreCalque.java 2009-01-09 10:31:50 UTC (rev 4338) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BArbreCalque.java 2009-01-09 10:59:45 UTC (rev 4339) @@ -53,6 +53,11 @@ import org.fudaa.ebli.commun.EbliPopupListener; import org.fudaa.ebli.ressource.EbliResource; +/** + * Un menu pour le composant de cartographie utilisant des calques non bas\xE9s sur des mod\xE8le. + * @see EbliFilleCalques + * @deprecated + */ class BArbreNormalMenu extends BuMenu { /** @@ -321,10 +326,6 @@ } } - public BArbreNormalMenu buildNormalMenu() { - return new BArbreNormalMenu(getArbreModel()); - } - public JPopupMenu buildPopupMenu(final BCalque _calque) { final CtuluPopupMenu r = new CtuluPopupMenu(); getArbreModel().fillPopupMenu(r); @@ -584,6 +585,13 @@ if (calque instanceof ZCalqueAffichageDonneesAbstract) { final ZCalqueAffichageDonneesAbstract cq = (ZCalqueAffichageDonneesAbstract) calque; lbSelect_.setVisible(!cq.isSelectionEmpty()); + + if (!cq.isSelectable()) { + if (s.length() > 0) { + s.append(CtuluLibString.ESPACE); + } + s.append(EbliResource.EBLI.getString("nonsel.")); + } } else { lbSelect_.setVisible(false); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BArbreCalqueModel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BArbreCalqueModel.java 2009-01-09 10:31:50 UTC (rev 4338) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/BArbreCalqueModel.java 2009-01-09 10:59:45 UTC (rev 4339) @@ -30,6 +30,7 @@ import javax.swing.tree.TreeSelectionModel; import com.memoire.bu.BuBorders; +import com.memoire.bu.BuCheckBoxMenuItem; import com.memoire.bu.BuGridLayout; import com.memoire.bu.BuLabel; import com.memoire.bu.BuMenu; @@ -201,6 +202,10 @@ actDown(c); } else if (action.equals(getActLast())) { actLast(c); + } else if (action.equals("SET_SELECTABLE")) { + actSetSelectable(c,true); + } else if (action.equals("UNSET_SELECTABLE")) { + actSetSelectable(c,false); } else { int i = action.indexOf('_'); if (i >= 0) { @@ -223,6 +228,8 @@ quickRefresh(); } else if ("VISIBLE".equals(action)) { calque.setVisible(!calque.isVisible()); + } else if ("SELECTABLE".equals(action) && (calque instanceof ZCalqueAffichageDonneesAbstract)) { + ((ZCalqueAffichageDonneesAbstract) calque).setSelectable(!((ZCalqueAffichageDonneesAbstract) calque).isSelectable()); // refreshSelect = true; } else if ("RENAME".equals(action)) { renameLayer(calque); @@ -256,6 +263,20 @@ } } + /** + * Rend les calques s\xE9lectionnables ou non, en controlaant qu'ils puissent l'etre. + * @param _c Les calques. + * @param _b True : Selectionnables. + */ + private void actSetSelectable(final BCalque[] _c, boolean _b) { + for (int i = 0; i < _c.length; i++) { + if (_c[i] instanceof ZCalqueAffichageDonneesAbstract) { + ZCalqueAffichageDonneesAbstract cq=(ZCalqueAffichageDonneesAbstract)_c[i]; + if (cq.canSetSelectable()) cq.setSelectable(_b); + } + } + } + protected void renameLayer(final BCalque _calque) { final String title = _calque.getTitle(); final BuTextField ft = new BuTextField(title); @@ -374,6 +395,9 @@ _m.addMenuItem(EbliResource.EBLI.getString("Visible"), "VISIBLE_OUI", null, true, 0, this); _m.addMenuItem(EbliResource.EBLI.getString("Cach\xE9"), "VISIBLE_NON", BuResource.BU.getIcon("cacher"), true, 0, this); _m.addSeparator(); + _m.addMenuItem(EbliResource.EBLI.getString("S\xE9lectionnable"), "SET_SELECTABLE", EbliResource.EBLI.getIcon("fleche"), true, 0, this); + _m.addMenuItem(EbliResource.EBLI.getString("Non s\xE9lectionnable"), "UNSET_SELECTABLE", EbliResource.EBLI.getIcon("non-selectionnable"), true, 0, this); + _m.addSeparator(); _m.addMenuItem(EbliResource.EBLI.getString("Att\xE9nu\xE9"), "ATTENUE_OUI", null, true, 0, this); _m.addMenuItem(EbliResource.EBLI.getString(getActNormal()), "ATTENUE_NON", null, true, 0, this); _m.addSeparator(); @@ -404,6 +428,9 @@ final JMenuItem it = _m.addMenuItem(EbliResource.EBLI.getString("Cach\xE9"), "VISIBLE_NON", null, true, this); it.setIcon(BuResource.BU.getIcon("cacher")); _m.addSeparator(); + _m.addMenuItem(EbliResource.EBLI.getString("S\xE9lectionnable"), "SET_SELECTABLE", EbliResource.EBLI.getIcon("fleche"), true, this); + _m.addMenuItem(EbliResource.EBLI.getString("Non s\xE9lectionnable"), "UNSET_SELECTABLE", EbliResource.EBLI.getIcon("non-selectionnable"), true, this); + _m.addSeparator(); _m.addMenuItem(EbliResource.EBLI.getString("Att\xE9nu\xE9"), "ATTENUE_OUI", null, true, this); _m.addMenuItem(EbliResource.EBLI.getString(getActNormal()), "ATTENUE_NON", null, true, this); _m.addSeparator(); @@ -447,6 +474,14 @@ _m.addCheckBox(EbliResource.EBLI.getString("Gel\xE9"), "GELE", true, ci.isGele(), this); } _m.addCheckBox(EbliResource.EBLI.getString("Visible"), "VISIBLE", true, _c.isVisible(), this); + if (_c instanceof ZCalqueAffichageDonneesAbstract) { + ZCalqueAffichageDonneesAbstract cq=(ZCalqueAffichageDonneesAbstract)_c; + if (cq.canSetSelectable()) { + BuCheckBoxMenuItem mi= + _m.addCheckBox(EbliResource.EBLI.getString("S\xE9lectionnable"), "SELECTABLE", EbliResource.EBLI.getIcon("fleche"), true, cq.isSelectable()); + mi.addActionListener(this); + } + } _m.addSeparator(); _m.addMenuItem(EbliResource.EBLI.getString("En premier"), getActPrem(), EbliResource.EBLI.getIcon("enpremier"), true, this); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonnees.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonnees.java 2009-01-09 10:31:50 UTC (rev 4338) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonnees.java 2009-01-09 10:59:45 UTC (rev 4339) @@ -116,6 +116,8 @@ * @return true si un objet de ce calque est selection par le point. */ public boolean changeSelection(final GrPoint _pt, final int _tolerancePixel, final int _action) { + if (!isSelectable()) return false; + final CtuluListSelection l = selection(_pt, _tolerancePixel); changeSelection(l, _action); if ((l == null) || (l.isEmpty())) { @@ -134,6 +136,8 @@ * @return true si des objets ont ete selectionnes par le polygone */ public boolean changeSelection(final LinearRing _poly, final int _action, final int _mode) { + if (!isSelectable()) return false; + final CtuluListSelection l = selection(_poly, _mode); changeSelection(l, _action); if ((l == null) || (l.isEmpty())) { @@ -143,6 +147,8 @@ } public boolean changeSelection(final LinearRing[] _p, final int _action, final int _mode) { + if (!isSelectable()) return false; + if (_p == null) { return false; } @@ -159,6 +165,8 @@ } public void clearSelection() { + if (!isSelectable()) return; + if ((selection_ != null) && (!selection_.isEmpty())) { selection_.clear(); fireSelectionEvent(); @@ -181,6 +189,8 @@ } public void inverseSelection() { + if (!isSelectable()) return; + if (isSelectionEmpty()) { return; } @@ -208,7 +218,7 @@ } public void selectAll() { - if (!isVisible()) return; + if (!isVisible() || !isSelectable()) return; initSelection(); selection_.addInterval(0, modeleDonnees().getNombre() - 1); fireSelectionEvent(); @@ -239,6 +249,8 @@ * @return true si une selection a \xE9t\xE9 effectu\xE9e. */ public boolean setSelection(final int[] _idx) { + if (!isSelectable()) return false; + if (_idx == null) { return false; } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesAbstract.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesAbstract.java 2009-01-09 10:31:50 UTC (rev 4338) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesAbstract.java 2009-01-09 10:59:45 UTC (rev 4339) @@ -24,6 +24,7 @@ import org.fudaa.ebli.controle.BConfigurableComposite; import org.fudaa.ebli.controle.BConfigurableInterface; import org.fudaa.ebli.controle.BSelecteurAlpha; +import org.fudaa.ebli.controle.BSelecteurCheckBox; import org.fudaa.ebli.controle.BSelecteurIconModel; import org.fudaa.ebli.controle.BSelecteurLineModel; import org.fudaa.ebli.geometrie.GrBoite; @@ -40,7 +41,7 @@ /** * @author deniger - * @version $Id: ZCalqueAffichageDonneesAbstract.java,v 1.47.6.2 2008-05-13 12:10:36 bmarchan Exp $ + * @version $Id$ */ public abstract class ZCalqueAffichageDonneesAbstract extends BCalqueAffichage implements ZCalqueAffichageDonneesInterface { @@ -98,6 +99,9 @@ */ protected boolean isPaletteCouleurUsed_; protected boolean painted_ = true; + + /** Les objets du calques sont-ils selectionnables */ + protected boolean isSelectable_=true; protected BPalettePlageAbstract paletteCouleur_; @@ -111,6 +115,25 @@ public boolean isEditable() { return modeleDonnees() != null && modeleDonnees().getNombre() > 0; } + + public boolean isSelectable() { + return isSelectable_; + } + + /** + * Definit si les objets du calque sont selectionnables. + */ + public void setSelectable(boolean _b) { + if (isSelectable() != _b) { + if (!_b) clearSelection(); + isSelectable_= _b; + firePropertyChange("selectable", !_b, _b); + } + } + + public boolean canSetSelectable() { + return false; + } public void paintAllInImage(final Graphics2D _g, final GrMorphisme _versEcran, final GrMorphisme _versReel, final GrBoite _clipReel) { Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesAbstract.java ___________________________________________________________________ Added: svn:keywords + Id Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesInterface.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesInterface.java 2009-01-09 10:31:50 UTC (rev 4338) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesInterface.java 2009-01-09 10:59:45 UTC (rev 4339) @@ -75,6 +75,18 @@ boolean isEditable(); /** + * Definit si les objets du calque sont ou non selectionnables. + * @return true : Les objets sont selectionnables. + */ + boolean isSelectable(); + + /** + * Definit si l'utilisateur peut changer le caract\xE8re s\xE9lectionnable/non depuis l'action "Selectionnable". + * @return true : Si le calque peut \xEAtre rendu selectionnable + */ + public boolean canSetSelectable(); + + /** * @return la boite zoomant sur la selection. Cette boite est la boite englobante * augment\xE9e d'une marge. */ Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java 2009-01-09 10:31:50 UTC (rev 4338) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java 2009-01-09 10:59:45 UTC (rev 4339) @@ -195,6 +195,8 @@ } public boolean changeSelection(final GrPoint _pt, final int _tolerancePixel, final int _action) { + if (!isSelectable()) return false; + if (isAtomicMode_) { final EbliListeSelectionMulti l = selectionMulti(_pt, _tolerancePixel); changeSelectionMulti(l, _action); @@ -207,6 +209,8 @@ } public boolean changeSelection(final LinearRing _poly, final int _action, final int _mode) { + if (!isSelectable()) return false; + if (isAtomicMode_) { final EbliListeSelectionMulti l = selectionMulti(_poly); changeSelectionMulti(l, _action); @@ -248,6 +252,8 @@ } public void clearSelection() { + if (!isSelectable()) return; + // dans le mode edition de noeuds if (isAtomicMode_) { if (selectionMulti_ != null && !selectionMulti_.isEmpty()) { @@ -367,6 +373,8 @@ } public void inverseSelection() { + if (!isSelectable()) return; + if (isSelectionEmpty()) { return; } @@ -656,7 +664,7 @@ } public void selectAll() { - if (!isVisible()) return; + if (!isVisible() || !isSelectable()) return; if (!isAtomicMode_) { initSelection(); @@ -877,6 +885,8 @@ } public boolean setSelection(final int[] _idx) { + if (!isSelectable()) return false; + // Aucun controle n'est fait sur la visibilit\xE9 ou non des objets d'indices pass\xE9s. if (!isAtomicMode_) { return super.setSelection(_idx); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java 2009-01-09 10:31:50 UTC (rev 4338) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java 2009-01-09 10:59:45 UTC (rev 4339) @@ -223,6 +223,8 @@ } public boolean changeSelection(final GrPoint _pt, final int _tolerancePixel, final int _action) { + if (!isSelectable()) return false; + if (isAtomicMode_) { final EbliListeSelectionMulti l = selectionMulti(_pt, _tolerancePixel); changeSelectionMulti(l, _action); @@ -235,6 +237,8 @@ } public boolean changeSelection(final LinearRing _poly, final int _action, final int _mode) { + if (!isSelectable()) return false; + if (isAtomicMode_) { final EbliListeSelectionMulti l = selectionMulti(_poly); changeSelectionMulti(l, _action); @@ -276,6 +280,8 @@ } public void clearSelection() { + if (!isSelectable()) return; + // dans le mode edition de noeuds if (isAtomicMode_) { if (selectionMulti_ != null && !selectionMulti_.isEmpty()) { @@ -436,28 +442,9 @@ } } - public void inverseSelectedSelection() { - if (!isAtomicMode_) { - super.inverseSelection(); - return; - } - if (isSelectionEmpty()) { - return; - } - for (int i = modele_.getNombre() - 1; i >= 0; i--) { - CtuluListSelection s = selectionMulti_.get(i); - if (s == null) { - s = new CtuluListSelection(); - s.setSelectionInterval(0, modele_.getNbPointForGeometry(i) - 1); - selectionMulti_.set(i, s); - } else { - s.inverse(modele_.getNbPointForGeometry(i)); - } - } - fireSelectionEvent(); - } - public void inverseSelection() { + if (!isSelectable()) return; + if (!isAtomicMode_) { // super.inverseSelection(); if (isSelectionEmpty()) { @@ -750,7 +737,7 @@ } public void selectAll() { - if (!isVisible()) return; + if (!isVisible() || !isSelectable()) return; if (!isAtomicMode_) { // super.selectAll(); @@ -995,6 +982,8 @@ } public boolean setSelection(final int[] _idx) { + if (!isSelectable()) return false; + // Aucun controle n'est fait sur la visibilit\xE9 ou non des objets d'indices pass\xE9s. if (!isAtomicMode_) { return super.setSelection(_idx); Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/ressource/non-selectionnable.png =================================================================== (Binary files differ) Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/ressource/non-selectionnable.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Id Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dLine.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dLine.java 2009-01-09 10:31:50 UTC (rev 4338) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dLine.java 2009-01-09 10:59:45 UTC (rev 4339) @@ -54,4 +54,8 @@ super.setActions(acts); } + + public boolean canSetSelectable() { + return true; + } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dMultiPoint.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dMultiPoint.java 2009-01-09 10:31:50 UTC (rev 4338) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dMultiPoint.java 2009-01-09 10:59:45 UTC (rev 4339) @@ -53,4 +53,8 @@ super.setActions(acts); } + + public boolean canSetSelectable() { + return true; + } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueBief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueBief.java 2009-01-09 10:31:50 UTC (rev 4338) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueBief.java 2009-01-09 10:59:45 UTC (rev 4339) @@ -70,14 +70,17 @@ BGroupeCalque groupeCalque=new BGroupeCalque(); // Ajout du calque d'axe hydraulique MdlLayer1dAxe axeHydraulique=new MdlLayer1dAxe((FSigEditor)gisEditor_); + axeHydraulique.setSelectable(false); axeHydraulique.modele(bief.axeHydraulique_); groupeCalque.add(axeHydraulique); // Ajout du calque de lignes directrices MdlLayer2dDirectionLine lignesDirectrices=new MdlLayer2dDirectionLine((FSigEditor)gisEditor_); + lignesDirectrices.setSelectable(false); lignesDirectrices.modele(bief.lignesDirectrices_); groupeCalque.add(lignesDirectrices); // Ajout du calque de limites de stockage MdlLayer2dConstraintLine limitesStockage=new MdlLayer2dConstraintLine((FSigEditor)gisEditor_); + limitesStockage.setSelectable(false); limitesStockage.modele(bief.limitesStockages_); groupeCalque.add(limitesStockage); // Ajout du calque de profils @@ -86,6 +89,7 @@ groupeCalque.add(profils); // Ajout du calque de rives MdlLayer1dBank rives=new MdlLayer1dBank((FSigEditor)gisEditor_); + rives.setSelectable(false); rives.modele(bief.rives_); groupeCalque.add(rives); // Fin This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bma...@us...> - 2009-01-12 11:25:38
|
Revision: 4343 http://fudaa.svn.sourceforge.net/fudaa/?rev=4343&view=rev Author: bmarchan Date: 2009-01-12 11:25:30 +0000 (Mon, 12 Jan 2009) Log Message: ----------- Chgt de version 0.09 => 0.10 Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesInterface.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlImplementation.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesInterface.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesInterface.java 2009-01-09 15:13:24 UTC (rev 4342) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesInterface.java 2009-01-12 11:25:30 UTC (rev 4343) @@ -75,7 +75,8 @@ boolean isEditable(); /** - * Definit si les objets du calque sont ou non selectionnables. + * Definit si les objets du calque sont ou non selectionnables. Si la valeur retourn\xE9e est false, les + * m\xE9thodes de s\xE9lection de l'interface n'ont aucun effet. * @return true : Les objets sont selectionnables. */ boolean isSelectable(); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlImplementation.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlImplementation.java 2009-01-09 15:13:24 UTC (rev 4342) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlImplementation.java 2009-01-12 11:25:30 UTC (rev 4343) @@ -81,9 +81,9 @@ protected static BuInformationsSoftware isMdl_ = new BuInformationsSoftware(); static { isMdl_.name = "Modeleur"; - isMdl_.version = "0.09"; - isMdl_.date = "2008-12-22"; - isMdl_.rights = "Tous droits r\xE9serv\xE9s. CETMEF (c)1999-2008"; + isMdl_.version = "0.10"; + isMdl_.date = "2009-01-12"; + isMdl_.rights = "Tous droits r\xE9serv\xE9s. CETMEF (c)1999-2009"; isMdl_.license = "GPL2"; isMdl_.languages = "fr,en"; isMdl_.authors=new String[]{"F.Deniger, B.Marchand"}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2009-01-16 13:36:20
|
Revision: 4378 http://fudaa.svn.sourceforge.net/fudaa/?rev=4378&view=rev Author: emmanuel_martin Date: 2009-01-16 13:36:14 +0000 (Fri, 16 Jan 2009) Log Message: ----------- Tache #146 : "Edition de bief : Ajouter la visualisation des lignes directrices" Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGCourbe.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGCourbeModelDefault.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGCourbeModelProfile.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGModel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeDefautModel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeTimeModel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MVProfileCourbeModel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MvProfileCoordinatesModel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainer.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueCourbe.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrTelemacBoundaryCourbeModel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrTelemacWeirCourbeModel.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -312,4 +312,16 @@ return "ATTRIBUTE_INTERSECTION_LIMITE_STOCKAGE_DROITE"; } }; + + /** + * Attribut contenant l'index des points correspondants aux l'intersections entre + * les lignes directrices et un profil. Ces index sont stock\xE9s dans une List<Integer>. + */ + public final static GISAttribute INTERSECTIONS_LIGNES_DIRECTRICES=new GISAttribute(null, CtuluLib + .getS("Intersections lignes directrices"), false){ + @Override + public String getID() { + return "ATTRIBUTE_INTERSECTIONS_LIGNES_DIRECTRICES"; + } + }; } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGCourbe.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGCourbe.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGCourbe.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -413,15 +413,39 @@ xiVisible = _t.getXAxe().containsPoint(xi); yiVisible = getAxeY().containsPoint(yi); - if (model_.isPointDrawn(i) && xiVisible && yiVisible && iconeModel_.getType() != TraceIcon.RIEN) { - if (displayTitleOnCurve_) { - if (rangeDisplayed == null) { - rangeDisplayed = new Envelope(); + if(model_.isPointDrawn(i) && xiVisible && yiVisible) { + // Paint point label + String pLabel=model_.getPointLabel(i); + if(pLabel!=null) { + // Dessin de la boite et du label + // X + int xBox; + if(((int) xie)==_t.getMinEcranX()) + xBox=((int) xie); + else if(((int) xie)==_t.getMaxEcranX()) + xBox=((int) xie)-_g.getFontMetrics().stringWidth(pLabel)-3; + else + xBox=((int) xie)-_g.getFontMetrics().stringWidth(pLabel)/2-2; + // Y + int yBox; + if(((int) yie)==_t.getMaxEcranY()) + yBox=((int) yie)-10; + else + yBox=((int) yie)+10; + // Paint + tbox_.paintBox(_g, xBox, yBox, pLabel); + } + // Paint point + if(iconeModel_.getType() != TraceIcon.RIEN) { + if (displayTitleOnCurve_) { + if (rangeDisplayed == null) { + rangeDisplayed = new Envelope(); + } + rangeDisplayed.expandToInclude(xi, yi); } - rangeDisplayed.expandToInclude(xi, yi); + // icone_.couleur(getAspectContour()); + trIcon.paintIconCentre(_g, xie, yie); } - // icone_.couleur(getAspectContour()); - trIcon.paintIconCentre(_g, xie, yie); } if ((i > 0) && model_.isSegmentDrawn(i - 1) && (xpVisible || xiVisible || _t.getXAxe().isContained(xpe, xie))) { if (displayTitleOnCurve_) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGCourbeModelDefault.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGCourbeModelDefault.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGCourbeModelDefault.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -113,6 +113,10 @@ return 0; } + public String getPointLabel(int _i) { + return null; + } + public int getNbValues() { return x_.length; } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGCourbeModelProfile.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGCourbeModelProfile.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGCourbeModelProfile.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -72,6 +72,10 @@ return name_; } + public String getPointLabel(int _i) { + return null; + } + /* (non-Javadoc) * @see org.fudaa.ebli.courbe.EGModel#getX(int) */ Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGModel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGModel.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/courbe/EGModel.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -47,6 +47,14 @@ boolean isPointDrawn(int _i); /** + * @param _i + * l'indice du point compris entre 0 et getNbPoint()-1 + * @return le text \xE0 afficher concernant le point correspondant \xE0 _i. Null si + * il n'y en a pas. + */ + String getPointLabel(int _i); + + /** * @param _idx l'indice voulu * @return la valeur de x en ce point */ Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeDefautModel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeDefautModel.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeDefautModel.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -87,6 +87,10 @@ return false; } + public String getPointLabel(int _i) { + return null; + } + public int getNbValues() { return e_.getNbValues(); } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeTimeModel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeTimeModel.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeTimeModel.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -78,6 +78,10 @@ return false; } + public String getPointLabel(int _i) { + return null; + } + public int getNbValues() { if (y_ == null) { return 0; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MVProfileCourbeModel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MVProfileCourbeModel.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MVProfileCourbeModel.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -116,6 +116,10 @@ return 0; } + public String getPointLabel(int _i) { + return null; + } + public int getNbValues() { return res_.getNbIntersect(); } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MvProfileCoordinatesModel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MvProfileCoordinatesModel.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MvProfileCoordinatesModel.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -81,6 +81,10 @@ return false; } + public String getPointLabel(int _i) { + return null; + } + public int getNbValues() { return res_.getNbIntersect(); } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -127,6 +127,9 @@ int idxRg=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); if (idxRg==-1) attToAdd++; + int idxLd=zone.getIndiceOf(GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); + if(idxLd==-1) + attToAdd++; // Ajout des attributs manquant \\ if (attToAdd>0) { GISAttributeInterface[] atts=new GISAttributeInterface[zone.getNbAttributes()+attToAdd]; @@ -141,24 +144,28 @@ atts[k++]=GISAttributeConstants.INTERSECTION_RIVE_DROITE; if (idxRg==-1) atts[k++]=GISAttributeConstants.INTERSECTION_RIVE_GAUCHE; + if(idxLd==-1) + atts[k++]=GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES; zone.setAttributes(atts, null); } int idxAttRiveGauche=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); int idxAttRiveDroite=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); int idxAttlsGauche=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); int idxAttlsDroite=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); + int idxAttLignesDirectrices=zone.getIndiceOf(GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); if (axeHydraulique_.getNombre()==0) for (int i=0; i<profils_.getNombre(); i++) { profils_.getGeomData().setAttributValue(idxAttRiveGauche, i, null, null); profils_.getGeomData().setAttributValue(idxAttRiveDroite, i, null, null); profils_.getGeomData().setAttributValue(idxAttlsGauche, i, null, null); profils_.getGeomData().setAttributValue(idxAttlsDroite, i, null, null); + profils_.getGeomData().setAttributValue(idxAttLignesDirectrices, i, new ArrayList<Integer>(0), null); } if (axeHydraulique_.getNombre()==1) { Geometry axeHydraulique=(Geometry)axeHydraulique_.getObject(0); CoordinateSequence seqAxeHydraulique=((GISCoordinateSequenceContainerInterface)axeHydraulique).getCoordinateSequence(); orderProfils(-1, null); - // Construction des rives et limites de stockages \\ + // Normalise le sens du profil \\ for (int k=0; k<profils_.getNombre(); k++) { Geometry profil=zone.getGeometry(k); CoordinateSequence seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); @@ -187,7 +194,9 @@ profil=(Geometry)profils_.getGeomData().getGeometry(k); seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); } - double abscisseCurvIntersectionAxe=UtilsProfil1d.abscisseCurviligne(seqProfil, interAxeProfil); + } + // Cr\xE9ation des nouveaux points sur les profils \\ + for (int k=0; k<profils_.getNombre(); k++) { // Ajout des points au profil si n\xE9c\xE9ssaire pour les intersections \\ // Rives for (int l=0; l<rives_.getNombre(); l++) @@ -195,8 +204,16 @@ // Limites de stockages for (int l=0; l<limitesStockages_.getNombre(); l++) createPointIfNeeded(k, (GISPolyligne) limitesStockages_.getObject(l)); - profil=(Geometry)profils_.getGeomData().getGeometry(k); - seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); + // Lignes directrices + for (int l=0; l<lignesDirectrices_.getNombre(); l++) + createPointIfNeeded(k, (GISPolyligne) lignesDirectrices_.getObject(l)); + } + // Valuation des attributs simple d'intersection (rives et limites) \\ + for(int k=0;k<profils_.getNombre();k++) { + Geometry profil=zone.getGeometry(k); + CoordinateSequence seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); + Coordinate interAxeProfil=profil.intersection(axeHydraulique).getCoordinate(); + double abscisseCurvIntersectionAxe=UtilsProfil1d.abscisseCurviligne(seqProfil, interAxeProfil); // Valuation des attributs avec les index des points des intersections \\ // Rives zone.setAttributValue(idxAttRiveGauche, k, 0, null); @@ -210,6 +227,9 @@ for (int l=0; l<limitesStockages_.getNombre(); l++) valuateProfilIntersection(k, (Geometry) limitesStockages_.getObject(l), idxAttlsGauche, idxAttlsDroite, abscisseCurvIntersectionAxe); } + // Valuation des attributs composites d'intersection (lignes directrices) \\ + // Lignes directrices \\ + valuateProfilIntersection(idxAttLignesDirectrices); } // Activation du synchroniser gisSynchroniser_.enable(); @@ -259,6 +279,79 @@ profils_.getGeomData().setAttributValue(_idxAttrGauche, _idxProfil, idxIntersection, null); } } + + /** + * Valuation des attributs composites des profils, c'est \xE0 dire des attributs contenant plusieurs + * informations d'intersection sous forme d'une liste. + * + * @param _idxAttr l'index de l'attribut o\xF9 sera stock\xE9 les intersections + */ + @SuppressWarnings("unchecked") + private void valuateProfilIntersection(int _idxAttr) { + // Cr\xE9ation des listes + for (int k=0; k<profils_.getNombre(); k++) + profils_.getGeomData().setAttributValue(_idxAttr, k, new ArrayList<Integer>(), null); + // Valuation de l'attribut + int k=0; + int[] lstIntersectionTmp=new int[profils_.getNombre()]; + while (k<lignesDirectrices_.getNombre()) { + Geometry ligneD=(Geometry)lignesDirectrices_.getObject(k); + // Recherche des croisements avec les profils + for (int l=0; l<profils_.getNombre(); l++) { + Geometry profil=profils_.getGeomData().getGeometry(l); + CoordinateSequence seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); + Geometry inter=((Geometry)profils_.getObject(l)).intersection(ligneD); + if (inter.getNumPoints()==0) + lstIntersectionTmp[l]=-1; + else + lstIntersectionTmp[l]=UtilsProfil1d.getIndex(seqProfil, inter.getCoordinate()); + } + // Test si au moins un croisement existe + boolean ok=false; + int m=-1; + while (!ok&&++m<lstIntersectionTmp.length) + ok=lstIntersectionTmp[m]!=-1; + if (!ok) + // Suppression de la ligne directrice qui est inutile et pas + // incr\xE9mentation de k + lignesDirectrices_.getGeomData().removeGeometries(new int[]{k}, null); + else { + for (int l=0; l<profils_.getNombre(); l++) { + // R\xE9cup\xE9ration de la liste contenant les index + List<Integer> lst=(List<Integer>)profils_.getGeomData().getValue(_idxAttr, l); + if (lstIntersectionTmp[l]!=-1) + // Enregistrement de l'index + lst.add(lstIntersectionTmp[l]); + else { + // Place le permier ou le dernier index \\ + // Recherche d'un point avant + int idxTest=l; + while (idxTest>=0&&lstIntersectionTmp[idxTest]==-1) + idxTest--; + if (idxTest<0) { + // Recherche d'un point apr\xE8s + idxTest=l; + while (idxTest<lstIntersectionTmp.length&&lstIntersectionTmp[idxTest]==-1) + idxTest++; + } + // Extraction d'informations sur le profils et l'axe hydraulique + Geometry profil=profils_.getGeomData().getGeometry(idxTest); + CoordinateSequence seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); + Coordinate intersection=profil.intersection((Geometry)axeHydraulique_.getObject(0)).getCoordinate(); + int idxAxe=UtilsProfil1d.getPreviousIndex(seqProfil, intersection); + if (idxAxe==-1) + idxAxe=0; + // Enregistrement de l'index + if (lstIntersectionTmp[idxTest]<=idxAxe) + lst.add(0); + else + lst.add(profils_.getGeomData().getCoordinateSequence(l).size()-1); + } + } + k++; + } + } + } /** * Cr\xE9e un point \xE0 l'intersection du profil indiqu\xE9 par _idxProfil et de @@ -456,12 +549,12 @@ private int idxRiveDroite_=-1; private int idxLimiteStockageGauche_=-1; private int idxLimiteStockageDroite_=-1; - private List<Integer> idxLignesDirectrices_=new ArrayList<Integer>(); // Les index des attributs \\ private int idxAttRiveGauche_=-1; private int idxAttRiveDroite_=-1; private int idxAttlsGauche_=-1; private int idxAttlsDroite_=-1; + private int idxAttlignesDirectrices_=-1; /** * Active/met \xE0 jour le synchroniser. @@ -479,6 +572,7 @@ idxAttRiveDroite_=profilsListen_.getGeomData().getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); idxAttlsGauche_=profilsListen_.getGeomData().getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); idxAttlsDroite_=profilsListen_.getGeomData().getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); + idxAttlignesDirectrices_=profilsListen_.getGeomData().getIndiceOf(GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); // D\xE9termination des index de g\xE9om\xE9tries // Rives if(rivesModified_.getNombre()>0) { @@ -557,11 +651,11 @@ idxRiveDroite_=-1; idxLimiteStockageGauche_=-1; idxLimiteStockageDroite_=-1; - idxLignesDirectrices_.clear(); idxAttRiveGauche_=-1; idxAttRiveDroite_=-1; idxAttlsGauche_=-1; idxAttlsDroite_=-1; + idxAttlignesDirectrices_=-1; } } @@ -593,13 +687,10 @@ idxLimiteStockageGauche_=-1; idxLimiteStockageDroite_=-1; // Lignes directrices - if (idxLignesDirectrices_.size()>0) { - int[] idxLD=new int[idxLignesDirectrices_.size()]; - for (int i=0; i<idxLignesDirectrices_.size(); i++) - idxLD[i]=idxLignesDirectrices_.get(i); - lignesDirectricesModified_.getGeomData().removeGeometries(idxLD, null); - idxLignesDirectrices_.clear(); - } + int[] idx=new int[lignesDirectricesModified_.getNombre()]; + for(int i=0;i<idx.length;i++) + idx[i]=i; + lignesDirectricesModified_.getGeomData().removeGeometries(idx, null); } /** @@ -620,6 +711,8 @@ updateGeom(_idxGeom, limitesStockagsesModified_, idxLimiteStockageGauche_, idxAttlsGauche_); else if(_att==GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE) updateGeom(_idxGeom, limitesStockagsesModified_, idxLimiteStockageDroite_, idxAttlsDroite_); + else if(_att==GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES) + updateLd(_idxGeom); } public void geometryAction(Object _source, int _idxGeom, Geometry _geom, int _action) { @@ -628,12 +721,14 @@ updateGeom(_idxGeom, rivesModified_, idxRiveDroite_, idxAttRiveDroite_); updateGeom(_idxGeom, limitesStockagsesModified_, idxLimiteStockageGauche_, idxAttlsGauche_); updateGeom(_idxGeom, limitesStockagsesModified_, idxLimiteStockageDroite_, idxAttlsDroite_); + updateLd(_idxGeom); } } /** * R\xE9g\xE9n\xE8re toutes les g\xE9om\xE9tries volatiles. */ + @SuppressWarnings("unchecked") private void regenerateAll() { GISZoneCollection zone=profilsListen_.getGeomData(); // Cr\xE9ation des nouvelles g\xE9om\xE9tries \\ @@ -651,19 +746,35 @@ lsGauche[i]=zone.getCoordinateSequence(i).getCoordinate((Integer)zone.getValue(idxAttlsGauche_, i)); lsDroite[i]=zone.getCoordinateSequence(i).getCoordinate((Integer)zone.getValue(idxAttlsDroite_, i)); } + // Lignes directrices + Coordinate[][] ld=new Coordinate[lignesDirectricesModified_.getNombre()][]; + for(int i=0; i<ld.length; i++) + ld[i]=new Coordinate[profilsListen_.getNombre()]; + for(int i=0; i<profilsListen_.getNombre(); i++) { + List<Integer> lst=(List<Integer>) profilsListen_.getGeomData().getValue(idxAttlignesDirectrices_, i); + for(int j=0; j<lignesDirectricesModified_.getNombre(); j++) + ld[j][i]=profilsListen_.getGeomData().getCoordinateSequence(i).getCoordinate(lst.get(j)); + } + // Ajout des nouvelles g\xE9o\xE9mtries \\ // Extraction des anciennes donn\xE9es Object[] dataRiveGauche=getData(idxRiveGauche_, rivesModified_.getGeomData()); Object[] dataRiveDroite=getData(idxRiveDroite_, rivesModified_.getGeomData()); Object[] dataLsGauche=getData(idxLimiteStockageGauche_, rivesModified_.getGeomData()); Object[] dataLsDroite=getData(idxLimiteStockageDroite_, rivesModified_.getGeomData()); + Object[][] dataLignesDirectrices=new Object[lignesDirectricesModified_.getNombre()][]; + for(int i=0;i<lignesDirectricesModified_.getNombre();i++) + dataLignesDirectrices[i]=getData(i, lignesDirectricesModified_.getGeomData()); // Destruction des g\xE9om\xE9tries destroyGeometries(); - // Ajout des geometries + // Ajout des geometries \\ + // Rives if (riveGauche.length>1&&riveGauche[0]!=null&&rivesModified_!=null) - idxRiveGauche_=rivesModified_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(riveGauche)), dataRiveGauche, null); + idxRiveGauche_=rivesModified_.getGeomData().addGeometry( + new GISPolyligne(new GISCoordinateSequenceFactory().create(riveGauche)), dataRiveGauche, null); if (riveDroite.length>1&&riveDroite[0]!=null&&rivesModified_!=null) - idxRiveDroite_=rivesModified_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(riveDroite)), dataRiveDroite, null); + idxRiveDroite_=rivesModified_.getGeomData().addGeometry( + new GISPolyligne(new GISCoordinateSequenceFactory().create(riveDroite)), dataRiveDroite, null); // Limites de stockages if (lsGauche.length>1&&lsGauche[0]!=null&&limitesStockagsesModified_!=null) idxLimiteStockageGauche_=limitesStockagsesModified_.getGeomData().addGeometry( @@ -671,6 +782,10 @@ if (lsDroite.length>1&&lsDroite[0]!=null&&limitesStockagsesModified_!=null) idxLimiteStockageDroite_=limitesStockagsesModified_.getGeomData().addGeometry( new GISPolyligne(new GISCoordinateSequenceFactory().create(lsDroite)), dataLsDroite, null); + // Lignes directrices + for (int i=0; i<ld.length; i++) + lignesDirectricesModified_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(ld[i])), + dataLignesDirectrices[i], null); } /** @@ -705,6 +820,32 @@ _model.getGeomData().setCoordinateSequence(_idxGeomVolatile, seqGeomV, null); } } + + /** + * Met \xE0 jours les lignes directrices. + * @param _idxPoint indique l'index du point ayant chang\xE9 + */ + @SuppressWarnings("unchecked") + private void updateLd(int _idxGeom) { + if(_idxGeom==-1) + return; + List<Integer> lstIdx=(List<Integer>)profilsListen_.getGeomData().getValue(idxAttlignesDirectrices_, _idxGeom); + CoordinateSequence seqProfil=profilsListen_.getGeomData().getCoordinateSequence(_idxGeom); + boolean found=false; + int i=-1; + while(!found&&++i<lignesDirectricesModified_.getNombre()) { + CoordinateSequence seqLd= lignesDirectricesModified_.getGeomData().getCoordinateSequence(i); + Coordinate coodProfil=seqProfil.getCoordinate(lstIdx.get(i)); + // Test si c'est bien cette ligne directrice \xE0 mettre \xE0 jour + if(!UtilsProfil1d.egal(coodProfil, seqLd.getCoordinate(_idxGeom))) { + found=true; + seqLd.setOrdinate(_idxGeom, 0, coodProfil.x); + seqLd.setOrdinate(_idxGeom, 1, coodProfil.y); + seqLd.setOrdinate(_idxGeom, 2, coodProfil.z); + lignesDirectricesModified_.getGeomData().setCoordinateSequence(i, seqLd, null); + } + } + } } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainer.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainer.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainer.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -59,6 +59,15 @@ /** Retourne l'abscisse curviligne de l'axe sur le profil (ne pas confondre avec getAbsCurvProfilOnAxeHydraulique). -1 si inexistant. */ public double getAbsCurvAxeHydrauliqueOnProfil(); + /** Retourne les index des lignes directrices croisant le profil. null si aucun profil n'est selectionn\xE9. */ + public int[] getIdxLignesDirectrices(); + + /** Retourne les noms des lignes directrices. null si aucun profil n'est s\xE9lectionn\xE9 ou si il n'y a pas de noms.*/ + public String[] getNamesLignesDirectrices(); + + /** Retourneles noms des lignes directrices associ\xE9s \xE0 l'index pass\xE9 en param\xE8tre. null si aucun. */ + public String[] getNamesLignesDirectricesAt(int _idxPoint); + /** * Enregistre l'abcisse curviligne du point indiqu\xE9 en param\xE8tre. * Ce changement d'abscisse curviligne fonctionne sur tout les points. Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -328,11 +328,11 @@ } /** - * Retourne la valeur de l'attribut d'intersection demand\xE9. C'est donc un index de point qui est renvoy\xE9. + * Retourne la valeur de l'attribut d'intersection demand\xE9. */ - private int getValueOf(GISAttributeInterface attr_) { + private Object getValueOf(GISAttributeInterface attr_) { int idxAtt=biefContainer_.getZoneProfils().getIndiceOf(attr_); - return (Integer) biefContainer_.getZoneProfils().getValue(idxAtt, idxProfilSelected_); + return biefContainer_.getZoneProfils().getValue(idxAtt, idxProfilSelected_); } private CoordinateSequence getCoordSeq() { @@ -341,36 +341,79 @@ } public double getAbsCurvRiveGauche() { - if(idxProfilSelected_==-1) + if (idxProfilSelected_==-1) return -1; - return getCurv(getValueOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE)); + return getCurv((Integer)getValueOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE)); } - + public double getAbsCurvRiveDroite() { - if(idxProfilSelected_==-1) + if (idxProfilSelected_==-1) return -1; - return getCurv(getValueOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE)); + return getCurv((Integer)getValueOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE)); } - + public double getAbsCurvLimiteStockageGauche() { - if(idxProfilSelected_==-1) + if (idxProfilSelected_==-1) return -1; - return getCurv(getValueOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE)); + return getCurv((Integer)getValueOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE)); } public double getAbsCurvLimiteStockageDroite() { - if(idxProfilSelected_==-1) + if (idxProfilSelected_==-1) return -1; - return getCurv(getValueOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE)); + return getCurv((Integer)getValueOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE)); } - + public double getAbsCurvProfilOnAxeHydraulique() { - if(idxProfilSelected_==-1||biefContainer_.getZoneAxeHydraulique().getNbGeometries()==0) + if (idxProfilSelected_==-1||biefContainer_.getZoneAxeHydraulique().getNbGeometries()==0) return -1; - return UtilsProfil1d.abscisseCurviligne(((GISCoordinateSequenceContainerInterface)biefContainer_.getZoneAxeHydraulique().getGeometry(0)) - .getCoordinateSequence(), getCoordSeq()); + return UtilsProfil1d.abscisseCurviligne(((GISCoordinateSequenceContainerInterface)biefContainer_.getZoneAxeHydraulique() + .getGeometry(0)).getCoordinateSequence(), getCoordSeq()); } + @SuppressWarnings("unchecked") + public int[] getIdxLignesDirectrices() { + if (idxProfilSelected_==-1) + return null; + List<Integer> lst=(List<Integer>)getValueOf(GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); + int[] result=new int[lst.size()]; + for (int i=0; i<lst.size(); i++) + result[i]=lst.get(i); + return result; + } + + public String[] getNamesLignesDirectricesAt(int _idxPoint) { + if (idxProfilSelected_==-1||_idxPoint<0||_idxPoint>=getNbPoint()) + return null; + // Nom des lignes directrices + int[] idx=getIdxLignesDirectrices(); + String[] names=getNamesLignesDirectrices(); + if(idx==null||names==null) + return null; + // Construction du label par agr\xE9gation des noms des lignes directrices croisant le point + ArrayList<String> labels=new ArrayList<String>(); + for(int i=0;i<idx.length;i++) + if(idx[i]==_idxPoint) + labels.add(names[i]); + if(labels.size()==0) + return null; + else + return labels.toArray(new String[0]); + } + + public String[] getNamesLignesDirectrices() { + if (idxProfilSelected_==-1) + return null; + GISZoneCollection zoneLd=biefContainer_.getZoneLignesDirectrices(); + int idxTitre=zoneLd.getIndiceOf(GISAttributeConstants.TITRE); + if(idxTitre==-1) + return null; + String[] result=new String[zoneLd.getNbGeometries()]; + for(int i=0; i<result.length;i++) + result[i]=(String) zoneLd.getValue(idxTitre, i); + return result; + } + public double getAbsCurvAxeHydrauliqueOnProfil() { if(idxProfilSelected_==-1||biefContainer_.getZoneAxeHydraulique().getNbGeometries()==0) return -1; @@ -382,7 +425,7 @@ } public void setLimiteGauche(int _idx, CtuluCommandContainer _cmd) { - int idxRiveGauche=getValueOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); + int idxRiveGauche=(Integer) getValueOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); if(_idx<=idxRiveGauche) setIndexIn(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE, _idx, _cmd); else @@ -390,7 +433,7 @@ } public void setLimiteDroite(int _idx, CtuluCommandContainer _cmd) { - int idxRiveDroite=getValueOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); + int idxRiveDroite=(Integer) getValueOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); if(_idx>=idxRiveDroite) setIndexIn(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE, _idx, _cmd); else @@ -398,8 +441,8 @@ } public void setRiveGauche(int _idx, CtuluCommandContainer _cmd) { - int idxLimiteGauche=getValueOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); - int idxRiveDroite=getValueOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); + int idxLimiteGauche=(Integer) getValueOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); + int idxRiveDroite=(Integer) getValueOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); if(_idx>=idxLimiteGauche&&_idx<idxRiveDroite) setIndexIn(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE, _idx, _cmd); else @@ -407,8 +450,8 @@ } public void setRiveDroite(int _idx, CtuluCommandContainer _cmd) { - int idxLimiteDroite=getValueOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); - int idxRiveGauche=getValueOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); + int idxLimiteDroite=(Integer) getValueOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); + int idxRiveGauche=(Integer) getValueOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); if(_idx<=idxLimiteDroite&&_idx>idxRiveGauche) setIndexIn(GISAttributeConstants.INTERSECTION_RIVE_DROITE, _idx, _cmd); else Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueCourbe.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueCourbe.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueCourbe.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -216,6 +216,17 @@ public void fillWithInfo(InfoData _table, CtuluListSelectionInterface pt) { } + public String getPointLabel(int _i) { + String[] names=data_.getNamesLignesDirectricesAt(_i); + if(names==null) + return null; + // Construction du label par agr\xE9gation des noms + String label=""; + for(int i=0;i<names.length;i++) + label+=names[i]; + return label; + } + public int getNbValues() { return data_.getNbPoint(); } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrTelemacBoundaryCourbeModel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrTelemacBoundaryCourbeModel.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrTelemacBoundaryCourbeModel.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -136,6 +136,10 @@ return 0; } + public String getPointLabel(int _i) { + return null; + } + public int getNbValues() { if (t_ == null) { return 0; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrTelemacWeirCourbeModel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrTelemacWeirCourbeModel.java 2009-01-16 08:31:00 UTC (rev 4377) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrTelemacWeirCourbeModel.java 2009-01-16 13:36:14 UTC (rev 4378) @@ -71,6 +71,10 @@ return 0; } + public String getPointLabel(int _i) { + return null; + } + public int getNbValues() { return s_.getNbPoint(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2009-01-19 15:49:23
|
Revision: 4380 http://fudaa.svn.sourceforge.net/fudaa/?rev=4380&view=rev Author: emmanuel_martin Date: 2009-01-19 15:49:15 +0000 (Mon, 19 Jan 2009) Log Message: ----------- tache #147 : "Edition de bief : Ajouter la modification des lignes directrices". Il y a un bug ?\195?\160 corriger lors du d?\195?\169placement de deux lignes directrices se coupant au m?\195?\170me endroit. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainer.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueCourbe.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-01-16 18:56:21 UTC (rev 4379) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-01-19 15:49:15 UTC (rev 4380) @@ -315,7 +315,7 @@ /** * Attribut contenant l'index des points correspondants aux l'intersections entre - * les lignes directrices et un profil. Ces index sont stock\xE9s dans une List<Integer>. + * les lignes directrices et un profil. Ces index sont stock\xE9s dans une {@link GISAttributeModelIntegerList}. */ public final static GISAttribute INTERSECTIONS_LIGNES_DIRECTRICES=new GISAttribute(null, CtuluLib .getS("Intersections lignes directrices"), false){ Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-01-16 18:56:21 UTC (rev 4379) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-01-19 15:49:15 UTC (rev 4380) @@ -7,10 +7,8 @@ */ package org.fudaa.fudaa.modeleur.modeleur1d.model; -import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; -import java.util.List; import org.fudaa.ctulu.CtuluCommand; import org.fudaa.ctulu.CtuluCommandComposite; @@ -19,6 +17,7 @@ import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ctulu.gis.GISAttributeInterface; import org.fudaa.ctulu.gis.GISAttributeModel; +import org.fudaa.ctulu.gis.GISAttributeModelIntegerList; import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; import org.fudaa.ctulu.gis.GISCoordinateSequenceFactory; import org.fudaa.ctulu.gis.GISPolyligne; @@ -159,7 +158,9 @@ profils_.getGeomData().setAttributValue(idxAttRiveDroite, i, null, null); profils_.getGeomData().setAttributValue(idxAttlsGauche, i, null, null); profils_.getGeomData().setAttributValue(idxAttlsDroite, i, null, null); - profils_.getGeomData().setAttributValue(idxAttLignesDirectrices, i, new ArrayList<Integer>(0), null); + GISAttributeModelIntegerList attrModel=new GISAttributeModelIntegerList(0, GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); + attrModel.setListener(profils_.getGeomData()); + profils_.getGeomData().setAttributValue(idxAttLignesDirectrices, i, attrModel, null); } if (axeHydraulique_.getNombre()==1) { Geometry axeHydraulique=(Geometry)axeHydraulique_.getObject(0); @@ -286,11 +287,13 @@ * * @param _idxAttr l'index de l'attribut o\xF9 sera stock\xE9 les intersections */ - @SuppressWarnings("unchecked") private void valuateProfilIntersection(int _idxAttr) { // Cr\xE9ation des listes - for (int k=0; k<profils_.getNombre(); k++) - profils_.getGeomData().setAttributValue(_idxAttr, k, new ArrayList<Integer>(), null); + for (int k=0; k<profils_.getNombre(); k++) { + GISAttributeModelIntegerList attrModel=new GISAttributeModelIntegerList(0, GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); + attrModel.setListener(profils_.getGeomData()); + profils_.getGeomData().setAttributValue(_idxAttr, k, attrModel, null); + } // Valuation de l'attribut int k=0; int[] lstIntersectionTmp=new int[profils_.getNombre()]; @@ -318,7 +321,7 @@ else { for (int l=0; l<profils_.getNombre(); l++) { // R\xE9cup\xE9ration de la liste contenant les index - List<Integer> lst=(List<Integer>)profils_.getGeomData().getValue(_idxAttr, l); + GISAttributeModelIntegerList lst=(GISAttributeModelIntegerList)profils_.getGeomData().getValue(_idxAttr, l); if (lstIntersectionTmp[l]!=-1) // Enregistrement de l'index lst.add(lstIntersectionTmp[l]); @@ -728,7 +731,6 @@ /** * R\xE9g\xE9n\xE8re toutes les g\xE9om\xE9tries volatiles. */ - @SuppressWarnings("unchecked") private void regenerateAll() { GISZoneCollection zone=profilsListen_.getGeomData(); // Cr\xE9ation des nouvelles g\xE9om\xE9tries \\ @@ -751,9 +753,9 @@ for(int i=0; i<ld.length; i++) ld[i]=new Coordinate[profilsListen_.getNombre()]; for(int i=0; i<profilsListen_.getNombre(); i++) { - List<Integer> lst=(List<Integer>) profilsListen_.getGeomData().getValue(idxAttlignesDirectrices_, i); + GISAttributeModelIntegerList lst=(GISAttributeModelIntegerList) profilsListen_.getGeomData().getValue(idxAttlignesDirectrices_, i); for(int j=0; j<lignesDirectricesModified_.getNombre(); j++) - ld[j][i]=profilsListen_.getGeomData().getCoordinateSequence(i).getCoordinate(lst.get(j)); + ld[j][i]=profilsListen_.getGeomData().getCoordinateSequence(i).getCoordinate(lst.getValue(j)); } // Ajout des nouvelles g\xE9o\xE9mtries \\ @@ -823,26 +825,22 @@ /** * Met \xE0 jours les lignes directrices. - * @param _idxPoint indique l'index du point ayant chang\xE9 + * @param _idxGeom indique la ligne directrice ayant chang\xE9. */ - @SuppressWarnings("unchecked") private void updateLd(int _idxGeom) { if(_idxGeom==-1) return; - List<Integer> lstIdx=(List<Integer>)profilsListen_.getGeomData().getValue(idxAttlignesDirectrices_, _idxGeom); - CoordinateSequence seqProfil=profilsListen_.getGeomData().getCoordinateSequence(_idxGeom); - boolean found=false; - int i=-1; - while(!found&&++i<lignesDirectricesModified_.getNombre()) { - CoordinateSequence seqLd= lignesDirectricesModified_.getGeomData().getCoordinateSequence(i); - Coordinate coodProfil=seqProfil.getCoordinate(lstIdx.get(i)); - // Test si c'est bien cette ligne directrice \xE0 mettre \xE0 jour - if(!UtilsProfil1d.egal(coodProfil, seqLd.getCoordinate(_idxGeom))) { - found=true; - seqLd.setOrdinate(_idxGeom, 0, coodProfil.x); - seqLd.setOrdinate(_idxGeom, 1, coodProfil.y); - seqLd.setOrdinate(_idxGeom, 2, coodProfil.z); - lignesDirectricesModified_.getGeomData().setCoordinateSequence(i, seqLd, null); + CoordinateSequence seqLd= lignesDirectricesModified_.getGeomData().getCoordinateSequence(_idxGeom); + for(int i=0;i<profilsListen_.getNombre();i++) { + GISAttributeModelIntegerList lstIdx=(GISAttributeModelIntegerList)profilsListen_.getGeomData().getValue(idxAttlignesDirectrices_, i); + CoordinateSequence seqProfil=profilsListen_.getGeomData().getCoordinateSequence(i); + Coordinate coodProfil=seqProfil.getCoordinate(lstIdx.getValue(_idxGeom)); + // Test si c'est bien un point \xE0 mettre \xE0 jour + if(!UtilsProfil1d.egal(coodProfil, seqLd.getCoordinate(i))) { + seqLd.setOrdinate(i, 0, coodProfil.x); + seqLd.setOrdinate(i, 1, coodProfil.y); + seqLd.setOrdinate(i, 2, coodProfil.z); + lignesDirectricesModified_.getGeomData().setCoordinateSequence(_idxGeom, seqLd, null); } } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainer.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainer.java 2009-01-16 18:56:21 UTC (rev 4379) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainer.java 2009-01-19 15:49:15 UTC (rev 4380) @@ -59,15 +59,6 @@ /** Retourne l'abscisse curviligne de l'axe sur le profil (ne pas confondre avec getAbsCurvProfilOnAxeHydraulique). -1 si inexistant. */ public double getAbsCurvAxeHydrauliqueOnProfil(); - /** Retourne les index des lignes directrices croisant le profil. null si aucun profil n'est selectionn\xE9. */ - public int[] getIdxLignesDirectrices(); - - /** Retourne les noms des lignes directrices. null si aucun profil n'est s\xE9lectionn\xE9 ou si il n'y a pas de noms.*/ - public String[] getNamesLignesDirectrices(); - - /** Retourneles noms des lignes directrices associ\xE9s \xE0 l'index pass\xE9 en param\xE8tre. null si aucun. */ - public String[] getNamesLignesDirectricesAt(int _idxPoint); - /** * Enregistre l'abcisse curviligne du point indiqu\xE9 en param\xE8tre. * Ce changement d'abscisse curviligne fonctionne sur tout les points. @@ -113,4 +104,27 @@ /** Place l'intersection du profil avec la rive droite \xE0 l'index _idx. */ public void setRiveDroite(int _idx, CtuluCommandContainer _cmd); + + + + /** Retourne le nombre de lignes directrices croisant le profil. */ + public int getNbLignesDirectrices(); + + /** Retourne les noms des lignes directrices. null si aucun profil n'est s\xE9lectionn\xE9 ou si il n'y a pas de noms.*/ + public String[] getNamesLignesDirectrices(); + + /** Retourne les index des lignes directrices associ\xE9s \xE0 l'index pass\xE9 en param\xE8tre. */ + public int[] getIdxLignesDirectricesAt(int _idxPoint); + + /** Retourne les noms des lignes directrices associ\xE9s \xE0 l'index pass\xE9 en param\xE8tre. */ + public String[] getNamesLignesDirectricesAt(int _idxPoint); + + /** Enregistre la ligne directrice _idxLd comme passant par le point _idxDestination. */ + public void setLigneDirectriceAt(int _idxLd, int _idxPoint, CtuluCommandContainer _cmd); + + /** Retourne le nom de la ligne directrice. */ + public String getLigneDirectriceName(int _idx); + + /** Retourne les index des lignes directrices pouvant \xEAtre d\xE9plac\xE9s au point indiqu\xE9.*/ + public int[] getAllowedMoveOfLignesDirectricesTo(int _idxPoint); } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java 2009-01-16 18:56:21 UTC (rev 4379) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java 2009-01-19 15:49:15 UTC (rev 4380) @@ -19,6 +19,7 @@ import org.fudaa.ctulu.collection.CtuluCollection; import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ctulu.gis.GISAttributeInterface; +import org.fudaa.ctulu.gis.GISAttributeModelIntegerList; import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; import org.fudaa.ctulu.gis.GISGeometryFactory; import org.fudaa.ctulu.gis.GISPolyligne; @@ -371,34 +372,84 @@ .getGeometry(0)).getCoordinateSequence(), getCoordSeq()); } - @SuppressWarnings("unchecked") - public int[] getIdxLignesDirectrices() { + public int getNbLignesDirectrices() { if (idxProfilSelected_==-1) + return 0; + return biefContainer_.getZoneLignesDirectrices().getNbGeometries(); + } + + public void setLigneDirectriceAt(int _idxLd, int _idxDestination, CtuluCommandContainer _cmd) { + int[] allowed=getAllowedMoveOfLignesDirectricesTo(_idxDestination); + if(allowed==null||!UtilsProfil1d.in(_idxLd, allowed)) + throw new IllegalArgumentException(FudaaLib.getS("Ce d\xE9placement n'est pas permis")); + GISAttributeModelIntegerList lst=(GISAttributeModelIntegerList)getValueOf(GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); + // Changement de la valeur + lst.set(_idxLd, _idxDestination, _cmd); + fireProfilContainerDataModified(); + } + + public String getLigneDirectriceName(int _idx) { + if (idxProfilSelected_==-1) return null; - List<Integer> lst=(List<Integer>)getValueOf(GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); - int[] result=new int[lst.size()]; - for (int i=0; i<lst.size(); i++) - result[i]=lst.get(i); + GISZoneCollection zoneLd=biefContainer_.getZoneLignesDirectrices(); + if(_idx<0||_idx>=zoneLd.getNumGeometries()) + return null; + int idxTitre=zoneLd.getIndiceOf(GISAttributeConstants.TITRE); + if(idxTitre==-1) + return null; + return (String) zoneLd.getValue(idxTitre, _idx); + } + + public int[] getAllowedMoveOfLignesDirectricesTo(int _idxPoint) { + if(idxProfilSelected_==-1||_idxPoint<0||_idxPoint>=getNbPoint()) + return null; + // Recherche des lignes avants et apr\xE8s. + int[] namesLdPrevious=new int[0]; + int idx=_idxPoint; + while (namesLdPrevious.length==0&&--idx>=0) + namesLdPrevious=getIdxLignesDirectricesAt(idx); + int[] namesLdNext=new int[0]; + idx=_idxPoint; + while(namesLdNext.length==0&&++idx<getNbPoint()) + namesLdNext=getIdxLignesDirectricesAt(idx); + // Agr\xE9gation des r\xE9sultats + int[] result=new int[namesLdPrevious.length+namesLdNext.length]; + System.arraycopy(namesLdPrevious, 0, result, 0, namesLdPrevious.length); + System.arraycopy(namesLdNext, 0, result, namesLdPrevious.length, namesLdNext.length); return result; } + public int[] getIdxLignesDirectricesAt(int _idxPoint) { + if (idxProfilSelected_==-1||_idxPoint<0||_idxPoint>=getNbPoint()) + return new int[0]; + // R\xE9cup\xE9ration des croisements entre les lignes directrices et le profil + GISZoneCollection zone=biefContainer_.getZoneProfils(); + int idxAtt=zone.getIndiceOf(GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); + GISAttributeModelIntegerList lst=(GISAttributeModelIntegerList) zone.getValue(idxAtt, idxProfilSelected_); + // S\xE9lection des index utils + int nbIdx=0; + for(int i=0;i<lst.getSize();i++) + if(lst.getValue(i)==_idxPoint) + nbIdx++; + int[] result=new int[nbIdx]; + int j=0; + for(int i=0;i<lst.getSize();i++) + if(lst.getValue(i)==_idxPoint) + result[j++]=i; + return result; + } + public String[] getNamesLignesDirectricesAt(int _idxPoint) { if (idxProfilSelected_==-1||_idxPoint<0||_idxPoint>=getNbPoint()) - return null; - // Nom des lignes directrices - int[] idx=getIdxLignesDirectrices(); - String[] names=getNamesLignesDirectrices(); - if(idx==null||names==null) - return null; - // Construction du label par agr\xE9gation des noms des lignes directrices croisant le point - ArrayList<String> labels=new ArrayList<String>(); - for(int i=0;i<idx.length;i++) - if(idx[i]==_idxPoint) - labels.add(names[i]); - if(labels.size()==0) - return null; - else - return labels.toArray(new String[0]); + return new String[0]; + int[] idx=getIdxLignesDirectricesAt(_idxPoint); + if(idx.length==0) + return new String[0]; + // R\xE9cup\xE9rationd des noms a partir des index + String[] result=new String[idx.length]; + for(int i=0;i<result.length;i++) + result[i]= getLigneDirectriceName(idx[i]); + return result; } public String[] getNamesLignesDirectrices() { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java 2009-01-16 18:56:21 UTC (rev 4379) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java 2009-01-19 15:49:15 UTC (rev 4380) @@ -411,4 +411,15 @@ else return 0; } + + /** + * Retourne vrai si _el is dans _coll. _coll n'est pas consid\xE9r\xE9 comme tri\xE9e. + */ + static public boolean in(int _in, int[] _coll) { + boolean found=false; + int i=-1; + while(!found&&++i<_coll.length) + found=_coll[i]==_in; + return found; + } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueCourbe.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueCourbe.java 2009-01-16 18:56:21 UTC (rev 4379) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueCourbe.java 2009-01-19 15:49:15 UTC (rev 4380) @@ -24,6 +24,7 @@ import org.fudaa.ctulu.CtuluCommandComposite; import org.fudaa.ctulu.CtuluCommandContainer; import org.fudaa.ctulu.CtuluLib; +import org.fudaa.ctulu.CtuluListSelectionEvent; import org.fudaa.ctulu.CtuluListSelectionInterface; import org.fudaa.ctulu.CtuluListSelectionListener; import org.fudaa.ctulu.CtuluNumberFormatDefault; @@ -48,6 +49,7 @@ import com.memoire.bu.BuBorderLayout; import com.memoire.bu.BuButton; +import com.memoire.bu.BuComboBox; import com.memoire.bu.BuPanel; import com.memoire.bu.BuSpecificBar; @@ -69,6 +71,24 @@ public class VueCourbe extends BuPanel { /** + * Petite classe utilie pour le combo box de choix de ligne directrice. + * Il permet de concerver l'index de la ligne directrice en plus de son nom. + * @author Emmanuel MARTIN + * @version $Id:$ + */ + private class PaireLd { + public int idx; + public String name; + public PaireLd(int _idx, String _name) { + idx=_idx; + name=_name; + } + public String toString() { + return name; + } + } + + /** * Ce nouveau model de courbe permet d'utiliser un model d\xE9j\xE0 existant sous la * forme d'une DataGeometry. */ @@ -139,6 +159,30 @@ } } + /** + * Place au point voulu le passage de la ligne directrice. + */ + public void setLigneDirectriceAt(int _idxPoint, int _idxLd) { + controller_.clearError(); + try { + data_.setLigneDirectriceAt(_idxLd, _idxPoint, controller_.getCommandManager()); + } + catch(IllegalArgumentException _e) { + controller_.showError(_e.getMessage()); + } + } + + /** + * Retourne les noms des lignes directrices d\xE9placable vers ce point. + */ + public PaireLd[] getAllowedLignesDirectricesAt(int _idxPoint) { + int[] idx=data_.getAllowedMoveOfLignesDirectricesTo(_idxPoint); + PaireLd[] lds=new PaireLd[idx.length]; + for(int i=0;i<lds.length;i++) + lds[i]=new PaireLd(idx[i], data_.getLigneDirectriceName(idx[i])); + return lds; + } + private void updateLabels() { courbe_.removeLabels(); // Rive gauche @@ -218,7 +262,7 @@ public String getPointLabel(int _i) { String[] names=data_.getNamesLignesDirectricesAt(_i); - if(names==null) + if(names.length==0) return null; // Construction du label par agr\xE9gation des noms String label=""; @@ -384,6 +428,7 @@ BuButton riveGauche_; BuButton riveDroite_; BuButton limiteDroite_; + BuComboBox lignesDirectrices_; public VueCourbe(Controller1d _controller, ProfilContainer _dataGeom){ controller_=_controller; @@ -471,7 +516,33 @@ courbeModel_.setLimiteDroite(idx[0]); } }); + actions.add(limiteDroite_); + lignesDirectrices_=new BuComboBox(); + lignesDirectrices_.addItem(new PaireLd(-1, FudaaLib.getS("LD"))); + lignesDirectrices_.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + int[] idx=getSelection(); + if(idx!=null&&idx.length==1) { + PaireLd paireLd=(PaireLd) lignesDirectrices_.getSelectedItem(); + if(paireLd!=null&&paireLd.idx!=-1) + courbeModel_.setLigneDirectriceAt(idx[0], paireLd.idx); + } + } + }); + addSelectionListener(new CtuluListSelectionListener(){ + public void listeSelectionChanged(CtuluListSelectionEvent _e) { + int[] idx=getSelection(); + lignesDirectrices_.removeAllItems(); + lignesDirectrices_.addItem(new PaireLd(-1, FudaaLib.getS("LD"))); + if(idx!=null&&idx.length==1){ + PaireLd[] paireLd=courbeModel_.getAllowedLignesDirectricesAt(idx[0]); + for(int i=0;i<paireLd.length;i++) + lignesDirectrices_.addItem(paireLd[i]); + } + } + }); + actions.add(lignesDirectrices_); // Ajout des boutons \xE0 la barre speBar.addTools(actions.toArray(new JComponent[0])); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2009-01-19 16:20:31
|
Revision: 4381 http://fudaa.svn.sourceforge.net/fudaa/?rev=4381&view=rev Author: emmanuel_martin Date: 2009-01-19 16:20:26 +0000 (Mon, 19 Jan 2009) Log Message: ----------- bugfix : importation de polygone venant des fichiers rubars Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelFilterAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelSelectionAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSigFileLoaderRubarSt.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelFilterAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelFilterAdapter.java 2009-01-19 15:49:15 UTC (rev 4380) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelFilterAdapter.java 2009-01-19 16:20:26 UTC (rev 4381) @@ -98,7 +98,7 @@ } /** - * Cr\xE9ation d'un filtre ne conservant que les lignes ferm\xE9es et les d'attributs donn\xE9s. + * Cr\xE9ation d'un filtre ne conservant que les lignes ouvertes et les d'attributs donn\xE9s. */ public static GISDataModelFilterAdapter buildLigneOuverteAdapter(final GISDataModel _collection, final GISAttributeInterface[] _att) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelSelectionAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelSelectionAdapter.java 2009-01-19 15:49:15 UTC (rev 4380) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelSelectionAdapter.java 2009-01-19 16:20:26 UTC (rev 4381) @@ -19,10 +19,10 @@ * r\xE9pondant \xE0 des conditions donn\xE9es sur les attributs. Par exemple on peut * dire que seul les g\xE9om\xE9tries d'une certaine nature sont visbles. * Plusieurs conditions peuvent \xEAtre donn\xE9es. Elles seront g\xE9r\xE9es avec un OU - * logique. Pour simuler un ET logique entre des conditions, il suffi d'empiler - * plusieurs fois cette adapter sur le model. + * logique. Pour simuler un ET logique entre des conditions, il suffit d'empiler + * plusieurs fois cet adapter sur le model. * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public class GISDataModelSelectionAdapter implements GISDataModel { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSigFileLoaderRubarSt.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSigFileLoaderRubarSt.java 2009-01-19 15:49:15 UTC (rev 4380) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSigFileLoaderRubarSt.java 2009-01-19 16:20:26 UTC (rev 4381) @@ -17,7 +17,9 @@ import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ctulu.gis.GISAttributeInterface; import org.fudaa.ctulu.gis.GISDataModelAttributeAdapter; +import org.fudaa.ctulu.gis.GISDataModelFilterAdapter; import org.fudaa.ctulu.gis.GISDataModelListPtAdapter; +import org.fudaa.ctulu.gis.GISDataModelSelectionAdapter; import org.fudaa.ctulu.gis.GISVisitorCount; import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; @@ -62,16 +64,25 @@ if (res[i]==null||res[i].getNumGeometries()==0) continue; blines=true; res[i].accept(counter); - _r.nbPoint_+=counter.nbPt_; _r.nbPointTotal_+=counter.nbPt_; - _r.nbPolygones_+=counter.nbPolygone_; - _r.nbPolylignes_+=counter.nbPolyligne_; // Ajout de l'attribut ETAT_GEOM _r.findOrCreateAttribute(GISAttributeConstants.ETAT_GEOM.getID(), String.class, false); GISDataModelAttributeAdapter adapter = new GISDataModelAttributeAdapter(res[i]); adapter.addAttribut(GISAttributeConstants.ETAT_GEOM, _fileOrigine); // - _r.ligneModel_.add(adapter); + GISAttributeInterface[] attrs=res[i].getAttributes(); + if(counter.nbPt_>0) { + _r.nbPoint_+=counter.nbPt_; + _r.pointModel_.add(GISDataModelFilterAdapter.buildPointAdapter(adapter, attrs)); + } + if(counter.nbPolyligne_>0) { + _r.nbPolylignes_+=counter.nbPolyligne_; + _r.ligneModel_.add(GISDataModelFilterAdapter.buildLigneOuverteAdapter(adapter, attrs)); + } + if(counter.nbPolygone_>0) { + _r.nbPolygones_+=counter.nbPolygone_; + _r.polygoneModel_.add(GISDataModelFilterAdapter.buildLigneFermeeAdapter(adapter, attrs)); + } } if (blines) _r.addUsedAttributes(new GISAttributeInterface[]{GISAttributeConstants.BATHY, GISAttributeConstants.TITRE}); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2009-01-19 17:45:48
|
Revision: 4382 http://fudaa.svn.sourceforge.net/fudaa/?rev=4382&view=rev Author: emmanuel_martin Date: 2009-01-19 17:45:43 +0000 (Mon, 19 Jan 2009) Log Message: ----------- Tache #150 : "D?\195?\169caler l'abscisse de l'axe hydraulique" Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerProfil.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueContainerModules.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionProfil.java Added Paths: ----------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionAxeHydraulique.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-01-19 16:20:26 UTC (rev 4381) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-01-19 17:45:43 UTC (rev 4382) @@ -324,4 +324,14 @@ return "ATTRIBUTE_INTERSECTIONS_LIGNES_DIRECTRICES"; } }; + + /** + * Attribut contenant le d\xE9calage curviligne de l'axe hydraulique. + */ + public final static GISAttribute CURVILIGNE_DECALAGE=new GISAttributeDouble(CtuluLib.getS("D\xE9calage curviligne"), false) { + @Override + public String getID() { + return "ATTRIBUTE_CURVILIGNE_DECALAGE"; + } + }; } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java 2009-01-19 16:20:26 UTC (rev 4381) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java 2009-01-19 17:45:43 UTC (rev 4382) @@ -53,6 +53,7 @@ import org.fudaa.fudaa.modeleur.modeleur1d.view.VueContainerModules; import org.fudaa.fudaa.modeleur.modeleur1d.view.VueCourbe; import org.fudaa.fudaa.modeleur.modeleur1d.view.VueExport; +import org.fudaa.fudaa.modeleur.modeleur1d.view.VueModuleGestionAxeHydraulique; import org.fudaa.fudaa.modeleur.modeleur1d.view.VueTableau; import com.memoire.bu.BuDesktop; @@ -123,6 +124,7 @@ // Modules vueContainerModules_=new VueContainerModules(modelContainerModules_); addVueModule(controllerBief_.getVueModuleGestionBief()); + addVueModule(new VueModuleGestionAxeHydraulique(controllerBief_)); addVueModule(controllerProfil_.getVueModuleGestionProfil()); // Vue Bief controllerBief_.getVueBief().getScene().addSelectionListener(this); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java 2009-01-19 16:20:26 UTC (rev 4381) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java 2009-01-19 17:45:43 UTC (rev 4382) @@ -14,6 +14,7 @@ import javax.swing.event.ListSelectionListener; import org.fudaa.ctulu.CtuluCommandContainer; +import org.fudaa.ctulu.CtuluCommandManager; import org.fudaa.ebli.calque.BCalque; import org.fudaa.ebli.calque.ZModeleLigneBrisee; import org.fudaa.fudaa.modeleur.modeleur1d.model.Bief; @@ -117,6 +118,13 @@ } /** + * Retourne le Commande manager utilis\xE9 dans la partie 1d + */ + public CtuluCommandManager getCommandManager(){ + return controller1d_.getCommandManager(); + } + + /** * Retourne la vue du module de gestion des biefs. */ public VueModuleGestionBief getVueModuleGestionBief(){ Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerProfil.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerProfil.java 2009-01-19 16:20:26 UTC (rev 4381) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerProfil.java 2009-01-19 17:45:43 UTC (rev 4382) @@ -11,6 +11,7 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import org.fudaa.ctulu.CtuluCommandManager; import org.fudaa.fudaa.modeleur.modeleur1d.controller.ControllerBief.BiefSelectionModel; import org.fudaa.fudaa.modeleur.modeleur1d.model.BiefContainer; import org.fudaa.fudaa.modeleur.modeleur1d.model.ProfilContainer; @@ -57,6 +58,13 @@ } /** + * Retourne le Commande manager utilis\xE9 dans la partie 1d + */ + public CtuluCommandManager getCommandManager(){ + return controller1d_.getCommandManager(); + } + + /** * Retourne la vue du module de gestion des profils. */ public VueModuleGestionProfil getVueModuleGestionProfil(){ Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-01-19 16:20:26 UTC (rev 4381) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-01-19 17:45:43 UTC (rev 4382) @@ -110,48 +110,15 @@ limitesStockages_=new MdlModel2dConstraintLine(null, null); if (lignesDirectrices_==null) lignesDirectrices_=new MdlModel2dDirectionLine(null, null); - // Valuation des attributs sp\xE9cifiques au 1d \\ - // Verification de la pr\xE9sences des attributs + // Valuation des attributs sp\xE9cifiques au 1d pour les profils \\ GISZoneCollection zone=profils_.getGeomData(); - int attToAdd=0; - int idxIlsd=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); - if (idxIlsd==-1) - attToAdd++; - int idxIlsg=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); - if (idxIlsg==-1) - attToAdd++; - int idxRd=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); - if (idxRd==-1) - attToAdd++; - int idxRg=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); - if (idxRg==-1) - attToAdd++; - int idxLd=zone.getIndiceOf(GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); - if(idxLd==-1) - attToAdd++; - // Ajout des attributs manquant \\ - if (attToAdd>0) { - GISAttributeInterface[] atts=new GISAttributeInterface[zone.getNbAttributes()+attToAdd]; - int k=0; - for (k=0; k<zone.getNbAttributes(); k++) - atts[k]=zone.getAttribute(k); - if (idxIlsd==-1) - atts[k++]=GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE; - if (idxIlsg==-1) - atts[k++]=GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE; - if (idxRd==-1) - atts[k++]=GISAttributeConstants.INTERSECTION_RIVE_DROITE; - if (idxRg==-1) - atts[k++]=GISAttributeConstants.INTERSECTION_RIVE_GAUCHE; - if(idxLd==-1) - atts[k++]=GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES; - zone.setAttributes(atts, null); - } + normalizeProfilAttributes(zone); int idxAttRiveGauche=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); int idxAttRiveDroite=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); int idxAttlsGauche=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); int idxAttlsDroite=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); int idxAttLignesDirectrices=zone.getIndiceOf(GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); + if (axeHydraulique_.getNombre()==0) for (int i=0; i<profils_.getNombre(); i++) { profils_.getGeomData().setAttributValue(idxAttRiveGauche, i, null, null); @@ -232,11 +199,70 @@ // Lignes directrices \\ valuateProfilIntersection(idxAttLignesDirectrices); } + // Valuation des attributs sp\xE9cifique au 1d pour l'axe hydraulique \\ + normalizeAxeHydrauliqueAttributes(axeHydraulique_.getGeomData()); // Activation du synchroniser gisSynchroniser_.enable(); } /** + * Ajout les attributs manquant \xE0 la zone de l'axe hydraulique. + */ + private void normalizeAxeHydrauliqueAttributes(GISZoneCollection _zone) { + if(_zone.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE)==-1) { + GISAttributeInterface[] atts=new GISAttributeInterface[_zone.getNbAttributes()+1]; + for (int k=0; k<_zone.getNbAttributes(); k++) + atts[k]=_zone.getAttribute(k); + atts[atts.length-1]=GISAttributeConstants.CURVILIGNE_DECALAGE; + _zone.setAttributes(atts, null); + int idxAttrDecCurv=_zone.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE); + for(int i=0;i<_zone.getNbGeometries();i++) + _zone.setAttributValue(idxAttrDecCurv, i, 0.0, null); + } + } + + /** + * Ajout les attributs manquant \xE0 la zone des profils. + */ + private void normalizeProfilAttributes(GISZoneCollection _zone) { + // Verification de la pr\xE9sences des attributs + int attToAdd=0; + int idxIlsd=_zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); + if (idxIlsd==-1) + attToAdd++; + int idxIlsg=_zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); + if (idxIlsg==-1) + attToAdd++; + int idxRd=_zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); + if (idxRd==-1) + attToAdd++; + int idxRg=_zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); + if (idxRg==-1) + attToAdd++; + int idxLd=_zone.getIndiceOf(GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); + if(idxLd==-1) + attToAdd++; + // Ajout des attributs manquant \\ + if (attToAdd>0) { + GISAttributeInterface[] atts=new GISAttributeInterface[_zone.getNbAttributes()+attToAdd]; + int k=0; + for (k=0; k<_zone.getNbAttributes(); k++) + atts[k]=_zone.getAttribute(k); + if (idxIlsd==-1) + atts[k++]=GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE; + if (idxIlsg==-1) + atts[k++]=GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE; + if (idxRd==-1) + atts[k++]=GISAttributeConstants.INTERSECTION_RIVE_DROITE; + if (idxRg==-1) + atts[k++]=GISAttributeConstants.INTERSECTION_RIVE_GAUCHE; + if(idxLd==-1) + atts[k++]=GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES; + _zone.setAttributes(atts, null); + } + } + + /** * Inverse le sens du profil dont l'index est pass\xE9 en param\xE8tre. */ private void inverseProfil(int _idxProfil) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java 2009-01-19 16:20:26 UTC (rev 4381) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java 2009-01-19 17:45:43 UTC (rev 4382) @@ -106,6 +106,7 @@ // Caches \\ private int idxZMax_; private int idxZMin_; + private double curviligneDecalage_; // d\xE9calage de l'axe hydraulique. // Le profil est potentiellement coup\xE9 en trois, les deux indices qui suivent // indique l'index de chacune de ces ruptures. private int idxRupture1_; @@ -211,9 +212,12 @@ if (idxProfilSelected_==-1) { z_=null; curv_=null; + curviligneDecalage_=0; } else if (biefContainer_.getZoneProfils()!=null&&idxProfilSelected_>=0&&idxProfilSelected_<biefContainer_.getZoneProfils().getNbGeometries()&&biefContainer_.getZoneProfils().getAttributeIsZ()!=null) { try { + int idxAttrDecCurv=biefContainer_.getZoneAxeHydraulique().getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE); + curviligneDecalage_=(Double) biefContainer_.getZoneAxeHydraulique().getValue(idxAttrDecCurv, 0); z_=(CtuluCollection)biefContainer_.getZoneProfils().getValue(biefContainer_.getZoneProfils().getIndiceOf(biefContainer_.getZoneProfils().getAttributeIsZ()), idxProfilSelected_); curv_=new ArrayList<Double>(); CoordinateSequence seq=((GISCoordinateSequenceContainerInterface)biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_)).getCoordinateSequence(); @@ -302,6 +306,7 @@ idxProfilSelected_=-1; z_=null; curv_=null; + curviligneDecalage_=0; fireProfilContainerDataModified(); // Propagation de l'exception throw _exp; @@ -369,7 +374,7 @@ if (idxProfilSelected_==-1||biefContainer_.getZoneAxeHydraulique().getNbGeometries()==0) return -1; return UtilsProfil1d.abscisseCurviligne(((GISCoordinateSequenceContainerInterface)biefContainer_.getZoneAxeHydraulique() - .getGeometry(0)).getCoordinateSequence(), getCoordSeq()); + .getGeometry(0)).getCoordinateSequence(), getCoordSeq())+curviligneDecalage_; } public int getNbLignesDirectrices() { @@ -541,12 +546,13 @@ } public boolean setAbsCurvProfilOnAxeHydraulique(double _value, CtuluCommandContainer _cmd) throws ProfilContainerException { + _value=_value-curviligneDecalage_; CoordinateSequence axeHydrau=((GISCoordinateSequenceContainerInterface)biefContainer_.getZoneAxeHydraulique().getGeometry(0)) .getCoordinateSequence(); Geometry geomAxeHydrau=biefContainer_.getZoneAxeHydraulique().getGeometry(0); if (_value<0||_value>UtilsProfil1d.abscisseCurviligne(axeHydrau, axeHydrau.getCoordinate(axeHydrau.size()-1))) - throw new IllegalArgumentException(FudaaLib.getS("L'abscisse curviligne doit \xEAtre entre 0 et " - +UtilsProfil1d.abscisseCurviligne(axeHydrau, axeHydrau.getCoordinate(axeHydrau.size()-1))+" inclus.")); + throw new IllegalArgumentException(FudaaLib.getS("L'abscisse curviligne doit \xEAtre entre " +curviligneDecalage_+" et " + +(UtilsProfil1d.abscisseCurviligne(axeHydrau, axeHydrau.getCoordinate(axeHydrau.size()-1))+curviligneDecalage_)+" inclus.")); CtuluCommandComposite cmd=new CtuluCommandComposite(FudaaLib.getS("D\xE9placement d'un profil")); // Calcul de la coordonn\xE9e actuelle de croisement entre l'axe et le profil Geometry intersection=geomAxeHydrau.intersection( Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueContainerModules.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueContainerModules.java 2009-01-19 16:20:26 UTC (rev 4381) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueContainerModules.java 2009-01-19 17:45:43 UTC (rev 4382) @@ -7,7 +7,8 @@ */ package org.fudaa.fudaa.modeleur.modeleur1d.view; -import javax.swing.Box; +import java.awt.Container; + import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.ListModel; @@ -15,23 +16,25 @@ import javax.swing.event.ListDataListener; import com.memoire.bu.BuBorderLayout; +import com.memoire.bu.BuVerticalLayout; /** * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public class VueContainerModules extends JComponent implements ListDataListener { /** le model */ private ListModel model_; - /** La boite contenant la visualisation des modules. */ - private Box box_; + /** Container contenant la visualisation des modules. */ + private Container container_; public VueContainerModules(ListModel _model){ model_=_model; setLayout(new BuBorderLayout()); - box_=new Box(BoxLayout.Y_AXIS); - add(box_, BuBorderLayout.CENTER); + container_=new Container(); + container_.setLayout(new BuVerticalLayout()); + add(container_, BuBorderLayout.CENTER); model_.addListDataListener(this); updateBox(); } @@ -40,10 +43,10 @@ * R\xE9g\xE9n\xE8re le contenu de la box. */ protected void updateBox(){ - box_.removeAll(); + container_.removeAll(); for(int i=0;i<model_.getSize();i++) if(model_.getElementAt(i) instanceof JComponent) - box_.add((JComponent) model_.getElementAt(i)); + container_.add((JComponent) model_.getElementAt(i)); } public void contentsChanged(ListDataEvent e) { Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionAxeHydraulique.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionAxeHydraulique.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionAxeHydraulique.java 2009-01-19 17:45:43 UTC (rev 4382) @@ -0,0 +1,90 @@ +/* + * @creation 19 janv. 2009 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2009 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.fudaa.modeleur.modeleur1d.view; + +import java.awt.Container; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ctulu.gis.GISZoneCollection; +import org.fudaa.fudaa.commun.FudaaLib; +import org.fudaa.fudaa.modeleur.modeleur1d.controller.ControllerBief; +import org.fudaa.fudaa.modeleur.modeleur1d.model.BiefContainerListener; + +import com.memoire.bu.BuBorderLayout; +import com.memoire.bu.BuCharValidator; +import com.memoire.bu.BuGridLayout; +import com.memoire.bu.BuLabel; +import com.memoire.bu.BuPanel; +import com.memoire.bu.BuTextField; + +/** + * Petit module permettant de modifier les propri\xE9t\xE9s de l'axe hydraulique. + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class VueModuleGestionAxeHydraulique extends BuPanel{ + + /** Le controller des biefs. */ + protected ControllerBief controllerBief_; + /** D\xE9calage curviligne */ + protected BuTextField btDecalageCurviligne_; + + public VueModuleGestionAxeHydraulique(ControllerBief _controllerBief){ + controllerBief_=_controllerBief; + setLayout(new BuBorderLayout()); + // Mise \xE0 jour lors du changement de bief selectionn\xE9 + controllerBief_.getBiefContainer().addBiefContainerListener(new BiefContainerListener() { + public void biefSelectedChanged(String name) { + btDecalageCurviligne_.setText(getDecalageCurviligne()); + } + public void biefSelectedRenamed(String name, String name2) {} + public void profilAdded(int profil) {} + public void profilRemoved(int profil) {} + public void profilRenamed(int profil, String name, String name2) {} + }); + // Titre + BuLabel lblTitre=new BuLabel("<html><b>"+FudaaLib.getS("Axe hydraulique")+"</b></html>"); + lblTitre.setHorizontalAlignment(BuLabel.CENTER); + add(lblTitre, BuBorderLayout.NORTH); + // Body \\ + Container body=new Container(); + body.setLayout(new BuGridLayout(2, 2, 2)); + // D\xE9calage curviligne + body.add(new BuLabel(FudaaLib.getS("Abscisse Curviligne : "))); + btDecalageCurviligne_=new BuTextField(); + btDecalageCurviligne_.setCharValidator(BuCharValidator.DOUBLE); + btDecalageCurviligne_.setText(getDecalageCurviligne()); + btDecalageCurviligne_.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e) { + try { + double value=Double.parseDouble(btDecalageCurviligne_.getText()); + GISZoneCollection zone=controllerBief_.getBiefContainer().getZoneAxeHydraulique(); + int idxAttr=zone.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE); + zone.setAttributValue(idxAttr, 0, value, controllerBief_.getCommandManager()); + } + catch(NumberFormatException _ex) {} + } + }); + body.add(btDecalageCurviligne_); + add(body, BuBorderLayout.CENTER); + } + + /** + * Retourne la valeur du d\xE9calage sous forme de string. + */ + private String getDecalageCurviligne() { + GISZoneCollection zone=controllerBief_.getBiefContainer().getZoneAxeHydraulique(); + if(zone==null) + return ""; + int idxAttr=zone.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE); + return Double.toString((Double) zone.getValue(idxAttr, 0)); + } + +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionAxeHydraulique.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionProfil.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionProfil.java 2009-01-19 16:20:26 UTC (rev 4381) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionProfil.java 2009-01-19 17:45:43 UTC (rev 4382) @@ -8,6 +8,7 @@ package org.fudaa.fudaa.modeleur.modeleur1d.view; import java.awt.Container; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -82,7 +83,7 @@ btFusionner.setEnabled(false); btContainer.add(btFusionner); body.add(btContainer, BuBorderLayout.EAST); - body.setPreferredSize(body.getMinimumSize()); + body.setPreferredSize(new Dimension(body.getMinimumSize().width, 350)); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2009-01-21 09:11:27
|
Revision: 4388 http://fudaa.svn.sourceforge.net/fudaa/?rev=4388&view=rev Author: emmanuel_martin Date: 2009-01-21 09:11:20 +0000 (Wed, 21 Jan 2009) Log Message: ----------- Tache 148 : "Ajouter une fonction "fusion de biefs"" Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionBief.java Added Paths: ----------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueFusionBief.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-01-20 23:25:33 UTC (rev 4387) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-01-21 09:11:20 UTC (rev 4388) @@ -323,6 +323,13 @@ public String getID() { return "ATTRIBUTE_INTERSECTIONS_LIGNES_DIRECTRICES"; } + @Override + protected Object createGlobalValues(Object _initValues) { + if (_initValues instanceof GISAttributeModelIntegerList) + return _initValues; + else + return getDefaultValue(); + }; }; /** Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java 2009-01-20 23:25:33 UTC (rev 4387) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java 2009-01-21 09:11:20 UTC (rev 4388) @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.BitSet; import java.util.List; import javax.swing.DefaultListSelectionModel; @@ -17,17 +18,28 @@ import org.fudaa.ctulu.CtuluCommandComposite; import org.fudaa.ctulu.CtuluCommandContainer; import org.fudaa.ctulu.CtuluCommandManager; +import org.fudaa.ctulu.CtuluListSelection; +import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ctulu.gis.GISCoordinateSequenceFactory; +import org.fudaa.ctulu.gis.GISPolyligne; +import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ebli.calque.BCalque; import org.fudaa.ebli.calque.ZModeleLigneBrisee; +import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; import org.fudaa.fudaa.commun.FudaaLib; import org.fudaa.fudaa.modeleur.modeleur1d.model.Bief; import org.fudaa.fudaa.modeleur.modeleur1d.model.BiefContainer; import org.fudaa.fudaa.modeleur.modeleur1d.model.BiefContainerAdapter; import org.fudaa.fudaa.modeleur.modeleur1d.model.BiefSet; +import org.fudaa.fudaa.modeleur.modeleur1d.model.UtilsProfil1d; import org.fudaa.fudaa.modeleur.modeleur1d.view.VueBief; +import org.fudaa.fudaa.modeleur.modeleur1d.view.VueFusionBief; import org.fudaa.fudaa.modeleur.modeleur1d.view.VueModuleGestionBief; import org.fudaa.fudaa.sig.layer.FSigLayerLineEditable; +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.CoordinateSequence; + /** * Controller permettant de g\xE9rer (cr\xE9er, modifier, supprimer, selectionner) les biefs. * @author Emmanuel MARTIN @@ -156,10 +168,176 @@ * Fusion de deux biefs. */ public void fusionnerBiefs(int _idxBief1, int _idxBief2){ - //TODO + // D\xE9termine le premier axe hydraulique et le second + double bief1BaseCurv; + double bief2BaseCurv; + { // Bloque r\xE9duisant artificiellement la port\xE9 des variables + String name1=biefSet_.getBiefName(_idxBief1); + String name2=biefSet_.getBiefName(_idxBief2); + Bief bief1=biefSet_.getBief(name1); + Bief bief2=biefSet_.getBief(name2); + GISZoneCollection zoneAxeHydrau1=bief1.axeHydraulique_.getGeomData(); + bief1BaseCurv=(Double)zoneAxeHydrau1.getValue(zoneAxeHydrau1.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE), 0); + GISZoneCollection zoneAxeHydrau2=bief2.axeHydraulique_.getGeomData(); + bief2BaseCurv=(Double)zoneAxeHydrau2.getValue(zoneAxeHydrau2.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE), 0); + + // Verifications + if(bief1==null||bief2==null) + throw new IllegalArgumentException(FudaaLib.getS("Au moins un des index ne correspond pas \xE0 un bief.")); + if(bief1.lignesDirectrices_.getNombre()!=bief2.lignesDirectrices_.getNombre()) + throw new IllegalArgumentException(FudaaLib.getS("Il doit y avoir le m\xEAme nombre de lignes directrices dans les deux biefs.")); + + // Inversion des biefs si n\xE9c\xE9ssaire + if (bief1BaseCurv>bief2BaseCurv) { + int idxTmp=_idxBief1; + _idxBief1=_idxBief2; + _idxBief2=idxTmp; + double valTmp=bief1BaseCurv; + bief1BaseCurv=bief2BaseCurv; + bief2BaseCurv=valTmp; + } + } + { // Bloque r\xE9duisant artificiellement la port\xE9 des variables + String name1=biefSet_.getBiefName(_idxBief1); + String name2=biefSet_.getBiefName(_idxBief2); + CoordinateSequence seqAxe1=biefSet_.getBief(name1).axeHydraulique_.getGeomData().getCoordinateSequence(0); + CoordinateSequence seqAxe2=biefSet_.getBief(name2).axeHydraulique_.getGeomData().getCoordinateSequence(0); + double bief1MaxCurvBrut=UtilsProfil1d.abscisseCurviligne(seqAxe1, seqAxe1.getCoordinate(seqAxe1.size()-1)); + double bief2MaxCurvBrut=UtilsProfil1d.abscisseCurviligne(seqAxe2, seqAxe2.getCoordinate(seqAxe2.size()-1)); + + if(bief1BaseCurv+bief1MaxCurvBrut>bief2BaseCurv) { + VueFusionBief vueFusionBief=new VueFusionBief(controller1d_.getFormater(), name1, bief1BaseCurv, bief1MaxCurvBrut, name2, bief2BaseCurv, bief2MaxCurvBrut); + if(!vueFusionBief.run()) + return; + bief1BaseCurv=vueFusionBief.getAbsCurvAxe1(); + bief2BaseCurv=vueFusionBief.getAbsCurvAxe2(); + } + + // Inversion des biefs si n\xE9c\xE9ssaire + if (bief1BaseCurv>bief2BaseCurv) { + int idxTmp=_idxBief1; + _idxBief1=_idxBief2; + _idxBief2=idxTmp; + double valTmp=bief1BaseCurv; + bief1BaseCurv=bief2BaseCurv; + bief2BaseCurv=valTmp; + } + } + + String name1=biefSet_.getBiefName(_idxBief1); + String name2=biefSet_.getBiefName(_idxBief2); + Bief bief1=biefSet_.getBief(name1); + Bief bief2=biefSet_.getBief(name2); + GISZoneCollection zoneAxeHydrau1=bief1.axeHydraulique_.getGeomData(); + GISZoneCollection zoneAxeHydrau2=bief2.axeHydraulique_.getGeomData(); + CoordinateSequence seqAxeHydraulique1=zoneAxeHydrau1.getCoordinateSequence(0); + CoordinateSequence seqAxeHydraulique2=zoneAxeHydrau2.getCoordinateSequence(0); + + Coordinate debutAxe2=UtilsProfil1d.getCoordinateXY(seqAxeHydraulique1, bief2BaseCurv-bief1BaseCurv); + Coordinate move=UtilsProfil1d.vec(seqAxeHydraulique2.getCoordinate(0), debutAxe2); + + // Construction du nouveau bief + Bief newBief=new Bief(); + String biefName=name1+"_"+name2; + int k=1; + while(biefSet_.getBief(biefName)!=null) + biefName=name1+"_"+name2+"#"+Integer.toString(++k); + // Racourcis + GISZoneCollection zoneAxeHydraulique=newBief.axeHydraulique_.getGeomData(); + GISZoneCollection zoneProfils=newBief.profils_.getGeomData(); + GISZoneCollection bief1ZoneProfil=bief1.profils_.getGeomData(); + GISZoneCollection bief2ZoneProfil=bief2.profils_.getGeomData(); + + // Ajout de g\xE9om\xE9tries au nouveau bief \\ + // Ajout des profils des biefs d'origines + for(int i=0;i<bief1.profils_.getNombre();i++) + zoneProfils.addGeometry(bief1ZoneProfil.getGeometry(i), UtilsProfil1d.getData(i, bief1ZoneProfil), null); + for(int i=0;i<bief2.profils_.getNombre();i++) + zoneProfils.addGeometry(bief2ZoneProfil.getGeometry(i), UtilsProfil1d.getData(i, bief2ZoneProfil), null); + // Ajout de l'axe hydraulique du second bief (utile pour la translation) + zoneAxeHydraulique.addGeometry(zoneAxeHydrau2.getGeometry(0), UtilsProfil1d.getData(0, zoneAxeHydrau2), null); + + // Translation du second bief \\ + // Cr\xE9ation d'une selection contenant le second axe hydraulique + BitSet bs=new BitSet(1); + bs.set(0); + CtuluListSelection selection=new CtuluListSelection(bs); + // Application de la translation sur le second axe hydraulique + ((ZModeleLigneBriseeEditable) newBief.axeHydraulique_).moveGlobal(selection, move.x, move.y, 0, null); + // Cr\xE9ation d'une selection contenant les profils du second axe hydraulique + bs=new BitSet(zoneProfils.getNbGeometries()); + bs.set(bief1.profils_.getNombre(), zoneProfils.getNbGeometries()); + selection=new CtuluListSelection(bs); + // Application de la translation sur les profils du second axe hydraulique + ((ZModeleLigneBriseeEditable) newBief.profils_).moveGlobal(selection, move.x, move.y, 0, null); + + // Fusion des deux axes Hydrauliques \\ + String newTitre=agregeTitres(0, zoneAxeHydrau1, zoneAxeHydrau2, -1, -1); + seqAxeHydraulique2=zoneAxeHydraulique.getCoordinateSequence(0); + Coordinate[] coords=new Coordinate[seqAxeHydraulique1.size()+seqAxeHydraulique2.size()]; + int i=0; + for(;i<seqAxeHydraulique1.size();i++) + coords[i]=seqAxeHydraulique1.getCoordinate(i); + for(;i<seqAxeHydraulique2.size()+seqAxeHydraulique1.size();i++) + coords[i]=seqAxeHydraulique2.getCoordinate(i-seqAxeHydraulique1.size()); + zoneAxeHydraulique.addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(coords)), null, null); + zoneAxeHydraulique.setAttributValue(zoneAxeHydraulique.getIndiceOf(GISAttributeConstants.TITRE), 1, newTitre, null); + zoneAxeHydraulique.setAttributValue(zoneAxeHydrau1.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE), 1, bief1BaseCurv, null); + // suppression de l'axe hydraulique 2 du nouveau bief + zoneAxeHydraulique.removeGeometries(new int[]{0}, null); + + // Traitement des g\xE9om\xE9tries volatiles \\ + // Rives + calculateData(bief1.rives_.getGeomData(), bief2.rives_.getGeomData(), newBief.rives_.getGeomData()); + // Limite de stockage + calculateData(bief1.limitesStockages_.getGeomData(), bief2.limitesStockages_.getGeomData(), newBief.limitesStockages_.getGeomData()); + // Lignes directrices + calculateData(bief1.lignesDirectrices_.getGeomData(), bief2.lignesDirectrices_.getGeomData(), newBief.lignesDirectrices_.getGeomData()); + + // Ajout du nouveau bief \\ + newBief.enableSynchroniser(); + biefSet_.addBief(biefName, newBief, getCommandManager()); } + + /** + * Extrait les valeurs de titre des g\xE9om\xE9tries et en cr\xE9e une nouvelle + * g\xE9om\xE9trie avec ce titre dans _zone3. La nouvelle g\xE9om\xE9trie n'a pas de + * sommets. + */ + private void calculateData(GISZoneCollection _zone1, GISZoneCollection _zone2, GISZoneCollection _zone3) { + int idxAttrZone1=_zone1.getIndiceOf(GISAttributeConstants.TITRE); + int idxAttrZone2=_zone2.getIndiceOf(GISAttributeConstants.TITRE); + int idxAttrZone3=_zone3.getIndiceOf(GISAttributeConstants.TITRE); + for(int i=0;i<_zone1.getNbGeometries();i++) { + String newTitre=agregeTitres(i, _zone1, _zone2, idxAttrZone1, idxAttrZone2); + // Cr\xE9ation de la gom\xE9trie (elle sera correctement g\xE9n\xE9r\xE9 par le synchronizer du bief) + int idxGeom=_zone3.addGeometry(new GISPolyligne(), null, null); + // Valuation de l'attribut nom + _zone3.setAttributValue(idxAttrZone3, idxGeom, newTitre, null); + } + } /** + * Agregation de deux titres. + * Si les _idxAttrX sont \xE0 -1 il seront d\xE9termin\xE9 par la m\xE9thode. + */ + private String agregeTitres(int _idxGeom, GISZoneCollection _zone1, GISZoneCollection _zone2, int _idxAttr1, int _idxAttr2) { + if(_idxAttr1==-1) + _idxAttr1=_zone1.getIndiceOf(GISAttributeConstants.TITRE); + if(_idxAttr2==-1) + _idxAttr2=_zone1.getIndiceOf(GISAttributeConstants.TITRE); + String titre1=(String) _zone1.getValue(_idxAttr1, _idxGeom); + String titre2=(String) _zone2.getValue(_idxAttr2, _idxGeom); + String newTitre; + // Calcule du nouveau nom + if(titre1.equals(titre2)) + newTitre=titre1; + else + newTitre=titre1+'_'+titre2; + return newTitre; + } + + /** * Duplique le bief selectionn\xE9. */ public void dupliquerSelectedBief() { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-01-20 23:25:33 UTC (rev 4387) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-01-21 09:11:20 UTC (rev 4388) @@ -52,9 +52,51 @@ /** Le synchroniser de gis. */ private GisZoneSynchroniser gisSynchroniser_=new GisZoneSynchroniser(); - public Bief(){} + /** + * Les models de bases sont instanci\xE9s, le synchronizer n'est pas lanc\xE9. + */ + public Bief(){ + axeHydraulique_=new MdlModel1dAxe(null); + normalizeAxeHydrauliqueAttributes(axeHydraulique_.getGeomData()); + profils_=new MdlModel2dProfile(null, null); + normalizeProfilAttributes(profils_.getGeomData()); + rives_=new MdlModel1dBank(null, null); + limitesStockages_=new MdlModel2dConstraintLine(null, null); + lignesDirectrices_=new MdlModel2dDirectionLine(null, null); + } + + /** + * Ce constructeur permet de construire un bief a partir des mod\xE8les pr\xE9sents + * dans _models. Le param\xE8tre _rawData permet d'indiquer le type de traitement + * effectu\xE9 sur ces mod\xE8les. Si _rawData est \xE0 true, les donn\xE9es dans les + * mod\xE8les sont import\xE9s en partant du princique qu'ils sont potentiellement + * erron\xE9s. De plus dans cette importation toutes les donn\xE9es 1d sont g\xE9n\xE9r\xE9es + * pendant cette construction, si des donn\xE9es 2d exitaient avant cette + * construction, elles seront \xE9cras\xE9es. si _rawData est mise \xE0 false, les + * model\xE8s pass\xE9s en param\xE8tres sont consid\xE9r\xE9s comme venant du 1d et fiable. + * Dans ce cas si les donn\xE9es sp\xE9cifiques au 1d ne sont pas \xE9cras\xE9s. Une des + * grosses diff\xE9rences de traitement entre _rawData vrai et faux, finalement, + * est que pour le vrai les donn\xE9es sp\xE9cifiques au 1d sont g\xE9n\xE9r\xE9es \xE0 partir + * des g\xE9om\xE9tries volatiles, pas pour le faut. Le faux peut donc se passer des + * g\xE9om\xE9tries volatils du moment qu'elles sont d\xE9finies dans les attributs 1d. + */ + public Bief(ZModeleLigneBrisee[] _models, boolean _rawData) { + if(_rawData) + buildWithUntrustData(_models); + else + buildWithTrustData(_models); + } + + /** + * Correspond au constructeur Bief(ZModeleLigneBrisee[] _models, boolean + * _rawData) avec _rawData \xE0 true. Void le docstring de + * Bief(ZModeleLigneBrisee[] _models, boolean _rawData) pour plus de d\xE9tails. + */ + public Bief(ZModeleLigneBrisee[] _models){ + buildWithUntrustData(_models); + } - public Bief(ZModeleLigneBrisee[] _models){ + private void testAndValuateModels(ZModeleLigneBrisee[] _models) { if (_models==null) throw new IllegalArgumentException("_models ne peut pas \xEAtre null."); for (int i=0; i<_models.length; i++) { @@ -110,6 +152,16 @@ limitesStockages_=new MdlModel2dConstraintLine(null, null); if (lignesDirectrices_==null) lignesDirectrices_=new MdlModel2dDirectionLine(null, null); + } + + private void buildWithTrustData(ZModeleLigneBrisee[] _models) { + testAndValuateModels(_models); + // Activation du synchroniser + gisSynchroniser_.enable(); + } + + private void buildWithUntrustData(ZModeleLigneBrisee[] _models) { + testAndValuateModels(_models); // Valuation des attributs sp\xE9cifiques au 1d pour les profils \\ GISZoneCollection zone=profils_.getGeomData(); normalizeProfilAttributes(zone); @@ -276,7 +328,7 @@ // Inversion des attributs atomiques for(int i=0;i<zone.getNbAttributes();i++) if(zone.getAttribute(i).isAtomicValue()) { - GISAttributeModel model=((GISAttributeModel)zone.getDataModel(i)); + GISAttributeModel model=(GISAttributeModel)zone.getDataModel(i).getObjectValueAt(_idxProfil); Object valueTmp=model.getObjectValueAt(l); model.setObject(l, model.getObjectValueAt(coords.length-1-l), null); model.setObject(l, valueTmp, null); @@ -573,11 +625,6 @@ private ZModeleLigneBrisee limitesStockagsesModified_; /** Le model de lignes directrices modifi\xE9. */ private ZModeleLigneBrisee lignesDirectricesModified_; - // Les index des g\xE9om\xE9tries. \\ - private int idxRiveGauche_=-1; - private int idxRiveDroite_=-1; - private int idxLimiteStockageGauche_=-1; - private int idxLimiteStockageDroite_=-1; // Les index des attributs \\ private int idxAttRiveGauche_=-1; private int idxAttRiveDroite_=-1; @@ -589,8 +636,9 @@ * Active/met \xE0 jour le synchroniser. */ public void enable() { - if(profilsListen_!=null&&profilsListen_!=profils_) - profilsListen_.removeModelListener(this); + // Met tout au propre + disable(); + // R\xE9g\xE9n\xE8re tout if(profils_!=null) { profils_.addModelListener(this); profilsListen_=profils_; @@ -602,67 +650,86 @@ idxAttlsGauche_=profilsListen_.getGeomData().getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); idxAttlsDroite_=profilsListen_.getGeomData().getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); idxAttlignesDirectrices_=profilsListen_.getGeomData().getIndiceOf(GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); - // D\xE9termination des index de g\xE9om\xE9tries + // Normalisation de la position des g\xE9om\xE9tries et cr\xE9ation des g\xE9om\xE9tries manquantes \\ + /* + * Dans les zones de rives et de limites de stockages, les g\xE9om\xE9tries gauches sont \xE0 la + * position 0 et les g\xE9om\xE9tries droites sont \xE0 la position 1. + */ // Rives - if(rivesModified_.getNombre()>0) { - if(isDroite(rivesModified_.getGeomData().getGeometry(0))) - idxRiveDroite_=0; - else - idxRiveGauche_=0; + if(rivesModified_.getNombre()==0) { + rivesModified_.getGeomData().addGeometry(new GISPolyligne(), null, null); + rivesModified_.getGeomData().addGeometry(new GISPolyligne(), null, null); } - if(rivesModified_.getNombre()>1) { - if(isDroite(rivesModified_.getGeomData().getGeometry(1))) - idxRiveDroite_=1; - else - idxRiveGauche_=1; + else if(rivesModified_.getNombre()==1) { + rivesModified_.getGeomData().addGeometry(new GISPolyligne(), null, null); + if(position(rivesModified_.getGeomData().getGeometry(0))==1) + rivesModified_.getGeomData().switchGeometries(0, 1, null); + } + else if (rivesModified_.getNombre()==2) { + int pos=position(rivesModified_.getGeomData().getGeometry(0)); + if(pos==0) + if(position(rivesModified_.getGeomData().getGeometry(1))==-1) + rivesModified_.getGeomData().switchGeometries(0, 1, null); + if(pos==1) + rivesModified_.getGeomData().switchGeometries(0, 1, null); } - if(rivesModified_.getNombre()>2) - throw new IllegalArgumentException("Le nombre de rives est sup\xE9rieur \xE0 deux."); + else + throw new IllegalArgumentException(FudaaLib.getS("Le nombre de rives est sup\xE9rieur \xE0 deux.")); // Limites de stockages - if(limitesStockagsesModified_.getNombre()>0) { - if(isDroite(limitesStockagsesModified_.getGeomData().getGeometry(0))) - idxLimiteStockageDroite_=0; - else - idxLimiteStockageGauche_=0; + if(limitesStockagsesModified_.getNombre()==0) { + limitesStockagsesModified_.getGeomData().addGeometry(new GISPolyligne(), null, null); + limitesStockagsesModified_.getGeomData().addGeometry(new GISPolyligne(), null, null); } - if(limitesStockagsesModified_.getNombre()>1) { - if(isDroite(limitesStockagsesModified_.getGeomData().getGeometry(1))) - idxLimiteStockageDroite_=1; - else - idxLimiteStockageGauche_=1; + else if(limitesStockagsesModified_.getNombre()==1) { + limitesStockagsesModified_.getGeomData().addGeometry(new GISPolyligne(), null, null); + if(position(limitesStockagsesModified_.getGeomData().getGeometry(0))==1) + limitesStockagsesModified_.getGeomData().switchGeometries(0, 1, null); + } + else if (limitesStockagsesModified_.getNombre()==2) { + int pos=position(limitesStockagsesModified_.getGeomData().getGeometry(0)); + if(pos==0) + if(position(limitesStockagsesModified_.getGeomData().getGeometry(1))==-1) + limitesStockagsesModified_.getGeomData().switchGeometries(0, 1, null); + if(pos==1) + limitesStockagsesModified_.getGeomData().switchGeometries(0, 1, null); } - if(limitesStockagsesModified_.getNombre()>2) - throw new IllegalArgumentException("Le nombre de limite de stockage est sup\xE9rieur \xE0 deux."); + else + throw new IllegalArgumentException(FudaaLib.getS("Le nombre de limite de stockage est sup\xE9rieur \xE0 deux.")); + regenerateAll(); } - regenerateAll(); } /** - * D\xE9termine si la courbe est \xE0 gauche de l'axe hydraulique. + * D\xE9termine la position de la courbe par rapport \xE0 l'axe hydraulique en se basant sur les profils. + * Retourne -1 si \xE0 gauche, 0 si ind\xE9terminable, 1 si \xE0 droite. */ - private boolean isDroite(Geometry _geom) { + private int position(Geometry _geom) { // Recherche d'intersection de _geom avec un profil boolean found=false; int i=-1; - Coordinate intersectionRive=null; + Coordinate coordIntersection=null; while(!found&&++i<profilsListen_.getNombre()) { Geometry inter=_geom.intersection((Geometry) profilsListen_.getObject(i)); if(inter.getNumPoints()==1) { found=true; - intersectionRive=inter.getCoordinate(); + coordIntersection=inter.getCoordinate(); } } + if(!found) + return 0; // Calcul de l'abscisse curviligne de l'axe hydraulique sur le profil. Geometry axeHydraulique=(Geometry) axeHydraulique_.getObject(0); Geometry intersection=((Geometry) profilsListen_.getObject(i)).intersection(axeHydraulique); - // D\xE9termination de la gauche - if(found&&intersection.getNumPoints()==1) { + // D\xE9termination de la droite + if(intersection.getNumPoints()==1) { CoordinateSequence seqProfil=profilsListen_.getGeomData().getCoordinateSequence(i); double abscisseCurvIntersectionAxe=UtilsProfil1d.abscisseCurviligne(seqProfil, intersection.getCoordinate()); - if(abscisseCurvIntersectionAxe>UtilsProfil1d.abscisseCurviligne(seqProfil, intersectionRive)) - return true; + if(abscisseCurvIntersectionAxe>UtilsProfil1d.abscisseCurviligne(seqProfil, coordIntersection)) + return 1; + else + return -1; } - return false; + return 0; } /** @@ -676,10 +743,6 @@ rivesModified_=null; limitesStockagsesModified_=null; lignesDirectricesModified_=null; - idxRiveGauche_=-1; - idxRiveDroite_=-1; - idxLimiteStockageGauche_=-1; - idxLimiteStockageDroite_=-1; idxAttRiveGauche_=-1; idxAttRiveDroite_=-1; idxAttlsGauche_=-1; @@ -694,27 +757,9 @@ private void destroyGeometries() { // Suppression des anciennes g\xE9om\xE9tries \\ // Rives - int[] idxRives=new int[0]; - if(idxRiveGauche_!=-1&&idxRiveDroite_!=-1) - idxRives=new int[]{idxRiveGauche_, idxRiveDroite_}; - else if(idxRiveGauche_!=-1) - idxRives=new int[]{idxRiveGauche_}; - else if(idxRiveDroite_!=-1) - idxRives=new int[]{idxRiveDroite_}; - rivesModified_.getGeomData().removeGeometries(idxRives, null); - idxRiveGauche_=-1; - idxRiveDroite_=-1; + rivesModified_.getGeomData().removeGeometries(new int[]{0, 1}, null); // Limites stockages - int[] idxLimiteStockages=new int[0]; - if(idxLimiteStockageGauche_!=-1&&idxLimiteStockageDroite_!=-1) - idxLimiteStockages=new int[]{idxLimiteStockageGauche_, idxLimiteStockageDroite_}; - else if(idxLimiteStockageGauche_!=-1) - idxLimiteStockages=new int[]{idxLimiteStockageGauche_}; - else if(idxLimiteStockageDroite_!=-1) - idxLimiteStockages=new int[]{idxLimiteStockageDroite_}; - limitesStockagsesModified_.getGeomData().removeGeometries(idxLimiteStockages, null); - idxLimiteStockageGauche_=-1; - idxLimiteStockageDroite_=-1; + limitesStockagsesModified_.getGeomData().removeGeometries(new int[]{0, 1}, null); // Lignes directrices int[] idx=new int[lignesDirectricesModified_.getNombre()]; for(int i=0;i<idx.length;i++) @@ -733,23 +778,23 @@ public void attributeValueChangeAction(Object _source, int att, GISAttributeInterface _att, int _idxGeom, Object value) { if(_att==GISAttributeConstants.INTERSECTION_RIVE_GAUCHE) - updateGeom(_idxGeom, rivesModified_, idxRiveGauche_, idxAttRiveGauche_); + updateGeom(_idxGeom, rivesModified_, 0, idxAttRiveGauche_); else if(_att==GISAttributeConstants.INTERSECTION_RIVE_DROITE) - updateGeom(_idxGeom, rivesModified_, idxRiveDroite_, idxAttRiveDroite_); + updateGeom(_idxGeom, rivesModified_, 1, idxAttRiveDroite_); else if(_att==GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE) - updateGeom(_idxGeom, limitesStockagsesModified_, idxLimiteStockageGauche_, idxAttlsGauche_); + updateGeom(_idxGeom, limitesStockagsesModified_, 0, idxAttlsGauche_); else if(_att==GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE) - updateGeom(_idxGeom, limitesStockagsesModified_, idxLimiteStockageDroite_, idxAttlsDroite_); + updateGeom(_idxGeom, limitesStockagsesModified_, 1, idxAttlsDroite_); else if(_att==GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES) updateLd(_idxGeom); } public void geometryAction(Object _source, int _idxGeom, Geometry _geom, int _action) { if(_action==ZModelGeometryListener.GEOMETRY_ACTION_MODIFY) { - updateGeom(_idxGeom, rivesModified_, idxRiveGauche_, idxAttRiveGauche_); - updateGeom(_idxGeom, rivesModified_, idxRiveDroite_, idxAttRiveDroite_); - updateGeom(_idxGeom, limitesStockagsesModified_, idxLimiteStockageGauche_, idxAttlsGauche_); - updateGeom(_idxGeom, limitesStockagsesModified_, idxLimiteStockageDroite_, idxAttlsDroite_); + updateGeom(_idxGeom, rivesModified_, 0, idxAttRiveGauche_); + updateGeom(_idxGeom, rivesModified_, 1, idxAttRiveDroite_); + updateGeom(_idxGeom, limitesStockagsesModified_, 0, idxAttlsGauche_); + updateGeom(_idxGeom, limitesStockagsesModified_, 1, idxAttlsDroite_); updateLd(_idxGeom); } } @@ -786,50 +831,38 @@ // Ajout des nouvelles g\xE9o\xE9mtries \\ // Extraction des anciennes donn\xE9es - Object[] dataRiveGauche=getData(idxRiveGauche_, rivesModified_.getGeomData()); - Object[] dataRiveDroite=getData(idxRiveDroite_, rivesModified_.getGeomData()); - Object[] dataLsGauche=getData(idxLimiteStockageGauche_, rivesModified_.getGeomData()); - Object[] dataLsDroite=getData(idxLimiteStockageDroite_, rivesModified_.getGeomData()); + Object[] dataRiveGauche=UtilsProfil1d.getData(0, rivesModified_.getGeomData()); + Object[] dataRiveDroite=UtilsProfil1d.getData(1, rivesModified_.getGeomData()); + Object[] dataLsGauche=UtilsProfil1d.getData(0, rivesModified_.getGeomData()); + Object[] dataLsDroite=UtilsProfil1d.getData(1, rivesModified_.getGeomData()); Object[][] dataLignesDirectrices=new Object[lignesDirectricesModified_.getNombre()][]; for(int i=0;i<lignesDirectricesModified_.getNombre();i++) - dataLignesDirectrices[i]=getData(i, lignesDirectricesModified_.getGeomData()); + dataLignesDirectrices[i]=UtilsProfil1d.getData(i, lignesDirectricesModified_.getGeomData()); // Destruction des g\xE9om\xE9tries destroyGeometries(); // Ajout des geometries \\ // Rives - if (riveGauche.length>1&&riveGauche[0]!=null&&rivesModified_!=null) - idxRiveGauche_=rivesModified_.getGeomData().addGeometry( - new GISPolyligne(new GISCoordinateSequenceFactory().create(riveGauche)), dataRiveGauche, null); - if (riveDroite.length>1&&riveDroite[0]!=null&&rivesModified_!=null) - idxRiveDroite_=rivesModified_.getGeomData().addGeometry( - new GISPolyligne(new GISCoordinateSequenceFactory().create(riveDroite)), dataRiveDroite, null); + if (riveGauche.length>1&&riveGauche[0]!=null&&rivesModified_!=null&&riveDroite.length>1&&riveDroite[0]!=null + &&rivesModified_!=null) { + rivesModified_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(riveGauche)), + dataRiveGauche, null); + rivesModified_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(riveDroite)), + dataRiveDroite, null); + } // Limites de stockages - if (lsGauche.length>1&&lsGauche[0]!=null&&limitesStockagsesModified_!=null) - idxLimiteStockageGauche_=limitesStockagsesModified_.getGeomData().addGeometry( - new GISPolyligne(new GISCoordinateSequenceFactory().create(lsGauche)), dataLsGauche, null); - if (lsDroite.length>1&&lsDroite[0]!=null&&limitesStockagsesModified_!=null) - idxLimiteStockageDroite_=limitesStockagsesModified_.getGeomData().addGeometry( - new GISPolyligne(new GISCoordinateSequenceFactory().create(lsDroite)), dataLsDroite, null); + if (lsGauche.length>1&&lsGauche[0]!=null&&limitesStockagsesModified_!=null&&lsDroite.length>1&&lsDroite[0]!=null + &&limitesStockagsesModified_!=null) { + limitesStockagsesModified_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(lsGauche)), + dataLsGauche, null); + limitesStockagsesModified_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(lsDroite)), + dataLsDroite, null); + } // Lignes directrices for (int i=0; i<ld.length; i++) - lignesDirectricesModified_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(ld[i])), + if(ld[i].length>1) + lignesDirectricesModified_.getGeomData().addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(ld[i])), dataLignesDirectrices[i], null); } - - /** - * Retourne les donn\xE9es. - * retourne null si _idxGeom est invalide. - */ - private Object[] getData(int _idxGeom, GISZoneCollection _zone) { - Object[] data=null; - if (_idxGeom>=0&&_idxGeom<_zone.getNbGeometries()) { - GISAttributeModel[] models=_zone.getModels(); - data=new Object[models.length]; - for (int i=0; i<data.length; i++) - data[i]=models[i].getObjectValueAt(_idxGeom); - } - return data; - } /** * Met \xE0 jour la geometrie volatile indiqu\xE9. Le param\xE8tre pass\xE9 est l'index du point \xE0 Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java 2009-01-20 23:25:33 UTC (rev 4387) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java 2009-01-21 09:11:20 UTC (rev 4388) @@ -7,6 +7,7 @@ */ package org.fudaa.fudaa.modeleur.modeleur1d.model; +import org.fudaa.ctulu.gis.GISAttributeModel; import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; import org.fudaa.ctulu.gis.GISCoordinateSequenceFactory; import org.fudaa.ctulu.gis.GISGeometryFactory; @@ -422,4 +423,19 @@ found=_coll[i]==_in; return found; } + + /** + * Retourne les donn\xE9es de la g\xE9om\xE9tries de _zone. + * retourne null si _idxGeom est invalide. + */ + static public Object[] getData(int _idxGeom, GISZoneCollection _zone) { + Object[] data=null; + if (_idxGeom>=0&&_idxGeom<_zone.getNbGeometries()) { + GISAttributeModel[] models=_zone.getModels(); + data=new Object[models.length]; + for (int i=0; i<data.length; i++) + data[i]=models[i].getObjectValueAt(_idxGeom); + } + return data; + } } Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueFusionBief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueFusionBief.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueFusionBief.java 2009-01-21 09:11:20 UTC (rev 4388) @@ -0,0 +1,125 @@ +/* + * @creation 20 janv. 2009 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2009 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.fudaa.modeleur.modeleur1d.view; + +import java.awt.Container; +import java.awt.GridLayout; + +import javax.swing.SwingUtilities; + +import org.fudaa.ctulu.CtuluLib; +import org.fudaa.ctulu.gui.CtuluDialogPanel; +import org.fudaa.ebli.commun.EbliFormatterInterface; +import org.fudaa.fudaa.commun.FudaaLib; + +import com.memoire.bu.BuBorderLayout; +import com.memoire.bu.BuCharValidator; +import com.memoire.bu.BuGridLayout; +import com.memoire.bu.BuLabel; +import com.memoire.bu.BuPanel; +import com.memoire.bu.BuTextField; + +/** + * Petite fen\xEAtre demandant des informations suppl\xE9mentaire \xE0 l'utilisateur + * concernant la fusion de deux biefs. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class VueFusionBief extends CtuluDialogPanel { + + /* Donn\xE9es de base */ + private String name1_; + private double absCurv1_; + private double length1_; + private String name2_; + private double absCurv2_; + private double length2_; + /* Donn\xE9es de l'interface */ + private BuTextField tfAbsCurv1_; + private BuTextField tfAbsCurv2_; + + public VueFusionBief(EbliFormatterInterface _formater, String _name1, double _absCurv1, double _length1, String _name2, double _absCurv2, double _length2) { + name1_=_name1; + absCurv1_=_absCurv1; + length1_=_length1; + name2_=_name2; + absCurv2_=_absCurv2; + length2_=_length2; + + // Construction de la fen\xEAtre \\ + setLayout(new BuBorderLayout()); + // Titres + Container head=new Container(); + head.setLayout(new BuGridLayout(1)); + BuLabel titre1=new BuLabel(FudaaLib.getS("Les deux axes hydrauliques se superposes.")); + titre1.setHorizontalAlignment(SwingUtilities.CENTER); + head.add(titre1); + BuLabel titre2=new BuLabel(FudaaLib.getS("D\xE9finissez de nouvelles valeurs d'abscisses curviligne pour corriger ce probl\xE8me.")); + titre2.setHorizontalAlignment(SwingUtilities.CENTER); + head.add(titre2); + add(head, BuBorderLayout.NORTH); + // Corps + BuPanel body=new BuPanel(); + body.setLayout(new GridLayout(3, 2, 2, 2)); + BuLabel name1=new BuLabel(name1_); + name1.setHorizontalAlignment(SwingUtilities.CENTER); + body.add(name1); + BuLabel name2=new BuLabel(name2_); + name2.setHorizontalAlignment(SwingUtilities.CENTER); + body.add(name2); + tfAbsCurv1_=new BuTextField(_formater.getXYFormatter().format(absCurv1_)); + tfAbsCurv1_.setCharValidator(BuCharValidator.DOUBLE); + tfAbsCurv2_=new BuTextField(_formater.getXYFormatter().format(absCurv2_)); + tfAbsCurv2_.setCharValidator(BuCharValidator.DOUBLE); + body.add(tfAbsCurv1_); + body.add(tfAbsCurv2_); + body.add(new BuLabel(FudaaLib.getS("taille : " + _formater.getXYFormatter().format(length1_)))); + body.add(new BuLabel(FudaaLib.getS("taille : " + _formater.getXYFormatter().format(length2_)))); + add(body, BuBorderLayout.CENTER); + } + + public boolean valide() { + absCurv1_=Double.parseDouble(tfAbsCurv1_.getText()); + absCurv2_=Double.parseDouble(tfAbsCurv2_.getText()); + if(absCurv1_<=absCurv2_&&absCurv1_+length1_>absCurv2_) { + setErrorText(CtuluLib.getS(name1_ + FudaaLib.getS(" est toujours chevauch\xE9 par ") + name2_ +".")); + return false; + } + else if(absCurv2_<absCurv1_&&absCurv2_+length2_>absCurv1_) { + setErrorText(CtuluLib.getS(name2_ + FudaaLib.getS(" est toujours chevauch\xE9 par ") + name1_ +".")); + return false; + } + return true; + } + + /** + * Lance l'exporter dans une fen\xEAtre modale et retourne vrai si l'utilisateur + * clic sur 'ok' \xE0 la fin, faux si il clic sur 'annuler'. + * + * @return + */ + public boolean run(){ + return CtuluDialogPanel.isOkResponse(afficheModale(this, FudaaLib.getS("Fusion de deux biefs"))); + } + + /** + * Retourne l'abscisse curviligne de l'axe 1. + */ + public double getAbsCurvAxe1() { + return absCurv1_; + } + + /** + * Retourne l'abscisse curviligne de l'axe 2. + */ + public double getAbsCurvAxe2() { + return absCurv2_; + } + +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueFusionBief.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionBief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionBief.java 2009-01-20 23:25:33 UTC (rev 4387) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionBief.java 2009-01-21 09:11:20 UTC (rev 4388) @@ -110,7 +110,7 @@ btFusionner_.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { ListSelectionModel sel=tableBiefs_.getSelectionModel(); - controllerBief_.fusionnerBiefs(sel.getMaxSelectionIndex(), sel.getMinSelectionIndex()); + controllerBief_.fusionnerBiefs(sel.getMinSelectionIndex(), sel.getMaxSelectionIndex()); } }); tableBiefs_.getSelectionModel().addListSelectionListener(new ListSelectionListener() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2009-01-21 17:31:02
|
Revision: 4390 http://fudaa.svn.sourceforge.net/fudaa/?rev=4390&view=rev Author: emmanuel_martin Date: 2009-01-21 17:30:56 +0000 (Wed, 21 Jan 2009) Log Message: ----------- Tache #128 "On aimerait pouvoir copier des g?\195?\169om?\195?\169tries/sommets vers un calque sans passer par une duplication" Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZSceneEditor.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/impl/FudaaCommonImplementation.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlFille2d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlSceneEditor.java Added Paths: ----------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/CutCopyPasteManager.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/ZDialog.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZSceneEditor.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZSceneEditor.java 2009-01-21 16:06:25 UTC (rev 4389) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZSceneEditor.java 2009-01-21 17:30:56 UTC (rev 4390) @@ -11,7 +11,6 @@ import org.fudaa.ctulu.CtuluCommandContainer; import org.fudaa.ctulu.CtuluCommandManager; import org.fudaa.ctulu.CtuluUI; -import org.fudaa.ebli.calque.ZCalqueAffichageDonnees; import org.fudaa.ebli.calque.ZCalqueAffichageDonneesInterface; import org.fudaa.ebli.calque.ZEbliCalquesPanel; import org.fudaa.ebli.calque.ZScene; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/impl/FudaaCommonImplementation.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/impl/FudaaCommonImplementation.java 2009-01-21 16:06:25 UTC (rev 4389) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/impl/FudaaCommonImplementation.java 2009-01-21 17:30:56 UTC (rev 4390) @@ -320,6 +320,16 @@ act=replaceItemByAction("DUPLIQUER"); act.setEnabled(false); if (act!=null) EbliActionMap.getInstance().addAction(act); + + act=replaceItemByAction("COUPER"); + act.setEnabled(false); + if (act!=null) EbliActionMap.getInstance().addAction(act); + act=replaceItemByAction("COLLER"); + act.setEnabled(false); + if (act!=null) EbliActionMap.getInstance().addAction(act); + act=replaceItemByAction("COPIER"); + act.setEnabled(false); + if (act!=null) EbliActionMap.getInstance().addAction(act); } /** Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/CutCopyPasteManager.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/CutCopyPasteManager.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/CutCopyPasteManager.java 2009-01-21 17:30:56 UTC (rev 4390) @@ -0,0 +1,309 @@ +/* + * @creation 21 janv. 2009 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2009 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.fudaa.modeleur; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.event.InternalFrameAdapter; +import javax.swing.event.InternalFrameEvent; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; + +import org.fudaa.ctulu.CtuluCommandComposite; +import org.fudaa.ctulu.gis.GISAttributeInterface; +import org.fudaa.ctulu.gis.GISAttributeModel; +import org.fudaa.ctulu.gis.GISCoordinateSequenceFactory; +import org.fudaa.ctulu.gis.GISGeometryFactory; +import org.fudaa.ctulu.gis.GISLib; +import org.fudaa.ctulu.gis.GISZoneCollection; +import org.fudaa.ebli.calque.ZModeleGeometry; +import org.fudaa.ebli.calque.ZScene; +import org.fudaa.ebli.calque.ZSelectionEvent; +import org.fudaa.ebli.calque.ZSelectionListener; +import org.fudaa.ebli.calque.dessin.DeForme; +import org.fudaa.ebli.calque.edition.ZCalqueEditable; +import org.fudaa.ebli.calque.edition.ZModeleEditable; +import org.fudaa.ebli.commun.EbliActionInterface; +import org.fudaa.ebli.commun.EbliActionMap; +import org.fudaa.fudaa.commun.FudaaLib; +import org.fudaa.fudaa.modeleur.layer.MdlModel2dLine; +import org.fudaa.fudaa.modeleur.layer.MdlModel2dMultiPoint; + +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.Geometry; + +/** + * G\xE8re les fonctions de couper/coller/copier de la fen\xEAtre 2d. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class CutCopyPasteManager { + /** La fen\xEAtre 2d \xE0 g\xE9rer. */ + protected MdlFille2d mdlFille2d_; + /** La sc\xE8ne permettant l'acc\xE8s sur les g\xE9om\xE9tries et les selections. */ + protected ZScene zScene_; + /** L'editeur de sc\xE8ne contenant les m\xE9thodes pour le d\xE9placement des g\xE9om\xE9tries. */ + protected MdlSceneEditor zSceneEditor_; + /** Copy action interface */ + protected EbliActionInterface copyAction_; + /** Cut action interface */ + protected EbliActionInterface cutAction_; + /** Paste action interface */ + protected EbliActionInterface pasteAction_; + /** Les mod\xE8les contennant les g\xE9om\xE9tries en cours de copy. */ + protected List<ZModeleGeometry> models_=new ArrayList<ZModeleGeometry>(); + /** Les points selectionn\xE9s pour la copy en mode sommet. */ + protected List<Coordinate> coordinates_=new ArrayList<Coordinate>(); + // Les gestionnaires d'\xE9v\xE9nements \\ + protected EventFrameManager eventManager1_; + protected EventSelectedGeometriesManager eventManager2_; + protected EventSelectedCalquesManager eventManager3_; + + /** + * Mise \xE0 jour correcte de bouton copier/coller/couper lors des diff\xE9rente + * manipulation de la fen\xEAtre. + */ + protected class EventFrameManager extends InternalFrameAdapter { + public boolean blockPaste_=false; + public boolean blockCopy_=false; + public boolean blockCut_=false; + + public void internalFrameActivated(InternalFrameEvent e) { + blockPaste_=false; + blockCopy_=false; + blockCut_=false; + updateButtons(); + } + + public void internalFrameDeactivated(InternalFrameEvent e) { + blockPaste_=true; + blockCopy_=true; + blockCut_=true; + updateButtons(); + } + } + + /** + * Mise \xE0 jour des boutons en fonction de la selection qui est faite dans les + * calques. + */ + protected class EventSelectedGeometriesManager implements ZSelectionListener { + public boolean blockPaste_=false; + public boolean blockCopy_=false; + public boolean blockCut_=false; + + public void selectionChanged(ZSelectionEvent _evt) { + blockCopy_=zScene_.isSelectionEmpty(); + blockCut_=zScene_.isSelectionEmpty()||zScene_.isAtomicMode(); + updateButtons(); + } + } + + /** + * Mise \xE0 jour de du bouton 'coller' en fonction du calque selectionn\xE9 dans + * l'arbre des calques. + */ + protected class EventSelectedCalquesManager implements TreeSelectionListener { + public boolean blockPaste_=false; + public boolean blockCopy_=false; + public boolean blockCut_=false; + + public void valueChanged(TreeSelectionEvent e) { + blockCut_=!(mdlFille2d_.getArbreCalqueModel().getSelectedCalque() instanceof ZCalqueEditable); + blockCopy_=blockCut_; + blockPaste_=blockCut_; + updateButtons(); + } + } + + public CutCopyPasteManager(MdlFille2d _mdlFille2d, MdlSceneEditor _zSceneEditor) { + mdlFille2d_=_mdlFille2d; + zScene_=_zSceneEditor.getScene(); + zSceneEditor_=_zSceneEditor; + copyAction_=EbliActionMap.getInstance().getAction("COPIER"); + cutAction_=EbliActionMap.getInstance().getAction("COUPER"); + pasteAction_=EbliActionMap.getInstance().getAction("COLLER"); + // Verification de la pr\xE9sence des actions + if (copyAction_==null||cutAction_==null||pasteAction_==null) + throw new IllegalArgumentException(FudaaLib + .getS("Les actions n\xE9c\xE9ssaire aux fonctionnalit\xE9s de couper/copier/coller n'ont pas \xE9t\xE9 trouv\xE9s.")); + // Mise en place des diff\xE9rentes \xE9coutes + eventManager1_=new EventFrameManager(); + eventManager2_=new EventSelectedGeometriesManager(); + eventManager3_=new EventSelectedCalquesManager(); + mdlFille2d_.addInternalFrameListener(eventManager1_); + zScene_.addSelectionListener(eventManager2_); + mdlFille2d_.getArbreCalqueModel().addTreeSelectionListener(eventManager3_); + // Initialisation des valeurs de blockage des boutons. + eventManager2_.selectionChanged(null); + eventManager3_.valueChanged(null); + } + + /** + * Active les boutons qui doivent l'\xEAtre. + */ + protected void updateButtons() { + copyAction_.setEnabled(!eventManager1_.blockCopy_&&!eventManager2_.blockCopy_&&!eventManager3_.blockCopy_); + pasteAction_.setEnabled((models_.size()>0||coordinates_.size()>0)&&!eventManager1_.blockPaste_&&!eventManager2_.blockPaste_&&!eventManager3_.blockPaste_); + cutAction_.setEnabled(!eventManager1_.blockCut_&&!eventManager2_.blockCut_&&!eventManager3_.blockCut_); + } + + public void copy() { + models_.clear(); + coordinates_.clear(); + if (zScene_.isAtomicMode()) { + // Copy en mode atomic \\ + int[] idxScene=zScene_.getLayerSelectionMulti().getIdxSelected(); + if (idxScene!=null) { + for(int i=0;i<idxScene.length;i++) { + // Extraction des informations sur la zone + GISZoneCollection zone=((ZModeleEditable) zScene_.getLayerForId(idxScene[i]).modeleDonnees()).getGeomData(); + GISAttributeInterface attrZ=zone.getAttributeIsZ(); + int idxAttrZ=-1; + if(attrZ!=null) + idxAttrZ=zone.getIndiceOf(zone.getAttributeIsZ()); + // La g\xE9om\xE9trie \xE0 traiter + CoordinateSequence seqGeom=zone.getCoordinateSequence(zScene_.sceneId2LayerId(idxScene[i])); + int[] selectedIdx=zScene_.getLayerSelectionMulti().getSelection(idxScene[i]).getSelectedIndex(); + // Extraction des coordonn\xE9es + for(int j=0;j<selectedIdx.length;j++) { + Coordinate coord=seqGeom.getCoordinate(selectedIdx[j]); + if(attrZ!=null) { + if(attrZ.isAtomicValue()) + coord.z=(Double) ((GISAttributeModel) zone.getValue(idxAttrZ, zScene_.sceneId2LayerId(idxScene[i]))).getObjectValueAt(selectedIdx[j]); + else + coord.z=(Double) zone.getValue(selectedIdx[j], idxAttrZ); + } + coordinates_.add(coord); + } + } + } + } + else { + // Copy en mode global \\ + int[] idxScene=zScene_.getLayerSelection().getSelectedIndex(); + if (idxScene!=null) { + // Tri des g\xE9om\xE9tries en fonction de leur calque d'origine + Map<ZCalqueEditable, List<Integer>> selectedGeom=new HashMap<ZCalqueEditable, List<Integer>>(); + for (int i=0; i<idxScene.length; i++) { + ZCalqueEditable calque=(ZCalqueEditable)zScene_.getLayerForId(idxScene[i]); + if (!selectedGeom.containsKey(calque)) + selectedGeom.put(calque, new ArrayList<Integer>()); + selectedGeom.get(calque).add(zScene_.sceneId2LayerId(idxScene[i])); + } + // Cr\xE9ation des mod\xE8les de cache + for (Map.Entry<ZCalqueEditable, List<Integer>> entry : selectedGeom.entrySet()) { + // Cr\xE9ation du mod\xE8le + ZModeleEditable modelSource=entry.getKey().getModelEditable(); + ZModeleEditable modelCache=null; + if (modelSource instanceof MdlModel2dMultiPoint) + modelCache=new MdlModel2dMultiPoint(null); + else if (modelSource instanceof MdlModel2dLine) + modelCache=new MdlModel2dLine(null); + modelCache.getGeomData().setAttributes(modelSource.getGeomData().getAttributes(), null); + // Remplissage du mod\xE8le + for (int i=0; i<entry.getValue().size(); i++) { + int idxGeom=zScene_.sceneId2LayerId(entry.getValue().get(i)); + Geometry geom=modelSource.getGeomData().getGeometry(idxGeom); + GISAttributeModel[] models=modelSource.getGeomData().getModels(); + Object[] data=new Object[models.length]; + for (int j=0; j<data.length; j++) + data[j]=models[j].getObjectValueAt(idxGeom); + modelCache.getGeomData().addGeometry(geom, data, null); + } + // Ajout du mod\xE8le de cache + models_.add(modelCache); + } + } + } + updateButtons(); + } + + public void cut() { + copy(); + zSceneEditor_.removeSelectedObjects(mdlFille2d_.getCmdMng()); + } + + public void paste() { + try { + CtuluCommandComposite cmd; + // Collage de g\xE9om\xE9trie + if (models_.size()>0) { + cmd=new CtuluCommandComposite(FudaaLib.getS("Coller des g\xE9om\xE9tries")); + for (int i=0; i<models_.size(); i++) { + int[] idxSource=new int[models_.get(i).getNombre()]; + for (int j=0; j<idxSource.length; j++) + idxSource[j]=j; + zSceneEditor_.moveGeometries(models_.get(i), idxSource, (ZCalqueEditable)zScene_.getCalqueActif(), cmd); + } + } + // Collage de points + else { + cmd=new CtuluCommandComposite(FudaaLib.getS("Coller des points")); + ZCalqueEditable calque=((ZCalqueEditable)zScene_.getCalqueActif()); + ZModeleEditable modele=(ZModeleEditable)calque.modeleDonnees(); + GISZoneCollection zone=modele.getGeomData(); + GISAttributeInterface attrZ=zone.getAttributeIsZ(); + int idxAttrZ=-1; + if (attrZ!=null) + idxAttrZ=zone.getIndiceOf(attrZ); + // Cr\xE9ation de la g\xE9om\xE9trie + CoordinateSequence coordSeq=new GISCoordinateSequenceFactory().create(coordinates_.toArray(new Coordinate[0])); + Geometry geom=null; + if (modele instanceof MdlModel2dMultiPoint) + geom=GISGeometryFactory.INSTANCE.createMultiPoint(coordSeq); + else if (modele instanceof MdlModel2dLine) { + boolean isFerme=coordSeq.getCoordinate(0).equals(coordSeq.getCoordinate(coordSeq.size()-1)); + if ((calque.canAddForme(DeForme.LIGNE_BRISEE)&&!isFerme)||!calque.canAddForme(DeForme.POLYGONE)) { + if (coordSeq.size()<2) + throw new IllegalArgumentException(FudaaLib.getS("Il faut au moins deux points pour coller en temps que polyligne.")); + geom=GISLib.toPolyligne(coordSeq); + } + else { + if (coordSeq.size()<2) + throw new IllegalArgumentException(FudaaLib.getS("Il faut au moins trois points pour coller en temps que polygone.")); + geom=GISLib.toPolygone(coordSeq); + } + } + // Cr\xE9ation de l'attribut z + Object[] data=new Object[zone.getNbAttributes()]; + if (attrZ!=null) + if (attrZ.isAtomicValue()) { + data[idxAttrZ]=new double[coordSeq.size()]; + for (int i=0; i<coordSeq.size(); i++) + ((double[])data[idxAttrZ])[i]=coordSeq.getOrdinate(i, 2); + } + else { + boolean allSame=true; + int i=0; + while (allSame&&++i<coordSeq.size()) + allSame=coordSeq.getOrdinate(i-1, 2)==coordSeq.getOrdinate(i, 2); + if (allSame) + data[idxAttrZ]=coordSeq.getOrdinate(0, 2); + else { + ZDialog dialog =new ZDialog(mdlFille2d_.getVisuPanel().getEditor().getFrame(), FudaaLib.getS("Choisissez un Z")); + dialog.setVisible(true); + data[idxAttrZ]=dialog.getValue(); + } + } + // Ajout de la g\xE9om\xE9trie + zone.addGeometry(geom, data, cmd); + } + if (mdlFille2d_.getCmdMng()!=null) + mdlFille2d_.getCmdMng().addCmd(cmd.getSimplify()); + } + catch (IllegalArgumentException _exp) { + mdlFille2d_.getVisuPanel().getController().getUI().error(_exp.getMessage()); + } + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/CutCopyPasteManager.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlFille2d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlFille2d.java 2009-01-21 16:06:25 UTC (rev 4389) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlFille2d.java 2009-01-21 17:30:56 UTC (rev 4390) @@ -9,11 +9,6 @@ import java.awt.Dimension; -import com.db4o.ObjectContainer; - -import com.memoire.bu.BuCutCopyPasteInterface; -import com.memoire.bu.BuUndoRedoInterface; - import org.fudaa.ctulu.CtuluCommandManager; import org.fudaa.ctulu.CtuluExportDataInterface; import org.fudaa.ctulu.CtuluUI; @@ -21,15 +16,17 @@ import org.fudaa.ctulu.ProgressionInterface; import org.fudaa.ctulu.image.CtuluImageImporter; import org.fudaa.ctulu.image.CtuluImageProducer; - import org.fudaa.ebli.calque.ZEbliFilleCalques; - import org.fudaa.fudaa.commun.impl.FudaaCommonImplementation; import org.fudaa.fudaa.commun.save.FudaaFilleVisuPersistence; import org.fudaa.fudaa.commun.save.FudaaSavable; import org.fudaa.fudaa.commun.save.FudaaSaveZipWriter; import org.fudaa.fudaa.sig.FSigResource; +import com.db4o.ObjectContainer; +import com.memoire.bu.BuCutCopyPasteInterface; +import com.memoire.bu.BuUndoRedoInterface; + /** * La fenetre interne vue 2D des donn\xE9es du modeleur. Elle construit le composant arbre de * calques {@link org.fudaa.ebli.calque.BArbreCalque}. La plupart des traitements est @@ -42,11 +39,15 @@ public class MdlFille2d extends ZEbliFilleCalques implements BuUndoRedoInterface, CtuluExportDataInterface, CtuluImageImporter, CtuluUndoRedoInterface, FudaaSavable, BuCutCopyPasteInterface { + /** Le gestionnaire de couper/coller/copier de la fen\xEAtre. */ + protected CutCopyPasteManager cutCopyPasteManager_; + public MdlFille2d(FudaaCommonImplementation _ui) { super(new MdlVisuPanel(_ui), _ui, null); setName("mdlMainFille"); setTitle(FSigResource.FSIG.getString("Vue 2D")); setPreferredSize(new Dimension(500, 400)); + cutCopyPasteManager_=new CutCopyPasteManager(this, (MdlSceneEditor) getMdlVisuPanel().getEditor().getSceneEditor()); } public void saveIn(final FudaaSaveZipWriter _writer, final ProgressionInterface _prog) { @@ -96,13 +97,20 @@ } - public void copy() {} + public void copy() { + cutCopyPasteManager_.copy(); + } - public void cut() {} + public void cut() { + cutCopyPasteManager_.cut(); + } public void duplicate() { getMdlVisuPanel().duplicate(); } - public void paste() {} + public void paste() { + cutCopyPasteManager_.paste(); + } + } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlSceneEditor.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlSceneEditor.java 2009-01-21 16:06:25 UTC (rev 4389) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlSceneEditor.java 2009-01-21 17:30:56 UTC (rev 4390) @@ -23,6 +23,7 @@ import javax.swing.JPanel; import org.fudaa.ctulu.CtuluCommandComposite; +import org.fudaa.ctulu.CtuluCommandContainer; import org.fudaa.ctulu.CtuluListSelection; import org.fudaa.ctulu.CtuluListSelectionInterface; import org.fudaa.ctulu.collection.CtuluCollection; @@ -141,125 +142,99 @@ } /** - * D\xE9place les g\xE9om\xE9tries s\xE9lectionn\xE9es dans le calque cible. + * D\xE9place des g\xE9om\xE9tries d'un mod\xE8le vers un calque. */ - public void moveInLayerSelectedGeometries() { - ZModeleGeometry mdldest=(ZModeleGeometry)((ZCalqueAffichageDonneesInterface)getScene().getCalqueActif()).modeleDonnees(); - if(mdldest==null) - return; - GISZoneCollection coldest=mdldest.getGeomData(); - if(coldest==null) - return; + public void moveGeometries(ZModeleGeometry _mldSource, int[] _idxSource, ZCalqueEditable _calqueDestination, CtuluCommandContainer _cmd) { + if(_mldSource==null||_idxSource==null||_calqueDestination==null) + throw new IllegalArgumentException(FudaaLib.getS("Aucun des param\xE8tres ne doit \xEAtre null.")); - int[] idxGeom=getScene().getLayerSelection().getSelectedIndex(); - Geometry[] geoms=new Geometry[idxGeom.length]; - for (int i=0; i<idxGeom.length; i++) { - geoms[i]=(Geometry)getScene().getObject(idxGeom[i]); - } + GISZoneCollection zoneSource=_mldSource.getGeomData(); + GISZoneCollection zoneDestination=_calqueDestination.getModelEditable().getGeomData(); + + Geometry[] geoms=new Geometry[_idxSource.length]; + for (int i=0; i<_idxSource.length; i++) + geoms[i]=zoneSource.getGeometry(_idxSource[i]); - final CtuluCommandComposite cmp = new CtuluCommandComposite(FudaaLib.getS("D\xE9placer dans calque cible")); + final CtuluCommandComposite cmp = new CtuluCommandComposite(FudaaLib.getS("D\xE9placement de g\xE9om\xE9tries")); // Controle sur le nombre de point minimum - ZCalqueEditable calque=(ZCalqueEditable)getScene().getCalqueActif(); - if(calque.canAddForme(DeForme.POLYGONE)&&!calque.canAddForme(DeForme.LIGNE_BRISEE)) - for (Geometry g : geoms) { - if (g.getNumPoints()<3) { - ui_.error(FudaaLib.getS("Vous ne pouvez pas d\xE9placer ces g\xE9om\xE9tries.\nUne au moins est constitu\xE9e de moins de 3 points.")); - return; - } + if (_calqueDestination.canAddForme(DeForme.POLYGONE)&&!_calqueDestination.canAddForme(DeForme.LIGNE_BRISEE)) { + int nbProbGeom=0; + for (Geometry g : geoms) + if (g.getNumPoints()<3) + nbProbGeom++; + if (nbProbGeom>0) { + ui_.error(FudaaLib.getS("Vous ne pouvez pas d\xE9placer ces g\xE9om\xE9tries.\n")+Integer.toString(nbProbGeom) + +FudaaLib.getS(" g\xE9om\xE9trie(s) a/ont moins de 3 points.")); + return; } - else if(calque.canAddForme(DeForme.LIGNE_BRISEE)) - for (Geometry g : geoms) { - if (g.getNumPoints()<2) { - ui_.error(FudaaLib.getS("Vous ne pouvez pas d\xE9placer ces g\xE9om\xE9tries.\nUne au moins est constitu\xE9e de moins de 2 points.")); - return; - } + } + else if (_calqueDestination.canAddForme(DeForme.LIGNE_BRISEE)) { + int nbProbGeom=0; + for (Geometry g : geoms) + if (g.getNumPoints()<2) + nbProbGeom++; + if (nbProbGeom>0) { + ui_.error(FudaaLib.getS("Vous ne pouvez pas d\xE9placer ces g\xE9om\xE9tries.\n")+Integer.toString(nbProbGeom) + +FudaaLib.getS(" g\xE9om\xE9trie(s) a/ont moins de 2 points.")); + return; } + } // Nouveaux objets - Geometry[] newGeom=new Geometry[idxGeom.length]; - Object[][] newData=new Object[idxGeom.length][]; + Geometry[] newGeom=new Geometry[_idxSource.length]; + Object[][] newData=new Object[_idxSource.length][]; // Ajout des nouveaux objets. - for (int i=0; i<idxGeom.length; i++) { - + for (int i=0; i<_idxSource.length; i++) { // Les attributs - Object[] datadest=new Object[coldest.getNbAttributes()]; - GISZoneCollection colsrc=((ZModeleGeometry)getScene().getLayerForId(idxGeom[i]).modeleDonnees()).getGeomData(); + Object[] datadest=new Object[zoneDestination.getNbAttributes()]; for (int iatt=0; iatt<datadest.length; iatt++) { - int idxAtt=colsrc.getIndiceOf(coldest.getAttribute(iatt)); + int idxAtt=zoneSource.getIndiceOf(zoneDestination.getAttribute(iatt)); if (idxAtt!=-1) { - datadest[iatt]=colsrc.getValue(idxAtt, getScene().sceneId2LayerId(idxGeom[i])); + datadest[iatt]=zoneSource.getValue(idxAtt,_idxSource[i]); // Les nouvelles g\xE9om\xE9tries sont modifi\xE9s, pas d'origine - if (colsrc.getAttribute(idxAtt)==GISAttributeConstants.ETAT_GEOM) + if (zoneSource.getAttribute(idxAtt)==GISAttributeConstants.ETAT_GEOM) datadest[iatt]=GISAttributeConstants.ATT_VAL_ETAT_MODI; } // Cas particuliers de mapping entre les attributs Z et z \\ else{ // On va essayer de renseigner le Z global de destination - if(coldest.getAttribute(iatt).getID().equals("Z")){ + if(zoneDestination.getAttribute(iatt).getID().equals("Z")){ // Cas o\xF9 un z atomique existe dans la source et qu'il est constant boolean identique=true; - int indexBathy=colsrc.getIndiceOf(GISAttributeConstants.BATHY); + int indexBathy=zoneSource.getIndiceOf(GISAttributeConstants.BATHY); if(indexBathy!=-1){ - GISAttributeModelDoubleArray data=(GISAttributeModelDoubleArray) colsrc.getValue(indexBathy, getScene().sceneId2LayerId(idxGeom[i])); + GISAttributeModelDoubleArray data=(GISAttributeModelDoubleArray) zoneSource.getValue(indexBathy, _idxSource[i]); identique=data.getMin()==data.getMax(); } if(identique&&indexBathy!=-1) - datadest[iatt]=((GISAttributeModelDoubleArray) colsrc.getValue(indexBathy, getScene().sceneId2LayerId(idxGeom[i]))).getObjectValueAt(0); + datadest[iatt]=((GISAttributeModelDoubleArray) zoneSource.getValue(indexBathy, _idxSource[i])).getObjectValueAt(0); // Dans le cas contraire, on demande \xE0 l'utilisateur else{ - // Utilisation d'une fen\xEAtre modale pour l'obtension du Z. - class myDialogModal extends JDialog implements ActionListener{ - private JComponent text_; - public myDialogModal(Frame _frame, String _title){ - super(_frame, _title, true); - // Position & resizable - setLocation(_frame.getLocation().x+_frame.getSize().width/2, _frame.getLocation().y+_frame.getSize().height/2); - setResizable(false); - // Contenu - JPanel container=new JPanel(new BuBorderLayout(2, 2)); - container.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); - text_=GISAttributeConstants.BATHY.getEditor().createEditorComponent(); - JButton ok=new JButton(MdlResource.MDL.getString("Valider")); - ok.addActionListener(this); - container.add(new BuLabel(MdlResource.MDL.getString("Valeur de Z :")), BuBorderLayout.WEST); - container.add(text_, BuBorderLayout.EAST); - container.add(ok, BuBorderLayout.SOUTH); - add(container); - pack(); - } - public void actionPerformed(ActionEvent e) { - setVisible(false); - dispose(); - } - public Double getValue(){ - return (Double) GISAttributeConstants.BATHY.getEditor().getValue(text_); - } - } // Pour le titre de la popup, on met le titre de la geom si possible String titre=MdlResource.MDL.getString("Nom : "); - if(colsrc.getIndiceOf(GISAttributeConstants.TITRE)!=-1) - titre+=(String) colsrc.getValue(colsrc.getIndiceOf(GISAttributeConstants.TITRE), getScene().sceneId2LayerId(idxGeom[i])); + if(zoneSource.getIndiceOf(GISAttributeConstants.TITRE)!=-1) + titre+=(String) zoneSource.getValue(zoneSource.getIndiceOf(GISAttributeConstants.TITRE), _idxSource[i]); else titre+=MdlResource.MDL.getString("sans nom"); // Instanciation de la popup - myDialogModal dialog =new myDialogModal(calquePanel_.getEditor().getFrame(), titre); + ZDialog dialog =new ZDialog(calquePanel_.getEditor().getFrame(), titre); dialog.setVisible(true); datadest[iatt]=dialog.getValue(); } } - else if(coldest.getAttribute(iatt)==GISAttributeConstants.BATHY){ + else if(zoneDestination.getAttribute(iatt)==GISAttributeConstants.BATHY){ // Recherche d'un attribut ayant pour ID 'Z' pour pouvoir utiliser sa valeur boolean found=false; int j=-1; - while(!found&&++j<colsrc.getNbAttributes()) - found=colsrc.getAttribute(j).getID().equals("Z"); + while(!found&&++j<zoneSource.getNbAttributes()) + found=zoneSource.getAttribute(j).getID().equals("Z"); if(found){ // Duplication de la valeur Object[] values=new Object[geoms[i].getNumPoints()]; for(int k=0;k<values.length;k++) - values[k]=colsrc.getValue(j, getScene().sceneId2LayerId(idxGeom[i])); + values[k]=zoneSource.getValue(j, _idxSource[i]); datadest[iatt]=values; } } @@ -270,12 +245,12 @@ newData[i]=datadest; // La g\xE9om\xE9trie - if (mdldest instanceof MdlModel2dMultiPoint) + if (_mldSource instanceof MdlModel2dMultiPoint) newGeom[i]=GISGeometryFactory.INSTANCE.createMultiPoint(geoms[i].getCoordinates()); - else if (mdldest instanceof MdlModel2dLine) { + else if (_mldSource instanceof MdlModel2dLine) { CoordinateSequence coordSeq=((GISCoordinateSequenceContainerInterface) geoms[i]).getCoordinateSequence(); boolean isFerme=coordSeq.getCoordinate(0).equals(coordSeq.getCoordinate(coordSeq.size()-1)); - if((calque.canAddForme(DeForme.LIGNE_BRISEE)&&!isFerme)||!calque.canAddForme(DeForme.POLYGONE)) + if((_calqueDestination.canAddForme(DeForme.LIGNE_BRISEE)&&!isFerme)||!_calqueDestination.canAddForme(DeForme.POLYGONE)) newGeom[i]=GISLib.toPolyligne(coordSeq); else newGeom[i]=GISLib.toPolygone(coordSeq); @@ -284,13 +259,40 @@ // Ajout des nouvelles g\xE9om\xE9tries for (int i=0; i<newGeom.length; i++) - coldest.addGeometry(newGeom[i], newData[i], cmp); - - // Suppression des anciens. - removeSelectedObjects(cmp); + zoneDestination.addGeometry(newGeom[i], newData[i], cmp); - if (mng_ != null) { - mng_.addCmd(cmp.getSimplify()); + if (_cmd != null) + _cmd.addCmd(cmp.getSimplify()); + } + + /** + * D\xE9place les g\xE9om\xE9tries s\xE9lectionn\xE9es dans le calque cible. + */ + public void moveInLayerSelectedGeometries() { + // Rassemblement des informations + Map<ZCalqueEditable, List<Integer>> selectedGeom=new HashMap<ZCalqueEditable, List<Integer>>(); + int[] idxScene=getScene().getLayerSelection().getSelectedIndex(); + if (idxScene!=null) { + // Tri des g\xE9om\xE9tries en fonction de leur calque + for (int i=0; i<idxScene.length; i++) { + ZCalqueEditable calque=(ZCalqueEditable) getScene().getLayerForId(idxScene[i]); + if(!selectedGeom.containsKey(calque)) + selectedGeom.put(calque, new ArrayList<Integer>()); + selectedGeom.get(calque).add(getScene().sceneId2LayerId(idxScene[i])); + } + ZCalqueEditable calqueDestination=(ZCalqueEditable)getScene().getCalqueActif(); + final CtuluCommandComposite cmp=new CtuluCommandComposite(FudaaLib.getS("D\xE9placer dans calque cible")); + // D\xE9placement des g\xE9om\xE9tries + for(Map.Entry<ZCalqueEditable, List<Integer>> entry: selectedGeom.entrySet()) { + int[] idxSource=new int[entry.getValue().size()]; + for(int j=0;j<entry.getValue().size();j++) + idxSource[j]=entry.getValue().get(j); + moveGeometries(entry.getKey().getModelEditable(), idxSource, calqueDestination, cmp); + } + // Suppression des anciens. + removeSelectedObjects(cmp); + if (mng_!=null) + mng_.addCmd(cmp.getSimplify()); } } Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/ZDialog.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/ZDialog.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/ZDialog.java 2009-01-21 17:30:56 UTC (rev 4390) @@ -0,0 +1,59 @@ +/* + * @creation 21 janv. 2009 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2009 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.fudaa.modeleur; + +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JPanel; + +import org.fudaa.ctulu.gis.GISAttributeConstants; + +import com.memoire.bu.BuBorderLayout; +import com.memoire.bu.BuLabel; + +/** + * Fen\xEAtre modale pour l'obtension d'un Z. + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class ZDialog extends JDialog implements ActionListener { + private JComponent text_; + + public ZDialog(Frame _frame, String _title) { + super(_frame, _title, true); + // Position & resizable + setLocation(_frame.getLocation().x+_frame.getSize().width/2, _frame.getLocation().y+_frame.getSize().height/2); + setResizable(false); + // Contenu + JPanel container=new JPanel(new BuBorderLayout(2, 2)); + container.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); + text_=GISAttributeConstants.BATHY.getEditor().createEditorComponent(); + JButton ok=new JButton(MdlResource.MDL.getString("Valider")); + ok.addActionListener(this); + container.add(new BuLabel(MdlResource.MDL.getString("Valeur de Z :")), BuBorderLayout.WEST); + container.add(text_, BuBorderLayout.EAST); + container.add(ok, BuBorderLayout.SOUTH); + add(container); + pack(); + } + + public void actionPerformed(ActionEvent e) { + setVisible(false); + dispose(); + } + + public Double getValue() { + return (Double)GISAttributeConstants.BATHY.getEditor().getValue(text_); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/ZDialog.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2009-01-22 10:07:06
|
Revision: 4391 http://fudaa.svn.sourceforge.net/fudaa/?rev=4391&view=rev Author: emmanuel_martin Date: 2009-01-22 10:07:02 +0000 (Thu, 22 Jan 2009) Log Message: ----------- Tache #132 "Export Rubar : Simplifier pour que l'utilisateur n'ait pas a rentrer l'extension" Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gui/CtuluFileChooserPanel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStCnFileFormat.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlProjectExportPanel.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gui/CtuluFileChooserPanel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gui/CtuluFileChooserPanel.java 2009-01-21 17:30:56 UTC (rev 4390) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gui/CtuluFileChooserPanel.java 2009-01-22 10:07:02 UTC (rev 4391) @@ -21,6 +21,11 @@ import javax.swing.filechooser.FileFilter; import javax.swing.text.BadLocationException; +import org.fudaa.ctulu.CtuluLib; +import org.fudaa.ctulu.CtuluLibFile; + +import com.memoire.bu.BuFileFilter; + import com.memoire.bu.BuBorderLayout; import com.memoire.bu.BuButton; import com.memoire.bu.BuLabel; @@ -28,9 +33,6 @@ import com.memoire.bu.BuTextField; import com.memoire.fu.FuLog; -import org.fudaa.ctulu.CtuluLib; -import org.fudaa.ctulu.CtuluLibFile; - /** * @author Fred Deniger * @version $Id: CtuluFileChooserPanel.java,v 1.8 2007-02-02 11:20:11 deniger Exp $ @@ -48,6 +50,9 @@ JTextField tf_; boolean writeMode_ = true; + + /** Le filtre selectionn\xE9. */ + protected FileFilter selectedFilter_; protected final int getFileSelectMode() { return fileSelectMode_; @@ -159,15 +164,23 @@ final int r = writeMode_ ? fileChooser.showSaveDialog(this) : fileChooser.showOpenDialog(this); if (r == JFileChooser.APPROVE_OPTION) { final File out = fileChooser.getSelectedFile(); - if ((initFile == null) || (!out.equals(initFile))) { - final String s = out.getAbsolutePath(); - tf_.setText(s); - } + selectedFilter_=fileChooser.getFileFilter(); + if(!selectedFilter_.accept(out)&&(selectedFilter_ instanceof BuFileFilter)) + tf_.setText(out.getAbsolutePath()+"."+((BuFileFilter)selectedFilter_).getFirstExt()); + else + tf_.setText(out.getAbsolutePath()); fileChooserAccepted(fileChooser); } } + /** + * Retourne le filtre selectionn\xE9. + */ + public FileFilter getSelectedFilter() { + return selectedFilter_; + } + protected void fileChooserAccepted(final CtuluFileChooser _fc){ } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStCnFileFormat.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStCnFileFormat.java 2009-01-21 17:30:56 UTC (rev 4390) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStCnFileFormat.java 2009-01-22 10:07:02 UTC (rev 4391) @@ -27,7 +27,7 @@ public RubarStCnFileFormat() { super(1); - extensions_ = new String[] { "st", "cn", "m" }; + extensions_ = new String[] { "st", "cn", "m", "sem" }; super.description_ = H2dResource.getS("Fichier de sections"); super.id_ = "RUBAR_ST"; super.nom_ = "Rubar st"; @@ -35,7 +35,7 @@ } public static BuFileFilter createStFilter() { - return new BuFileFilter(new String[] { "st" }, "Rubar st"); + return new BuFileFilter(new String[] { "st", "cn", "sem" }, "Rubar st"); } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlProjectExportPanel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlProjectExportPanel.java 2009-01-21 17:30:56 UTC (rev 4390) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlProjectExportPanel.java 2009-01-22 10:07:02 UTC (rev 4391) @@ -258,17 +258,7 @@ setErrorText(CtuluLib.getS("Donnez un nom au fichier d'exportation")); return false; } - boolean bextok=false; - for (int i=0; i<filters_.length; i++) { - if (filters_[i].accept(f)) { - selectedFilter_=filters_[i]; - bextok=true; - } - } - if (!bextok) { - setErrorText(TrResource.getS("Le fichier choisi a une extension inconnue")); - return false; - } + selectedFilter_=(BuFileFilter) pn_.getSelectedFilter(); if (CtuluLibFile.getExtension(f.getName())==null) { setErrorText(CtuluLib.getS("Le fichier choisi doit avoir une extension.")); return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2009-01-23 10:39:26
|
Revision: 4395 http://fudaa.svn.sourceforge.net/fudaa/?rev=4395&view=rev Author: emmanuel_martin Date: 2009-01-23 10:39:23 +0000 (Fri, 23 Jan 2009) Log Message: ----------- Commit de test ; r?\195?\169impl?\195?\169mentation de la tache #134 Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/gml/GISGMLZoneExporter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/telemac/io/SinusxWriter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/test/org/fudaa/dodico/telemac/TestJSinusx.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerExporter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerFilter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrMatisseConvertGUI.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/gml/GISGMLZoneExporter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/gml/GISGMLZoneExporter.java 2009-01-22 21:40:12 UTC (rev 4394) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/gml/GISGMLZoneExporter.java 2009-01-23 10:39:23 UTC (rev 4395) @@ -13,6 +13,12 @@ import java.io.IOException; import java.io.OutputStream; +import org.fudaa.ctulu.CtuluActivity; +import org.fudaa.ctulu.ProgressionInterface; +import org.fudaa.ctulu.ProgressionUpdater; +import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ctulu.gis.GISAttributeInterface; +import org.fudaa.ctulu.gis.GISZoneCollection; import org.geotools.data.DataStore; import org.geotools.data.FeatureWriter; import org.geotools.data.Transaction; @@ -25,17 +31,11 @@ import org.geotools.feature.SchemaException; import org.geotools.feature.type.BasicFeatureTypes; -import com.vividsolutions.jts.geom.Geometry; +import org.fudaa.ctulu.gis.GISDataModel; import com.memoire.fu.FuLog; +import com.vividsolutions.jts.geom.Geometry; -import org.fudaa.ctulu.CtuluActivity; -import org.fudaa.ctulu.ProgressionInterface; -import org.fudaa.ctulu.ProgressionUpdater; -import org.fudaa.ctulu.gis.GISAttributeConstants; -import org.fudaa.ctulu.gis.GISAttributeInterface; -import org.fudaa.ctulu.gis.GISZoneCollection; - /** * @author Fred Deniger * @version $Id: GISGMLZoneExporter.java,v 1.1.6.1 2008-03-28 14:59:28 bmarchan Exp $ @@ -54,7 +54,7 @@ private boolean useIdAsName_; - public AttributeType[] createAttributes(final GISZoneCollection _zone, final TObjectIntHashMap _attrIdx) { + public AttributeType[] createAttributes(final GISDataModel _zone, final TObjectIntHashMap _attrIdx) { final int attributeNb = _zone.getNbAttributes(); final TIntArrayList attribute = new TIntArrayList(attributeNb); // pour l'instant, les attributs atomiques (definis sur chaque sommets) ne sont pas @@ -107,12 +107,11 @@ * @throws SchemaException * @throws IllegalAttributeException */ - public void process(final ProgressionInterface _prog, final GISZoneCollection _zone, final DataStore _dest) + public void process(final ProgressionInterface _prog, final GISDataModel _zone, final DataStore _dest) throws IOException, SchemaException, IllegalAttributeException { out_ = null; store_ = _dest; process(_prog, _zone); - } /** @@ -133,10 +132,9 @@ } - private void process(final ProgressionInterface _prog, final GISZoneCollection _zone) throws IOException, + private void process(final ProgressionInterface _prog, final GISDataModel _zone) throws IOException, SchemaException, IllegalAttributeException { stop_ = false; - _zone.prepareExport(); final TObjectIntHashMap attIdx = new TObjectIntHashMap(_zone.getNbAttributes()); final AttributeType[] atts = createAttributes(_zone, attIdx); if (stop_) { @@ -160,7 +158,7 @@ final Feature feature = writer.next(); feature.setDefaultGeometry(_zone.getGeometry(i)); for (int j = 1; j < nbAttribute-1; j++) { - feature.setAttribute(j, _zone.getModel(attIdx.get(atts[j])).getObjectValueAt(i)); + feature.setAttribute(j, _zone.getValue(attIdx.get(atts[j]), i)); } // Enregistrement de l'index de la g\xE9om\xE9trie dans le fichier feature.setAttribute(nbAttribute-1, new Integer(i)); @@ -180,13 +178,14 @@ } - public FeatureType createFeatureType(final GISZoneCollection _zone, final AttributeType[] _atts) + public FeatureType createFeatureType(final GISDataModel _zone, final AttributeType[] _atts) throws SchemaException { + /* Changement de GISZoneCollection en GISDataModel, suppression des lignes dessous String name = _zone.getTitle(); if (name == null) { name = "zone"; - } - final FeatureType featureType = FeatureTypes.newFeatureType(_atts, name); + }*/ + final FeatureType featureType = FeatureTypes.newFeatureType(_atts, "zone"); return featureType; } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/telemac/io/SinusxWriter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/telemac/io/SinusxWriter.java 2009-01-22 21:40:12 UTC (rev 4394) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/telemac/io/SinusxWriter.java 2009-01-23 10:39:23 UTC (rev 4395) @@ -14,34 +14,29 @@ import java.util.Calendar; import java.util.Locale; -import com.vividsolutions.jts.geom.CoordinateSequence; -import com.vividsolutions.jts.geom.LineString; -import com.vividsolutions.jts.geom.LinearRing; -import com.vividsolutions.jts.geom.MultiPoint; -import com.vividsolutions.jts.geom.Point; -import com.vividsolutions.jts.geom.Polygon; - import org.fudaa.ctulu.CtuluActivity; import org.fudaa.ctulu.CtuluLibString; import org.fudaa.ctulu.ProgressionUpdater; import org.fudaa.ctulu.fileformat.FileFormatVersionInterface; -import org.fudaa.ctulu.gis.GISAttribute; import org.fudaa.ctulu.gis.GISAttributeConstants; -import org.fudaa.ctulu.gis.GISCollection; -import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; +import org.fudaa.ctulu.gis.GISCoordinateSequenceFactory; +import org.fudaa.ctulu.gis.GISDataModel; import org.fudaa.ctulu.gis.GISGeometry; import org.fudaa.ctulu.gis.GISLib; import org.fudaa.ctulu.gis.GISMultiPoint; import org.fudaa.ctulu.gis.GISPolygone; import org.fudaa.ctulu.gis.GISPolyligne; import org.fudaa.ctulu.gis.GISVisitorDefault; -import org.fudaa.ctulu.gis.GISZone; -import org.fudaa.ctulu.gis.GISZoneCollection; -import org.fudaa.ctulu.gis.GISZoneCollectionPoint; - import org.fudaa.dodico.fortran.FileOpWriterCharSimpleAbstract; import org.fudaa.dodico.h2d.resource.H2dResource; +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.LinearRing; +import com.vividsolutions.jts.geom.Point; +import com.vividsolutions.jts.geom.Polygon; + /** * @version $Id: SinusxWriter.java,v 1.24 2007-05-04 13:47:27 deniger Exp $ * @author Fred Deniger @@ -171,10 +166,10 @@ } protected void internalWrite(final Object _o) { - if (_o instanceof GISZone) { - writeZones((GISZone) _o); + if (_o instanceof GISDataModel[][]) { + writeZones((GISDataModel[][]) _o); } else { - donneesInvalides(_o); + donneesInvalides((GISDataModel[][]) _o); } } @@ -199,7 +194,7 @@ /** * @param _zones les zones a ecrire. */ - public void writeZones(final GISZone _zones) { + public void writeZones(final GISDataModel[][] _zones) { if (_zones == null) { analyze_.addFatalError(H2dResource.getS("Les donn\xE9es sont nulles")); return; @@ -210,7 +205,12 @@ progress_.setProgression(0); } up.majProgessionStateOnly(); - up.setValue(5, GISZone.getNbPoints(_zones)); + int nbPoints=0; + for(int i=0;i<_zones.length;i++) + for(int j=0;j<_zones[i].length;j++) + for(int k=0;k<_zones[i][j].getNumGeometries();k++) + nbPoints+=_zones[i][j].getGeometry(k).getNumPoints(); + up.setValue(5, nbPoints); final String bc = key_.getBlocCommentaire(); try { @@ -223,83 +223,77 @@ String spec; formate_.setPositivePrefix(pointPlus_); - final int max = _zones.getNumGeometries(); - for (int j = 0; j < max; j++) { - if (stop_) { + // Points + GISDataModel[] models=_zones[0]; + for (int j=0; j<models.length; j++) { + if (stop_) return; - } - // fermee= false; - spec = null; - final GISZoneCollection g = (GISZoneCollection) _zones.getGeometry(j); - if (g == null) { - continue; - } - int attName=g.getIndiceOf(GISAttributeConstants.TITRE); + final StringBuffer buf=new StringBuffer(50); + buf.append(bs_).append(' '); + buf.append(key_.getTypeSemis()); + writeToOut(buf.toString()); + writeEntete(j, "semis", null, false); + Coordinate[] coord=new Coordinate[models[j].getNumGeometries()]; + for (int k=0; k<coord.length; k++) + coord[k]=models[j].getGeometry(k).getCoordinate(); + writeCoordinateSequence(new GISCoordinateSequenceFactory().create(coord), up, false); + } + // Polylignes + models=_zones[1]; + for (int j=0; j<models.length; j++) { + final int nbPoly=models[j].getNumGeometries(); + int attName=models[j].getIndiceOf(GISAttributeConstants.TITRE); + for (int polyIdx=0; polyIdx<nbPoly; polyIdx++) { + if (stop_) + return; + final StringBuffer buf=new StringBuffer(); + buf.append(bs_).append(CtuluLibString.ESPACE); + final LineString geom=(LineString)models[j].getGeometry(polyIdx); + ((GISGeometry)geom).accept(identifieur); + final boolean ferme=identifieur.isClosed_; - // Les lignes et polygones - if (g.getDataStoreClass() == LineString.class || g.getDataStoreClass() == LinearRing.class) { - final int nbPoly = g.getNumGeometries(); - for (int polyIdx = 0; polyIdx < nbPoly; polyIdx++) { - final StringBuffer buf = new StringBuffer(); - buf.append(bs_).append(CtuluLibString.ESPACE); - final LineString geom = (LineString) g.getGeometryN(polyIdx); - ((GISGeometry) geom).accept(identifieur); - final boolean ferme = identifieur.isClosed_; - - final String nom; - if (attName==-1) - nom= ((ferme) ? "polygone" : "polyligne") + CtuluLibString.ESPACE + (j + 1) + "-" + (polyIdx + 1); - else - nom=(String)g.getValue(attName, polyIdx); - - if (identifieur.isNiveau_) { - buf.append(key_.getTypeCourbeNiveau()); - spec = formate_.format(geom.getCoordinateSequence().getOrdinate(0, 2)); + final String nom; + if (attName==-1) + nom=((ferme) ? "polygone":"polyligne")+CtuluLibString.ESPACE+(j+1)+"-"+(polyIdx+1); + else + nom=(String)models[j].getValue(attName, polyIdx); - } else { - buf.append(key_.getTypeCourbe()); - spec = courbeDefaut(key_.getCourbeNBIndic()); - } - writeToOut(buf.toString()); - writeEntete(j + polyIdx, nom, spec, ferme); - writeCoordinateSequence(geom.getCoordinateSequence(), up, ferme); + if (identifieur.isNiveau_) { + buf.append(key_.getTypeCourbeNiveau()); + spec=formate_.format(geom.getCoordinateSequence().getOrdinate(0, 2)); } - // DEBUG: Que veut dire ferme?? - // if(ent instanceof MNTPolygone) fermee=true; - } - - // Multipoints - else if (g.getDataStoreClass() == GISMultiPoint.class) { - final int nbPoly = g.getNumGeometries(); - for (int polyIdx = 0; polyIdx < nbPoly; polyIdx++) { - final StringBuffer buf = new StringBuffer(); - buf.append(bs_).append(CtuluLibString.ESPACE); - final GISMultiPoint geom = (GISMultiPoint) g.getGeometryN(polyIdx); - - final String nom; - if (attName==-1) - nom = "semis"+ CtuluLibString.ESPACE + (j + 1) + "-" + (polyIdx + 1); - else - nom=(String)g.getValue(attName, polyIdx); - - buf.append(key_.getTypeSemis()); - spec = null; - writeToOut(buf.toString()); - writeEntete(j + polyIdx, nom , spec, false); - writeCoordinateSequence(geom.getCoordinateSequence(), up, false); + else { + buf.append(key_.getTypeCourbe()); + spec=courbeDefaut(key_.getCourbeNBIndic()); } - // DEBUG: Que veut dire ferme?? - // if(ent instanceof MNTPolygone) fermee=true; + writeToOut(buf.toString()); + writeEntete(j+polyIdx, nom, spec, ferme); + writeCoordinateSequence(geom.getCoordinateSequence(), up, ferme); } - - // Points - else { - final StringBuffer buf = new StringBuffer(50); - buf.append(bs_).append(' '); + } + // Multipoint + models=_zones[2]; + for (int j=0; j<models.length; j++) { + int attName=models[j].getIndiceOf(GISAttributeConstants.TITRE); + final int nbPoly=models[j].getNumGeometries(); + for (int polyIdx=0; polyIdx<nbPoly; polyIdx++) { + if (stop_) + return; + final StringBuffer buf=new StringBuffer(); + buf.append(bs_).append(CtuluLibString.ESPACE); + final GISMultiPoint geom=(GISMultiPoint)models[j].getGeometry(polyIdx); + + final String nom; + if (attName==-1) + nom="semis"+CtuluLibString.ESPACE+(j+1)+"-"+(polyIdx+1); + else + nom=(String)models[j].getValue(attName, polyIdx); + buf.append(key_.getTypeSemis()); + spec=null; writeToOut(buf.toString()); - writeEntete(j, "semis", null, false); - writeCoordinateSequence(((GISZoneCollectionPoint) g), up, false); + writeEntete(j+polyIdx, nom, spec, false); + writeCoordinateSequence(geom.getCoordinateSequence(), up, false); } } } catch (final IOException e) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/test/org/fudaa/dodico/telemac/TestJSinusx.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/test/org/fudaa/dodico/telemac/TestJSinusx.java 2009-01-22 21:40:12 UTC (rev 4394) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/test/org/fudaa/dodico/telemac/TestJSinusx.java 2009-01-23 10:39:23 UTC (rev 4395) @@ -8,22 +8,28 @@ package org.fudaa.dodico.telemac; import java.io.File; +import java.util.ArrayList; +import java.util.List; import junit.framework.TestCase; -import com.vividsolutions.jts.geom.CoordinateSequence; - import org.fudaa.ctulu.CtuluIOOperationSynthese; +import org.fudaa.ctulu.gis.GISDataModel; +import org.fudaa.ctulu.gis.GISMultiPoint; import org.fudaa.ctulu.gis.GISPointMutable; import org.fudaa.ctulu.gis.GISPolyligne; import org.fudaa.ctulu.gis.GISZone; +import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ctulu.gis.GISZoneCollectionPoint; import org.fudaa.ctulu.gis.GISZoneCollectionPolygone; import org.fudaa.ctulu.gis.GISZoneCollectionPolyligne; - import org.fudaa.dodico.all.TestIO; import org.fudaa.dodico.telemac.io.SinusxFileFormat; +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.LinearRing; + /** * @version $Id: TestJSinusx.java,v 1.2 2007-06-29 15:10:32 deniger Exp $ * @author Fred Deniger @@ -123,7 +129,33 @@ assertNotNull(zones); f = File.createTempFile("testSinux", ".sx"); assertNotNull(f); - SinusxFileFormat.getInstance().getLastVersionInstance(null).write(f, zones, null); + + //# Conversion de la GISZone en GISDataModel[][] #\\ + // Tri des GISZoneCollection en fonction de leur type + List<GISDataModel> points=new ArrayList<GISDataModel>(); + List<GISDataModel> lignes=new ArrayList<GISDataModel>(); + List<GISDataModel> multipoints=new ArrayList<GISDataModel>(); + for (int i=0; i<zones.getNumGeometries(); i++) { + GISZoneCollection zone=(GISZoneCollection)zones.getGeometry(i); + // Les lignes et polygones + if (zone.getDataStoreClass()==LineString.class||zone.getDataStoreClass()==LinearRing.class) + lignes.add((GISDataModel)zone); + // Multipoints + else if (zone.getDataStoreClass()==GISMultiPoint.class) + multipoints.add((GISDataModel)zone); + // Points + else + points.add((GISDataModel)zone); + } + /* Case 0 : les points + * Case 1 : les polylignes et les polygones + * Case 2 : les multipoints. + */ + GISDataModel[][] gisDataModels=new GISDataModel[][]{points.toArray(new GISDataModel[0]), lignes.toArray(new GISDataModel[0]), + multipoints.toArray(new GISDataModel[0])}; + //# Fin de la conversion #\\ + + SinusxFileFormat.getInstance().getLastVersionInstance(null).write(f, gisDataModels, null); lecture(f); } catch (final Exception _e) { _e.printStackTrace(); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerExporter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerExporter.java 2009-01-22 21:40:12 UTC (rev 4394) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerExporter.java 2009-01-23 10:39:23 UTC (rev 4395) @@ -13,11 +13,6 @@ import java.util.List; import java.util.Set; -import org.geotools.data.FileDataStoreFactorySpi; - -import com.memoire.fu.FuEmptyArrays; -import com.memoire.fu.FuLog; - import org.fudaa.ctulu.CtuluAnalyze; import org.fudaa.ctulu.CtuluIOOperationSynthese; import org.fudaa.ctulu.CtuluLib; @@ -32,23 +27,20 @@ import org.fudaa.ctulu.gis.GISDataModelFilterAdapter; import org.fudaa.ctulu.gis.GISDataModelMultiAdapter; import org.fudaa.ctulu.gis.GISDataModelPointToMultiPointAdapter; -import org.fudaa.ctulu.gis.GISZone; -import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ctulu.gis.factory.GISExportDataStoreFactory; import org.fudaa.ctulu.gis.gml.GISGMLZoneExporter; import org.fudaa.ctulu.gis.mif.MIFDataStoreFactory; - import org.fudaa.dodico.dunes.io.DunesGEOFileFormat; import org.fudaa.dodico.rubar.io.RubarSEMFileFormat; import org.fudaa.dodico.rubar.io.RubarSEMWriterGISAdapter; import org.fudaa.dodico.rubar.io.RubarStCnFileFormat; import org.fudaa.dodico.telemac.io.SinusxFileFormat; - import org.fudaa.ebli.calque.ZCalqueAffichageDonneesInterface; - import org.fudaa.fudaa.commun.FudaaLib; -import org.fudaa.fudaa.sig.FSigResource; +import org.geotools.data.FileDataStoreFactorySpi; +import com.memoire.fu.FuLog; + /** * @author fred deniger * @version $Id: FSigLayerExporter.java,v 1.4 2007-06-14 12:01:22 deniger Exp $ @@ -103,7 +95,7 @@ return null; } } - final GISZoneCollection collect = _filter.getCollect(oi); + GISDataModel collect = _filter.getCollect(oi); exporter.process(_prog, collect, GISExportDataStoreFactory.createDataStore(dataStore_, file.toURL(), collect .getEnvelopeInternal(), true)); @@ -122,21 +114,24 @@ CtuluIOOperationSynthese exportTo(final FSigLayerFilter _filter, final CtuluUI _impl, final File _f, final ProgressionInterface _prog) { File f = CtuluLibFile.appendExtensionIfNeeded(_f, "sx"); - final GISZone z = new GISZone(); + GISDataModel[][] z = new GISDataModel[3][]; int nb = _filter.pointCq_.size(); + z[0]=new GISDataModel[_filter.pointCq_.size()]; for (int i = 0; i < nb; i++) { - final GISZoneCollection collec = _filter.getCollect(_filter.pointCq_.get(i)); - z.add(collec); + final GISDataModel collec = _filter.getCollect(_filter.pointCq_.get(i)); + z[0][i]=collec; } nb = _filter.polyCq_.size(); + z[1]=new GISDataModel[_filter.polyCq_.size()]; for (int i = 0; i < nb; i++) { - final GISZoneCollection collec = _filter.getCollect(_filter.polyCq_.get(i)); - z.add(collec); + final GISDataModel collec = _filter.getCollect(_filter.polyCq_.get(i)); + z[1][i]=collec; } nb = _filter.mlptsCq_.size(); + z[2]=new GISDataModel[_filter.mlptsCq_.size()]; for (int i = 0; i < nb; i++) { - final GISZoneCollection collec = _filter.getCollect(_filter.mlptsCq_.get(i)); - z.add(collec); + final GISDataModel collec = _filter.getCollect(_filter.mlptsCq_.get(i)); + z[2][i]=collec; } return SinusxFileFormat.getInstance().write(f, z, _prog); @@ -158,7 +153,7 @@ mdls.add(_filter.getCollect(_filter.mlptsCq_.get(i))); } for (int i = 0; i < _filter.polyCq_.size(); i++) { - final GISZoneCollection collec = _filter.getCollect(_filter.polyCq_.get(i)); + final GISDataModel collec = _filter.getCollect(_filter.polyCq_.get(i)); mdls.add(collec); } @@ -194,17 +189,18 @@ mdlsemis.add(GISDataModelFilterAdapter.buildAdapter(_filter.getCollect(_filter.mlptsCq_.get(i)), null)); } for (int i=0; i<_filter.polyCq_.size(); i++) { - GISZoneCollection col=_filter.getCollect(_filter.polyCq_.get(i)); - if (col.getNbGeometries()==0) continue; + GISDataModel col=_filter.getCollect(_filter.polyCq_.get(i)); + if (col.getNumGeometries()==0) + continue; int idxAtt=col.getIndiceOf(GISAttributeConstants.NATURE); if (idxAtt==-1) { - mdlautres.add(GISDataModelFilterAdapter.buildAdapter(_filter.getCollect(_filter.polyCq_.get(i)), - new GISAttributeInterface[]{GISAttributeConstants.TITRE})); + mdlautres.add(GISDataModelFilterAdapter.buildAdapter(_filter.getCollect(_filter.polyCq_.get(i)), + new GISAttributeInterface[]{GISAttributeConstants.TITRE})); } else { - GISDataModel mdl=GISDataModelFilterAdapter.buildAdapter(_filter.getCollect(_filter.polyCq_.get(i)), - new GISAttributeInterface[]{GISAttributeConstants.TITRE,GISAttributeConstants.NATURE}); - if (GISAttributeConstants.ATT_NATURE_CN.equals(col.getValue(idxAtt,0))) { + GISDataModel mdl=GISDataModelFilterAdapter.buildAdapter(_filter.getCollect(_filter.polyCq_.get(i)), + new GISAttributeInterface[]{GISAttributeConstants.TITRE, GISAttributeConstants.NATURE}); + if (GISAttributeConstants.ATT_NATURE_CN.equals(col.getValue(idxAtt, 0))) { mdlniv.add(mdl); } else if (GISAttributeConstants.ATT_NATURE_PF.equals(col.getValue(idxAtt,0))) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerFilter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerFilter.java 2009-01-22 21:40:12 UTC (rev 4394) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerFilter.java 2009-01-23 10:39:23 UTC (rev 4395) @@ -16,18 +16,13 @@ import org.fudaa.ctulu.CtuluIOOperationSynthese; import org.fudaa.ctulu.CtuluUI; import org.fudaa.ctulu.ProgressionInterface; -import org.fudaa.ctulu.gis.GISAttributeModel; +import org.fudaa.ctulu.gis.GISDataModel; +import org.fudaa.ctulu.gis.GISDataModelFilterAdapter; import org.fudaa.ctulu.gis.GISZoneCollection; -import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; -import org.fudaa.ctulu.gis.GISZoneCollectionMultiPoint; -import org.fudaa.ctulu.gis.GISZoneCollectionPoint; import org.fudaa.ebli.calque.BCalque; import org.fudaa.ebli.calque.BCalqueVisitor; import org.fudaa.ebli.calque.ZCalqueAffichageDonneesInterface; -import org.fudaa.ebli.calque.ZCalqueGeometry; import org.fudaa.ebli.calque.ZModeleGeometry; -import org.fudaa.ebli.calque.edition.ZModeleGeometryDefault; -import org.fudaa.ebli.calque.edition.ZModelePointEditable; import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.MultiPoint; @@ -40,10 +35,10 @@ */ public class FSigLayerFilter implements BCalqueVisitor { - final Set<BCalque> cqs_ = new HashSet<BCalque>(); - List<BCalque> pointCq_ = new ArrayList<BCalque>(); - List<BCalque> polyCq_ = new ArrayList<BCalque>(); - List<BCalque> mlptsCq_=new ArrayList<BCalque>(); + final Set<ZCalqueAffichageDonneesInterface> cqs_ = new HashSet<ZCalqueAffichageDonneesInterface>(); + List<ZCalqueAffichageDonneesInterface> pointCq_ = new ArrayList<ZCalqueAffichageDonneesInterface>(); + List<ZCalqueAffichageDonneesInterface> polyCq_ = new ArrayList<ZCalqueAffichageDonneesInterface>(); + List<ZCalqueAffichageDonneesInterface> mlptsCq_=new ArrayList<ZCalqueAffichageDonneesInterface>(); boolean bonlyVisible_=false; protected boolean onlySelectedGeometries_=false; @@ -74,13 +69,16 @@ return _o.getTitle(); } - final GISZoneCollection getCollect(final ZCalqueAffichageDonneesInterface _o) { - final GISZoneCollection geomData = ((ZModeleGeometry) _o.modeleDonnees()).getGeomData(); - geomData.prepareExport(); - return geomData; + final GISDataModel getCollect(final ZCalqueAffichageDonneesInterface _o) { + GISZoneCollection zone = ((ZModeleGeometry) _o.modeleDonnees()).getGeomData(); + zone.prepareExport(); + int[] idxAttributes=new int[zone.getNbAttributes()]; + for(int i=0;i<zone.getNbAttributes();i++) + idxAttributes[i]=i; + return new GISDataModelFilterAdapter(zone, idxAttributes, _o.getSelectedObjectInTable()); } - final GISZoneCollection getCollect(final Object _o) { + final GISDataModel getCollect(final Object _o) { return getCollect((ZCalqueAffichageDonneesInterface) _o); } @@ -99,40 +97,6 @@ onlySelectedGeometries_=_b; } - /** - * Retourne les donn\xE9es de la g\xE9om\xE9tries de _zone. - * retourne null si _idxGeom est invalide. - */ - private Object[] getData(int _idxGeom, GISZoneCollection _zone) { - Object[] data=null; - if (_idxGeom>=0&&_idxGeom<_zone.getNbGeometries()) { - GISAttributeModel[] models=_zone.getModels(); - data=new Object[models.length]; - for (int i=0; i<data.length; i++) - data[i]=models[i].getObjectValueAt(_idxGeom); - } - return data; - } - - /** - * Ajout les attributs n\xE9c\xE9ssaires \xE0 _destination puis ajout les g\xE9om\xE9tries de - * la _source \xE0 la _destination. - */ - private void addGeoms(int[] _idx, GISZoneCollection _source, GISZoneCollection _destination) { - _destination.setAttributes(_source.getAttributes(), null); - for(int i=0;i<_idx.length;i++) - _destination.addGeometry(_source.getGeometry(_idx[i]), getData(_idx[i], _source), null); - } - - /** - * Cr\xE9e un nouveau calque dupliquant les g\xE9om\xE9ries selectionn\xE9es dans celui pass\xE9 en param\xE8tre. - */ - private BCalque duplicateCalque(ZCalqueAffichageDonneesInterface _calque) { - ZModeleGeometryDefault model=new ZModeleGeometryDefault(null); - addGeoms(_calque.getSelectedObjectInTable(), ((ZModeleGeometry)_calque.modeleDonnees()).getGeomData(), model.getGeomData()); - return new ZCalqueGeometry(model); - } - public boolean visit(final BCalque _cq) { // Calque non trait\xE9 si invisible. if (bonlyVisible_&&!_cq.isVisible()) @@ -140,36 +104,17 @@ if (!cqs_.contains(_cq)&&_cq instanceof ZCalqueAffichageDonneesInterface &&((ZCalqueAffichageDonneesInterface)_cq).modeleDonnees() instanceof ZModeleGeometry) { - cqs_.add(_cq); - ZCalqueAffichageDonneesInterface calque=(ZCalqueAffichageDonneesInterface)_cq; - final ZModeleGeometry geom=(ZModeleGeometry)calque.modeleDonnees(); - if (onlySelectedGeometries_) { - if (!calque.isSelectionEmpty()) { - if (geom.getGeomData().getDataStoreClass().equals(Point.class)) { - ZModelePointEditable model=new ZModelePointEditable(new GISZoneCollectionPoint()); - addGeoms(calque.getSelectedObjectInTable(), geom.getGeomData(), model.getGeomData()); - pointCq_.add(new ZCalqueGeometry(model)); - } - else if (LineString.class.isAssignableFrom(geom.getGeomData().getDataStoreClass())) { - ZModeleGeometryDefault model=new ZModeleGeometryDefault(new GISZoneCollectionLigneBrisee()); - addGeoms(calque.getSelectedObjectInTable(), geom.getGeomData(), model.getGeomData()); - polyCq_.add(new ZCalqueGeometry(model)); - } - else if (MultiPoint.class.isAssignableFrom(geom.getGeomData().getDataStoreClass())) { - ZModeleGeometryDefault model=new ZModeleGeometryDefault(new GISZoneCollectionMultiPoint()); - addGeoms(calque.getSelectedObjectInTable(), geom.getGeomData(), model.getGeomData()); - mlptsCq_.add(new ZCalqueGeometry(model)); - } - } - } - else { + ZCalqueAffichageDonneesInterface calque=(ZCalqueAffichageDonneesInterface)_cq; + ZModeleGeometry geom=(ZModeleGeometry)calque.modeleDonnees(); + cqs_.add(calque); + if (!onlySelectedGeometries_||!calque.isSelectionEmpty()) { if (geom.getGeomData().getDataStoreClass().equals(Point.class)) - pointCq_.add(_cq); + pointCq_.add(calque); else if (LineString.class.isAssignableFrom(geom.getGeomData().getDataStoreClass())) - polyCq_.add(_cq); + polyCq_.add(calque); else if (MultiPoint.class.isAssignableFrom(geom.getGeomData().getDataStoreClass())) - mlptsCq_.add(_cq); + mlptsCq_.add(calque); } } return true; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrMatisseConvertGUI.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrMatisseConvertGUI.java 2009-01-22 21:40:12 UTC (rev 4394) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrMatisseConvertGUI.java 2009-01-23 10:39:23 UTC (rev 4395) @@ -11,6 +11,8 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; +import java.util.ArrayList; +import java.util.List; import javax.swing.BorderFactory; import javax.swing.JTextField; @@ -20,6 +22,8 @@ import javax.swing.event.DocumentListener; import com.memoire.bu.*; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.LinearRing; import org.fudaa.ctulu.CtuluActivity; import org.fudaa.ctulu.CtuluIOOperationSynthese; @@ -28,7 +32,10 @@ import org.fudaa.ctulu.CtuluLibString; import org.fudaa.ctulu.CtuluProgressionBarAdapter; import org.fudaa.ctulu.ProgressionInterface; +import org.fudaa.ctulu.gis.GISDataModel; +import org.fudaa.ctulu.gis.GISMultiPoint; import org.fudaa.ctulu.gis.GISZone; +import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ctulu.gui.CtuluDialogPanel; import org.fudaa.ctulu.gui.CtuluLibDialog; @@ -234,7 +241,33 @@ progress_.setDesc(CtuluLib.getS("Export")); final SinusxWriter sxW = new SinusxWriter(SinusxFileFormat.getInstance()); current_ = sxW; - sxW.write(mnt_, sx, progress_); + + //# Conversion de la GISZone en GISDataModel[][] #\\ + // Tri des GISZoneCollection en fonction de leur type + List<GISDataModel> points=new ArrayList<GISDataModel>(); + List<GISDataModel> lignes=new ArrayList<GISDataModel>(); + List<GISDataModel> multipoints=new ArrayList<GISDataModel>(); + for (int i=0; i<mnt_.getNumGeometries(); i++) { + GISZoneCollection zone=(GISZoneCollection)mnt_.getGeometry(i); + // Les lignes et polygones + if (zone.getDataStoreClass()==LineString.class||zone.getDataStoreClass()==LinearRing.class) + lignes.add((GISDataModel)zone); + // Multipoints + else if (zone.getDataStoreClass()==GISMultiPoint.class) + multipoints.add((GISDataModel)zone); + // Points + else + points.add((GISDataModel)zone); + } + /* Case 0 : les points + * Case 1 : les polylignes et les polygones + * Case 2 : les multipoints. + */ + GISDataModel[][] gisDataModels=new GISDataModel[][]{points.toArray(new GISDataModel[0]), lignes.toArray(new GISDataModel[0]), + multipoints.toArray(new GISDataModel[0])}; + //# Fin de la conversion #\\ + + sxW.write(gisDataModels, sx, progress_); CtuluLibDialog.showMessage(btCharger_, "OK", TrResource.getS("Export r\xE9ussie")); progress_.reset(); btStop_.setEnabled(false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bma...@us...> - 2009-01-23 16:12:48
|
Revision: 4396 http://fudaa.svn.sourceforge.net/fudaa/?rev=4396&view=rev Author: bmarchan Date: 2009-01-23 16:12:37 +0000 (Fri, 23 Jan 2009) Log Message: ----------- Task#36: Possibilit?\195?\169 d'accrocher les sommets des g?\195?\169om?\195?\169tries lors de la cr?\195?\169ation de g?\195?\169om?\195?\169trie ou lors du calcul de distance. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonnees.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesAbstract.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesInterface.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZEbliCalquePanelController.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZEbliCalquesPanel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonnees.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonneesVide.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonnesAbstract.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleFlecheForGrille.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleGeometry.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleStatiquePoint.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZScene.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueDistanceInteraction.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueEditionInteraction.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditionAttibutesContainer.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditionAttributesDataI.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleGeometryDefault.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/commun/EbliListeSelectionMulti.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/meshviewer/model/MvEdgeModelDefault.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/reflux/RefluxMaillage.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/reflux/RefluxModeleNoeud.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/FSigLineSingleModel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSIgImageWizartStepCalageUI.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/data/TrSiFlecheModel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/post/TrIsoModelEltDataAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/post/TrPostFlecheModel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/reflux/TrBcNodeLayer.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrTelemacSourceModel.java Added Paths: ----------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueCatchInteraction.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCatchEvent.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCatchListener.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZSceneSelection.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/ressource/curseur_accroche.gif Property Changed: ---------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonneesVide.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonnesAbstract.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleFlecheForGrille.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleStatiquePoint.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueEditionInteraction.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditionAttibutesContainer.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditionAttributesDataI.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/commun/EbliListeSelectionMulti.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/meshviewer/model/MvEdgeModelDefault.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/reflux/RefluxMaillage.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/reflux/RefluxModeleNoeud.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/FSigLineSingleModel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSIgImageWizartStepCalageUI.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/data/TrSiFlecheModel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/post/TrIsoModelEltDataAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/post/TrPostFlecheModel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/reflux/TrBcNodeLayer.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrTelemacSourceModel.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonnees.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonnees.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonnees.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -230,16 +230,16 @@ * * @param _pt coordonnees reelles * @param _tolerance - * @return la liste des indexs selectionnes (ou null si aucune selection) + * @return la liste des index des objets selectionnes (ou null si aucune selection) */ public abstract CtuluListSelection selection(GrPoint _pt, int _tolerance); /** - * renvoie la liste des points selectionnes par le polygone <code>_poly</code>. + * renvoie la liste des objets selectionnes par le polygone <code>_poly</code>. * * @param _poly le polygone EN coordonnees reelles * @param _mode TODO - * @return la liste des indexs ( ou null si aucun selectionne). + * @return la liste des indexs des objets selectionn\xE9s ( ou null si aucun selectionne). */ public abstract CtuluListSelection selection(LinearRing _poly, int _mode); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesAbstract.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesAbstract.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesAbstract.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -29,6 +29,7 @@ import org.fudaa.ebli.controle.BSelecteurLineModel; import org.fudaa.ebli.geometrie.GrBoite; import org.fudaa.ebli.geometrie.GrMorphisme; +import org.fudaa.ebli.geometrie.GrPoint; import org.fudaa.ebli.palette.BPalettePlage; import org.fudaa.ebli.palette.BPalettePlageAbstract; import org.fudaa.ebli.palette.BPalettePlageDiscret; @@ -292,6 +293,10 @@ public EbliListeSelectionMultiInterface getLayerSelectionMulti() { return null; } + + public EbliListeSelectionMultiInterface selectionMulti(GrPoint _ptReel, int _tolerancePixel, boolean _inDepth) { + return null; + } public BPalettePlageInterface getPaletteCouleur() { return paletteCouleur_; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesInterface.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesInterface.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueAffichageDonneesInterface.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -129,6 +129,19 @@ boolean changeSelection(LinearRing[] _p, int _action, int _mode); /** + * Retourne les indices de selection des sous objets selectionn\xE9s pour le point donn\xE9, sous la forme d'une liste de selection. + * La selection s'effectue du point le plus au dessus vers le point le plus en dessous.<p> + * Le plus souvent les sous objets selectionn\xE9s sont des sommets (points). + * + * @param _ptReel Le point donn\xE9 pour la selection. + * @param _tolerancePixel La tol\xE9rance, en pixels. + * @param _inDepth Si faux, la recherche s'arrete a la premi\xE8re occurence trouv\xE9e. Sinon, la recherche continue pour tous les + * points suceptibles d'etre selectionn\xE9s. + * @return Les indices des sous objets selectionn\xE9s, ou null si aucune selection. + */ + EbliListeSelectionMultiInterface selectionMulti(GrPoint _ptReel, int _tolerancePixel, boolean _inDepth); + + /** * @return la ligne repr\xE9sentant la s\xE9lection courant. null si s\xE9lection non adequate */ LineString getSelectedLine(); Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueCatchInteraction.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueCatchInteraction.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueCatchInteraction.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -0,0 +1,250 @@ +/* + * @file BCalqueSuiviSourisInteraction.java + * @creation 1998-10-16 + * @modification $Date: 2006-09-19 14:55:46 $ + * @license GNU General Public License 2 + * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail de...@fu... + */ +package org.fudaa.ebli.calque; + +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.util.HashSet; + +import org.fudaa.ebli.geometrie.GrPoint; +/** + * Un calque pour accrocher les objets de la scene. Si la scene n'existe pas, pas d'objets accroch\xE9. + * Des modificateurs permettent l'accrochage ou non (key SHIFT). + * + * @author Bertrand Marchand + * @version $Id$ + */ +public class ZCalqueCatchInteraction extends BCalqueInteraction implements + MouseMotionListener, MouseListener, KeyListener { + + /** La tol\xE9rance en pixels pour l'accrochage */ + private static int tolerancePixel_=4; + /** La scene */ + private ZScene scene_; + /** Un point temporaire remis a jour a chaque mouvement de souris */ + private GrPoint ptTmp_=new GrPoint(); + /** True si le mode d'accrochage est actif */ + private boolean bcatch_=true; + /** Les listeners de l'accrochage */ + private HashSet<ZCatchListener> listeners_=new HashSet<ZCatchListener>(); + /** La liste de selection des points d'accrochage */ + private ZSceneSelection selAccroch_=null; + /** Le tableau des indices de g\xE9om\xE9tries accroch\xE9es */ + private int[] idxGeoms_; + /** Le tableau des indices de sommets accroch\xE9s */ + private int[] idxVertices_; + /** L'indice sur les indices de g\xE9om\xE9tries */ + private int iidxGeom_=-1; + /** L'indice sur les indices de vertices */ + private int iidxVertex_=-1; + + public ZCalqueCatchInteraction() {} + + /** + * Methode inactive. + */ + public void mouseDown(final MouseEvent _evt){} + + /** + * Methode inactive. + */ + public void mouseEntered(final MouseEvent _evt){} + + /** + * Methode inactive. + */ + public void mouseExited(final MouseEvent _evt){} + + /** + * Methode inactive. + */ + public void mousePressed(final MouseEvent _evt){} + + /** + * Methode inactive. + */ + public void mouseReleased(final MouseEvent _evt){} + + /** + * Methode inactive. + */ + public void mouseUp(final MouseEvent _evt){} + + /** + * Methode inactive. + */ + public void mouseClicked(final MouseEvent _evt){} + + /** + * Appelle la methode <I>mouseMoved</I>. + */ + public void mouseDragged(final MouseEvent _evt){ + mouseMoved(_evt); + } + + /** + * Envoi d'un evenement <I>ZCatchEvent</I> (en mode non gele). + */ + public void mouseMoved(final MouseEvent _evt){ + ptTmp_.x_=_evt.getX(); + ptTmp_.y_=_evt.getY(); + + if (!isGele() && scene_!=null && bcatch_) { + mouseMoved(ptTmp_); + } + } + + /** + * Recherche les points a accrocher. Propose par defaut le plus en avant. + * @param _pt + */ + public void mouseMoved(GrPoint _pt) { + if (scene_==null) return; + + int idxGeomOld=-1; + int idxVertexOld=-1; + if (iidxGeom_!=-1) { + idxGeomOld=idxGeoms_[iidxGeom_]; + idxVertexOld=idxVertices_[iidxVertex_]; + } + + selAccroch_=scene_.selection(_pt.applique(getVersReel()), tolerancePixel_); + idxGeoms_=selAccroch_.getIdxSelected(); + + int igeom=-1; + int ivertex=-1; + + if (idxGeoms_.length!=0) { + igeom=0; + // Recherche dans le nouveau tableau de l'indice. + if (idxGeomOld!=-1) { + for (int i=0; i<idxGeoms_.length; i++) { + if (idxGeoms_[i]==idxGeomOld) { + igeom=i; + break; + } + } + } + idxVertices_=selAccroch_.getSelection(idxGeoms_[igeom]).getSelectedIndex(); + if (idxVertices_.length!=0) { + ivertex=0; + } + // Recherche dans le nouveau tableau de l'indice. + if (idxVertexOld!=-1) { + for (int i=0; i<idxVertices_.length; i++) { + if (idxVertices_[i]==idxGeomOld) { + ivertex=i; + break; + } + } + } + } + + if (ivertex==-1) { + if (iidxVertex_!=-1) { + fireCatchEvent(ZCatchEvent.UNCAUGHT,0,0); + } + } + else if (iidxVertex_==-1) { + if (ivertex!=-1) { + fireCatchEvent(ZCatchEvent.CAUGHT,idxGeoms_[igeom],idxVertices_[ivertex]); + } + } + else if (idxGeomOld!=idxGeoms_[igeom] || idxVertexOld!=idxVertices_[ivertex]) { + fireCatchEvent(ZCatchEvent.UNCAUGHT,0,0); + fireCatchEvent(ZCatchEvent.CAUGHT,idxGeoms_[igeom],idxVertices_[ivertex]); + } + + iidxGeom_=igeom; + iidxVertex_=ivertex; + } + + /** + * Definit la tol\xE9rence d'accrocahge. + * @param _tolPixel La tolerance, en pixel. + */ + public void setTolerance(int _tolPixel) { + tolerancePixel_=_tolPixel; + } + + /** + * Definit la scene. + * @param _scn La scene. + */ + public void setScene(ZScene _scn) { + scene_=_scn; + } + + public void addCatchListener(ZCatchListener _l) { + listeners_.add(_l); + } + + public void removeCatchListener(ZCatchListener _l) { + listeners_.remove(_l); + } + + /** + * Notification des listeners. + * @param _type Le type d'evenement. + * @param _pt Le point d'accrochage. + */ + public void fireCatchEvent(int _type, int _idxGeom, int _idxVertex) { + ZCatchEvent evt=new ZCatchEvent(this,_type,selAccroch_,_idxGeom,_idxVertex); + for (ZCatchListener l : listeners_) { + l.catchChanged(evt); + } + } + + /** + * Gere le SHIFT et le TAB.<p> + * SHIFT : pour inactiver le mode d'accrochage, + * TAB : Pour switcher de point accroch\xE9. + */ + public void keyPressed(KeyEvent e) { + if (e.getKeyCode()==KeyEvent.VK_SHIFT) { + bcatch_=false; + fireCatchEvent(ZCatchEvent.UNCAUGHT,0,0); + } + if (e.getKeyCode()==KeyEvent.VK_N) { + if (selAccroch_.getNbSelectedItem()>1) { + iidxVertex_++; + if (iidxVertex_==idxVertices_.length) { + iidxVertex_=0; + iidxGeom_++; + if (iidxGeom_==idxGeoms_.length) { + iidxGeom_=0; + } + idxVertices_=selAccroch_.getSelection(idxGeoms_[iidxGeom_]).getSelectedIndex(); + } + fireCatchEvent(ZCatchEvent.CAUGHT, idxGeoms_[iidxGeom_],idxVertices_[iidxVertex_]); + } + } + } + + /** + * Gere le SHIFT.<p> + * SHIFT : pour reactiver le mode d'accrochage + */ + public void keyReleased(KeyEvent e) { + if (e.getKeyCode()==KeyEvent.VK_SHIFT) { + bcatch_=true; + iidxVertex_=-1; + iidxGeom_=-1; + mouseMoved(ptTmp_); + } + } + + /** + * Methode inactive. + */ + public void keyTyped(KeyEvent e) {} +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueCatchInteraction.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -198,7 +198,7 @@ if (!isSelectable()) return false; if (isAtomicMode_) { - final EbliListeSelectionMulti l = selectionMulti(_pt, _tolerancePixel); + final EbliListeSelectionMulti l = selectionMulti(_pt, _tolerancePixel, false); changeSelectionMulti(l, _action); if ((l == null) || (l.isEmpty())) { return false; @@ -790,42 +790,44 @@ return r; } - /** - * Renvoie la liste des objets selectionnees pour le point <code>_pt</code> avec pour tolerance - * <code>_tolerance</code>. - * - * @param _pt - * @param _tolerance - * @return la liste des indexs selectionnes (ou null si aucune selection) - */ - public EbliListeSelectionMulti selectionMulti(final GrPoint _pt, final int _tolerance) { + public EbliListeSelectionMulti selectionMulti(final GrPoint _ptReel, final int _tolerancePixel, boolean _inDepth) { final GrMorphisme versReel = getVersReel(); GrBoite bClip = getDomaine(); - if (bClip == null || (!bClip.contientXY(_pt)) && (bClip.distanceXY(_pt) > _tolerance)) { + if (bClip == null || (!bClip.contientXY(_ptReel)) && (bClip.distanceXY(_ptReel) > _tolerancePixel)) { return null; } - final double distanceReel = GrMorphisme.convertDistanceXY(versReel, _tolerance); + final double distanceReel = GrMorphisme.convertDistanceXY(versReel, _tolerancePixel); bClip = getClipReel(getGraphics()); final GrPoint p = new GrPoint(); final GrBoite btLigne = new GrBoite(); + + EbliListeSelectionMulti sel=null; for (int i = modele_.getNombre() - 1; i >= 0; i--) { if (!modele_.isGeometryVisible(i)) continue; modele_.getDomaineForGeometry(i, btLigne); - if (btLigne.contientXY(_pt) || btLigne.distanceXY(_pt) < distanceReel) { + if (btLigne.contientXY(_ptReel) || btLigne.distanceXY(_ptReel) < distanceReel) { for (int j = modele_.getNbPointForGeometry(i) - 1; j >= 0; j--) { modele_.point(p, i, j); - if (bClip.contientXY(p) && (p.distanceXY(_pt) < distanceReel)) { - final EbliListeSelectionMulti r = new EbliListeSelectionMulti(1); - r.set(i, j); - return r; + if (bClip.contientXY(p) && (p.distanceXY(_ptReel) < distanceReel)) { + if (sel==null) + sel = new EbliListeSelectionMulti(1); + sel.add(i, j); + if (!_inDepth) + return sel; } } } } - return null; + return sel; } + /** + * Renvoie sous forme de liste de selection les sommets selectionnes pour la polyligne <code>_poly</code>. + * + * @param _poly Le point pour la selection + * @return la liste des indexs selectionnes (ou null si aucune selection) + */ public EbliListeSelectionMulti selectionMulti(final LinearRing _poly) { if (modele_.getNombre() == 0 || !isVisible()) { return null; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -226,7 +226,7 @@ if (!isSelectable()) return false; if (isAtomicMode_) { - final EbliListeSelectionMulti l = selectionMulti(_pt, _tolerancePixel); + final EbliListeSelectionMulti l = selectionMulti(_pt, _tolerancePixel, false); changeSelectionMulti(l, _action); if ((l == null) || (l.isEmpty())) { return false; @@ -875,40 +875,36 @@ return r; } - /** - * Renvoie la liste des objets selectionnees pour le point <code>_pt</code> avec pour tolerance - * <code>_tolerance</code>. - * - * @param _pt - * @param _tolerance - * @return la liste des indexs selectionnes (ou null si aucune selection) - */ - public EbliListeSelectionMulti selectionMulti(final GrPoint _pt, final int _tolerance) { + public EbliListeSelectionMulti selectionMulti(final GrPoint _ptReel, final int _tolerancePixel, boolean _inDepth) { final GrMorphisme versReel = getVersReel(); GrBoite bClip = getDomaine(); - if (bClip == null || (!bClip.contientXY(_pt)) && (bClip.distanceXY(_pt) > _tolerance)) { + if (bClip == null || (!bClip.contientXY(_ptReel)) && (bClip.distanceXY(_ptReel) > _tolerancePixel)) { return null; } - final double distanceReel = GrMorphisme.convertDistanceXY(versReel, _tolerance); + final double distanceReel = GrMorphisme.convertDistanceXY(versReel, _tolerancePixel); bClip = getClipReel(getGraphics()); final GrPoint p = new GrPoint(); final GrBoite btLigne = new GrBoite(); + + EbliListeSelectionMulti sel=null; for (int i = modele_.getNombre() - 1; i >= 0; i--) { if (!modele_.isGeometryVisible(i)) continue; modele_.getDomaineForGeometry(i, btLigne); - if (btLigne.contientXY(_pt) || btLigne.distanceXY(_pt) < distanceReel) { + if (btLigne.contientXY(_ptReel) || btLigne.distanceXY(_ptReel) < distanceReel) { for (int j = modele_.getNbPointForGeometry(i) - 1; j >= 0; j--) { modele_.point(p, i, j); - if (bClip.contientXY(p) && (p.distanceXY(_pt) < distanceReel)) { - final EbliListeSelectionMulti r = new EbliListeSelectionMulti(1); - r.set(i, j); - return r; + if (bClip.contientXY(p) && (p.distanceXY(_ptReel) < distanceReel)) { + if (sel==null) + sel = new EbliListeSelectionMulti(1); + sel.add(i, j); + if (!_inDepth) + return sel; } } } } - return null; + return sel; } public EbliListeSelectionMulti selectionMulti(final LinearRing _poly) { @@ -953,7 +949,7 @@ } return r; } - + /** * D\xE9finit que les modifications d'objets auront lieu en mode atomique. * @param _new true : Modifications en mode atomique. Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCatchEvent.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCatchEvent.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCatchEvent.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -0,0 +1,50 @@ +/* + * @creation 21 janv. 2009 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2009 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.ebli.calque; + +import java.util.EventObject; + +import org.fudaa.ebli.geometrie.GrPoint; + +/** + * Un evenement envoy\xE9 par le calque d'interaction d'accrochage si un sommet de g\xE9om\xE9trie a \xE9t\xE9 + * accroch\xE9 ou d\xE9ccroch\xE9 {@link ZCalqueCatchInteraction}. + * @author Bertrand Marchand + * @version $Id:$ + */ +public class ZCatchEvent extends EventObject { + /** Le type d'evement pour un accrochage */ + public static int CAUGHT=0; + /** Le type d'evenement pour un d\xE9ccrochage */ + public static int UNCAUGHT=1; + + /** Le type de l'evenement */ + public int type; + /** La liste de selection */ + public ZSceneSelection selection; + /** L'indice de g\xE9ometrie accroch\xE9e */ + public int idxGeom; + /** L'indice de sommet accroch\xE9 */ + public int idxVertex; + + /** + * Construction d'un evenement d'a&ccrochage + * @param _src Le calque ayant d\xE9clench\xE9 cet evenement. + * @param _type Le type de l'evenement + * @param _selection La liste de selection + * @param _idxGeom L'indice de g\xE9ometrie accroch\xE9e + * @param _idxVertex L'indice de sommet accroch\xE9 + */ + public ZCatchEvent(Object _src, int _type, ZSceneSelection _selection, int _idxGeom, int _idxVertex) { + super(_src); + type=_type; + selection=_selection; + idxGeom=_idxGeom; + idxVertex=_idxVertex; + } +} \ No newline at end of file Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCatchEvent.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCatchListener.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCatchListener.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCatchListener.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -0,0 +1,23 @@ +/* + * @creation 21 janv. 2009 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2009 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.ebli.calque; + +/** + * Une interface qu'un calque d'interaction doit implementer pour gerer l'accrochage sur des + * objets. + * @author Bertrand Marchand + * @version $Id:$ + */ +public interface ZCatchListener { + + /** + * L'accrochage a chang\xE9. Par exemple, le point accroch\xE9 n'est plus le m\xEAme. + * @param _evt L'evenement suite a un accrochage. + */ + public void catchChanged(ZCatchEvent _evt); +} \ No newline at end of file Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCatchListener.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZEbliCalquePanelController.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZEbliCalquePanelController.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZEbliCalquePanelController.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -8,6 +8,7 @@ package org.fudaa.ebli.calque; import java.awt.Cursor; +import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; @@ -39,10 +40,12 @@ import org.fudaa.ebli.commun.EbliActionPaletteSpecAbstract; import org.fudaa.ebli.commun.EbliActionSimple; import org.fudaa.ebli.commun.EbliComponentFactory; +import org.fudaa.ebli.commun.EbliFormatter; import org.fudaa.ebli.commun.EbliFormatterInterface; import org.fudaa.ebli.commun.EbliLib; import org.fudaa.ebli.controle.BConfigurePaletteAction; import org.fudaa.ebli.geometrie.GrBoite; +import org.fudaa.ebli.geometrie.GrPoint; import org.fudaa.ebli.palette.BPaletteInfoAbstractAction; import org.fudaa.ebli.palette.PaletteEditAction; import org.fudaa.ebli.repere.BControleRepereTexte; @@ -127,10 +130,41 @@ } } + class ControllerCatchListener implements ZCatchListener { + public void catchChanged(ZCatchEvent _evt) { + // Si le calque interactif courant n'est pas un calque gerant l'accrochage, on passe. + // TODO : Le calque interactif d'accrochage pourrait n'etre actif que si le calque courant interactif est un calque + // implementant ZCatchListener + if (cqInteractionActif_==null || !(cqInteractionActif_ instanceof ZCatchListener)) return; + + pn_.getVueCalque().setCursor(_evt.type==ZCatchEvent.CAUGHT ? CURSOR_ACC:cqInteractionActif_.getSpecificCursor()); + + if (_evt.type==ZCatchEvent.CAUGHT) { + GrPoint pt=_evt.selection.getScene().getVertex(_evt.idxGeom,_evt.idxVertex); + + String idxGeom=""+(_evt.selection.getScene().sceneId2LayerId(_evt.idxGeom)+1); + String idxVertex=""+(_evt.idxVertex+1); + String cqName=_evt.selection.getScene().getLayerForId(_evt.idxGeom).getTitle(); + String x=getEbliFormatter().getXYFormatter().format(pt.x_); + String y=getEbliFormatter().getXYFormatter().format(pt.y_); + String z=getEbliFormatter().getXYFormatter().format(pt.z_); + + String[] vars={cqName,idxGeom,idxVertex,x,y,z}; + String text= + EbliResource.EBLI.getString("Accroche : Calque={0}, Geom={1}, Sommet={2}, X={3}, Y={4}, Z={5} (n: Suivant)", vars); + pn_.setInfoText(text); + } + else + pn_.unsetInfoText(); + } + + } /** * Identifiant pour les propri\xE9t\xE9s concernant l'\xE9tat d'un calque d'interaction. */ public final static String STATE = "state"; + /** Un curseur specifique pour l'accrochage. */ + public static final Cursor CURSOR_ACC=EbliResource.EBLI.getCursor("curseur_accroche", -1, new Point(1, 1)); protected static EbliActionInterface[] removePaletteAction(final EbliActionInterface[] _i) { if (_i == null) { @@ -157,7 +191,8 @@ protected EbliActionInterface[] standardActionGroup_; ZCalqueSelectionInteractionAbstract cqSelectionI_; - + /** Le calque interactif d'accrochage */ + ZCalqueCatchInteraction cqCatchI_; BPaletteInfoAbstractAction infoPalette_; CalqueInteractionListener interactionListener_; @@ -422,8 +457,8 @@ cqAdmin_.setName("cqADMIN"); cqAdmin_.setTitle(EbliResource.EBLI.getString("Administration")); cqAdmin_.setDestructible(false); + // le calque etl'affichage du suivi des coordonnees. - final BCalqueSuiviSourisInteraction suivi = new BCalqueSuiviSourisInteraction(); suivi.setTitle(EbliResource.EBLI.getString("Position")); suivi.setName("cqPOSITION"); @@ -433,6 +468,18 @@ // setCalqueInteractionExclusif(suivi, false); addCalqueInteraction(suivi); // cqAdmin_.add(suivi); + + // Le calque d'accrochage + // Attention : L'ajout du calque en premier est tr\xE8s important, l'accrochage ne + // fonctionne que si ce calque recoit les evenements MouseEvent en premier lors de la propagation. + cqCatchI_=new ZCalqueCatchInteraction(); + cqCatchI_.setTitle(EbliResource.EBLI.getString("Accrochage")); + cqCatchI_.setName("cqACCROCHAGE"); + cqCatchI_.setDestructible(false); + cqCatchI_.addCatchListener(new ControllerCatchListener()); + pn_.getVueCalque().addKeyListener(cqCatchI_); + addCalqueInteraction(cqCatchI_); + // S\xE9lection cqSelectionI_ = new ZCalqueSelectionInteractionSimple(); // cqSelectionI_ = new ZCalqueSelectionInteractionMulti(); @@ -470,6 +517,10 @@ interactionListener_ = new CalqueInteractionListener(); } _b.addPropertyChangeListener("gele", interactionListener_); + + if (_b instanceof ZCatchListener) { + cqCatchI_.addCatchListener((ZCatchListener)_b); + } } public BCalqueInteraction getCalqueInteraction(String name){ @@ -596,6 +647,10 @@ public final ZCalqueSelectionInteractionAbstract getCqSelectionI() { return cqSelectionI_; } + + public final ZCalqueCatchInteraction getCqCatchI() { + return cqCatchI_; + } public final EbliFormatterInterface getEbliFormatter() { return suiviSouris_.format(); @@ -630,6 +685,10 @@ _b.removePropertyChangeListener("gele", interactionListener_); } cqAdmin_.remove(_b); + + if (_b instanceof ZCatchListener) { + cqCatchI_.removeCatchListener((ZCatchListener)_b); + } } public void restaurer() { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZEbliCalquesPanel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZEbliCalquesPanel.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZEbliCalquesPanel.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -399,6 +399,7 @@ gisEditor_=createGisEditor(); controller_.getCqSelectionI().setEditor(gisEditor_); + controller_.getCqCatchI().setScene(scene_); } protected ZEditorDefault createGisEditor() { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonnees.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonnees.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonnees.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -9,6 +9,7 @@ package org.fudaa.ebli.calque; import org.fudaa.ebli.geometrie.GrBoite; +import org.fudaa.ebli.geometrie.GrPoint; import com.memoire.bu.BuTable; @@ -56,4 +57,12 @@ */ Object getObject(int _ind); + /** + * Retourne le sommet 3D d'indice _idVertex pour l'objet d'index _ind. + * @param _ind L'indice de l'objet. + * @param _idVertex L'indice du sommet. + * @return Le point, ou null en cas de non conformit\xE9. + */ + GrPoint getVertexForObject(int _ind, int _idVertex); + } \ No newline at end of file Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonneesVide.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonneesVide.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonneesVide.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -8,13 +8,14 @@ package org.fudaa.ebli.calque; import org.fudaa.ebli.geometrie.GrBoite; +import org.fudaa.ebli.geometrie.GrPoint; import org.fudaa.ebli.palette.BPaletteInfo.InfoData; import com.memoire.bu.BuTable; /** * @author Fred Deniger - * @version $Id: ZModeleDonneesVide.java,v 1.7 2006-07-13 13:35:44 deniger Exp $ + * @version $Id$ */ public class ZModeleDonneesVide implements ZModeleDonnees { @@ -47,5 +48,9 @@ public Object getObject(final int _ind){ return null; } + + public GrPoint getVertexForObject(int _ind, int vertex) { + return null; + } } Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonneesVide.java ___________________________________________________________________ Added: svn:keywords + Id Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonnesAbstract.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonnesAbstract.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonnesAbstract.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.List; +import org.fudaa.ebli.geometrie.GrPoint; import org.fudaa.ebli.palette.BPaletteInfo.InfoData; import com.memoire.bu.BuTable; @@ -20,7 +21,7 @@ /** * @author deniger - * @version $Id: ZModeleDonnesAbstract.java,v 1.10 2006-09-19 14:55:46 deniger Exp $ + * @version $Id$ */ public abstract class ZModeleDonnesAbstract implements ZModeleDonnees { @@ -29,6 +30,10 @@ return null; } + public GrPoint getVertexForObject(int _ind, int _idVertex) { + return null; + } + public BuTable createValuesTable(final ZCalqueAffichageDonneesInterface _layer) { return null; } Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleDonnesAbstract.java ___________________________________________________________________ Added: svn:keywords + Id Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleFlecheForGrille.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleFlecheForGrille.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleFlecheForGrille.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -20,7 +20,7 @@ * Une classe permettant de cr\xE9er un modele de fleches d'apr\xE8s la grille utilis\xE9 sur une autre modele. * * @author fred deniger - * @version $Id: ZModeleFlecheForGrille.java,v 1.2 2007-06-20 12:23:11 deniger Exp $ + * @version $Id$ */ public class ZModeleFlecheForGrille implements ZModeleFleche { @@ -148,4 +148,8 @@ return lastRes_; } + public GrPoint getVertexForObject(int _ind, int vertex) { + return null; + } + } Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleFlecheForGrille.java ___________________________________________________________________ Added: svn:keywords + Id Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleGeometry.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleGeometry.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleGeometry.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -48,7 +48,7 @@ void getDomaineForGeometry(int _idxGeom, GrBoite _target); /** - * Modifie les coordonn\xE9es du sommet _pt pour correspondre au point d'indice _pointIdx de la + * Modifie les coordonn\xE9es X,Y,Z du sommet _pt pour correspondre au point d'indice _pointIdx de la * g\xE9om\xE9trie. * * @param _pt le point a modifier Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleStatiquePoint.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleStatiquePoint.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleStatiquePoint.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -16,7 +16,7 @@ /** * Le modele du calque d'affichage de point. * - * @version $Id: ZModeleStatiquePoint.java,v 1.10 2006-09-19 14:55:48 deniger Exp $ + * @version $Id$ * @author Guillaume Desnoix */ public class ZModeleStatiquePoint extends ZModeleDonnesAbstract implements ZModelePoint { @@ -151,4 +151,8 @@ return point(_i); } // public final boolean contourSelectionnable(int _i) { return true; } + + public GrPoint getVertexForObject(int _ind, int vertex) { + return point(_ind); + } } Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZModeleStatiquePoint.java ___________________________________________________________________ Added: svn:keywords + Id Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZScene.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZScene.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZScene.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -12,6 +12,7 @@ import java.awt.Graphics2D; import java.beans.PropertyChangeListener; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -23,6 +24,7 @@ import org.fudaa.ctulu.CtuluListSelectionInterface; import org.fudaa.ebli.calque.edition.ZCalqueEditable; import org.fudaa.ebli.commun.EbliActionInterface; +import org.fudaa.ebli.commun.EbliListeSelectionMulti; import org.fudaa.ebli.commun.EbliListeSelectionMultiInterface; import org.fudaa.ebli.commun.EbliSelectionState; import org.fudaa.ebli.geometrie.GrBoite; @@ -344,6 +346,8 @@ protected SceneListSelectionMulti selectionMulti_=null; protected SceneSelectionHelper selectionHelper_=null; protected boolean atomicMode_=false; + /** La selection pour l'accrochage. Conserv\xE9e pour ne pas etre reconstruite a chaque appel. */ + protected ZSceneSelection selTmp_=new ZSceneSelection(this); /** La scene est r\xE9duite au calque s\xE9lectionn\xE9 pour toutes les actions. */ protected boolean layerRestricted_=false; @@ -523,6 +527,36 @@ fireSelectionEvent(); return b; } + + /** + * Retourne la selection pour le point donn\xE9.<p> + * <b>Remarque:</b> Uniquement des sommets pour le moment, et en tenant compte du fait que la selection + * est restreinte a un calque ou pas. + * + * @param _pt Le point donn\xE9. + * @param _tolerance La tol\xE9rance, en pixels. + * @return Les sommets selectionn\xE9s, ou vide si aucune selection. + */ + public ZSceneSelection selection(final GrPoint _pt, final int _tolerance) { + selTmp_.clear(); + for (ZCalqueAffichageDonneesInterface cq : getTargetLayers()) { + EbliListeSelectionMulti sel=(EbliListeSelectionMulti)cq.selectionMulti(_pt, _tolerance, true); + if (sel!=null) + selTmp_.addLayerListSelectionMulti(cq,sel); + } + return selTmp_; + } + + /** + * Retourne le sommet 3D correspondant a l'indice de geometrie _idScene et l'indice de sommet _idVertex. + * @param _idScene L'indice de la g\xE9om\xE9trie dans la scene + * @param _idVertex L'indice de sommet sur la g\xE9om\xE9trie. + * @return Le sommet 3D. + */ + public GrPoint getVertex(int _idScene, int _idVertex) { + int idxGeom=sceneId2LayerId(_idScene); + return getLayerForId(_idScene).modeleDonnees().getVertexForObject(idxGeom, _idVertex); + } /** * @return la ligne repr\xE9sentant la s\xE9lection courant. null si s\xE9lection non adequate @@ -757,7 +791,7 @@ * si restreint et non calque de donn\xE9es. * @return Les calques cibles. */ - private ZCalqueAffichageDonneesInterface[] getTargetLayers() { + public ZCalqueAffichageDonneesInterface[] getTargetLayers() { if (!isRestrictedToCalqueActif()) return getAllLayers(); else if (treeModel_.getSelectedCalque() instanceof ZCalqueAffichageDonneesInterface) @@ -766,6 +800,10 @@ return new ZCalqueAffichageDonneesInterface[0]; } + /** + * Retourne tous les calques de donn\xE9es contenues dans la scene, dans l'ordre de parcours de l'arbre des calques. + * @return Les calques de donn\xE9es. + */ public ZCalqueAffichageDonneesInterface[] getAllLayers() { if (brefreshRequested_) { ArrayList<BCalque> lcqs=new ArrayList<BCalque>(); Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZSceneSelection.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZSceneSelection.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZSceneSelection.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -0,0 +1,75 @@ +/* + * @creation 15 janv. 2009 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2009 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.ebli.calque; + +import org.fudaa.ctulu.CtuluListSelection; +import org.fudaa.ctulu.CtuluListSelectionInterface; +import org.fudaa.ebli.commun.EbliListeSelectionMulti; +import org.fudaa.ebli.commun.EbliListeSelectionMultiInterface; + +/** + * Une selection pour des g\xE9om\xE9tries ou des sommets de la scene. La selection contient des indices globaux de g\xE9om\xE9tries. + * En cas de selection en mode g\xE9om\xE9tries, la liste des sommets pour un index de g\xE9om\xE9trie est vide. + * + * @author Bertrand Marchand + * @version $Id:$ + */ +public class ZSceneSelection extends EbliListeSelectionMulti { + ZScene scn_; + + /** + * Cr\xE9ation de la liste. + * @param _scn La scene. + */ + public ZSceneSelection(ZScene _scn) { + super(0); + scn_=_scn; + } + + /** + * Ajoute la selection de g\xE9om\xE9tries d'un calque donn\xE9. + * @param _cq Le calque contenant la liste de selection. + * @param _sel La liste des indices de g\xE9om\xE9tries pour le calque. + */ + public void addLayerListSelection(ZCalqueAffichageDonneesInterface _cq, CtuluListSelectionInterface _sel) { + int idecal=0; + for (ZCalqueAffichageDonneesInterface cq : scn_.getTargetLayers()) { + if (cq==_cq) break; + idecal+=cq.modeleDonnees().getNombre(); + } + + for (int idx=_sel.getMinIndex(); idx<=_sel.getMaxIndex(); idx++) { + // Ajoute une liste de selection des sommets vide. + if (_sel.isSelected(idx)) + set(idx+idecal,new CtuluListSelection(0)); + } + } + + /** + * Ajoute la selection de vertex d'un calque donn\xE9. + * @param _cq Le calque contenant la liste de selection. + * @param _sel La liste des indices de sommets par g\xE9om\xE9trie pour le calque. + */ + public void addLayerListSelectionMulti(ZCalqueAffichageDonneesInterface _cq, EbliListeSelectionMultiInterface _sel) { + int idecal=0; + for (ZCalqueAffichageDonneesInterface cq : scn_.getTargetLayers()) { + if (cq==_cq) break; + idecal+=cq.modeleDonnees().getNombre(); + } + + CtuluListSelection selGeom=_sel.getIdxSelection(); + for (int idx=selGeom.getMinIndex(); idx<=selGeom.getMaxIndex(); idx++) { + if (selGeom.isSelected(idx)) + set(idx+idecal,(CtuluListSelection)_sel.getSelection(idx)); + } + } + + public ZScene getScene() { + return scn_; + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZSceneSelection.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueDistanceInteraction.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueDistanceInteraction.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueDistanceInteraction.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -21,6 +21,11 @@ import java.util.List; import org.fudaa.ebli.calque.BCalqueInteraction; +import org.fudaa.ebli.calque.ZCatchEvent; +import org.fudaa.ebli.calque.ZCatchListener; +import org.fudaa.ebli.calque.ZEbliCalquePanelController; +import org.fudaa.ebli.calque.ZEbliCalquesPanel; +import org.fudaa.ebli.calque.ZScene; import org.fudaa.ebli.geometrie.GrPoint; import org.fudaa.ebli.ressource.EbliResource; import org.fudaa.ebli.trace.TraceLigne; @@ -34,8 +39,9 @@ * @author Emmanuel MARTIN * @version $Id$ */ -public class ZCalqueDistanceInteraction extends BCalqueInteraction implements MouseListener, MouseMotionListener { - +public class ZCalqueDistanceInteraction extends BCalqueInteraction implements MouseListener, MouseMotionListener, ZCatchListener { + private static final Cursor CURSOR_DST_=EbliResource.EBLI.getCursor("curseur_distance", -1, new Point(6, 6)); + /** Liste des points composant le chemin affich\xE9. Se sont des coordonn\xE9s r\xE9els. */ protected List<Coordinate> chemin_=new ArrayList<Coordinate>(); /** La coordonn\xE9e correspondant \xE0 la position de la souris. C'est une coordonn\xE9s \xE9cran. */ @@ -52,6 +58,8 @@ protected boolean ctrlActif_=false; /** Listener des distances. */ private List<PropertyChangeListener> listeners_=new ArrayList<PropertyChangeListener>(); + /** Point d'accrochage si existant. null si la souris n'est pas sur un point d'accorchage */ + private GrPoint ptAccroch_=null; public ZCalqueDistanceInteraction(){ setName("cqInteractifDistance"); @@ -84,7 +92,7 @@ // M\xE9thodes d\xE9riv\xE9es \\ public Cursor getSpecificCursor() { - return EbliResource.EBLI.getCursor("curseur_distance", -1, new Point(6, 6)); + return CURSOR_DST_; } public boolean alwaysPaint() { @@ -192,8 +200,7 @@ traceLigne_.dessineTrait((Graphics2D) getGraphics(), reelToEcran(chemin_.get(i-1)).x, reelToEcran(chemin_.get(i-1)).y, reelToEcran(chemin_.get(i)).x, reelToEcran(chemin_.get(i)).y); } - public void mousePressed(final MouseEvent _evt) { - } + public void mousePressed(final MouseEvent _evt) {} public void mouseDragged(final MouseEvent _evt) { mouseMoved(_evt); @@ -205,7 +212,9 @@ /** Met \xE0 jour la partie variable du chemin. */ public void mouseMoved(final MouseEvent _evt) { - if(!isGele()&&!cheminComplet_){ + if(isGele()) return; + + if (!cheminComplet_){ effaceVariable(); coordSouris_.x=_evt.getX(); coordSouris_.y=_evt.getY(); @@ -216,21 +225,40 @@ public void mouseReleased(final MouseEvent _evt) { if (!isGele()&&_evt.getButton()==MouseEvent.BUTTON1) { + GrPoint pt=new GrPoint(_evt.getX(),_evt.getY(),0); + + if (ptAccroch_!=null) + pt=ptAccroch_.applique(getVersEcran()); + effaceChemin(); effaceVariable(); - coordSouris_.x=_evt.getX(); - coordSouris_.y=_evt.getY(); + coordSouris_.x=pt.x_; + coordSouris_.y=pt.y_; // Si le chemin \xE9tait d\xE9j\xE0 complet, on reprend \xE0 0 if(cheminComplet_){ chemin_.clear(); cheminComplet_=false; repaint(); } - chemin_.add(ecranToReel(new Coordinate(_evt.getX(), _evt.getY()))); + chemin_.add(ecranToReel(new Coordinate(pt.x_,pt.y_))); // Si c'est le dernier point, le chemin est termin\xE9 cheminComplet_=chemin_.size()>1&&getDistanceCumulee()>0&&(_evt.getClickCount()>=2||_evt.isControlDown()); afficheChemin(); fireDistanceChangeListener(); } } + + /* (non-Javadoc) + * @see org.fudaa.ebli.calque.ZCalqueCatchInteraction.ZCatchListener#catchChanged(org.fudaa.ebli.calque.ZCalqueCatchInteraction.ZCatchEvent) + */ + public void catchChanged(ZCatchEvent _evt) { + if (isGele()) return; + + if (_evt.type==ZCatchEvent.CAUGHT) { + ptAccroch_=_evt.selection.getScene().getVertex(_evt.idxGeom,_evt.idxVertex); + } + else { + ptAccroch_=null; + } + } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueEditionInteraction.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueEditionInteraction.java 2009-01-23 10:39:23 UTC (rev 4395) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueEditionInteraction.java 2009-01-23 16:12:37 UTC (rev 4396) @@ -19,7 +19,6 @@ import java.awt.event.MouseMotionListener; import java.util.ArrayList; import java.util.HashMap; -import java.util.Set; import java.util.Vector; import java.util.Map.Entry; @@ -30,6 +29,10 @@ import org.fudaa.ctulu.CtuluLibString; import org.fudaa.ctulu.gis.GISAttributeInterface; import org.fudaa.ebli.calque.BCalqueInteraction; +import org.fudaa.ebli.calque.BVueCalque; +import org.fudaa.ebli.calque.ZCatchEvent; +import org.fudaa.ebli.calque.ZCatchListener; +import org.fudaa.ebli.calque.ZScene; import org.fudaa.ebli.calque.dessin.DeForme; import org.fudaa.ebli.calque.dessin.DeLigneBrisee; import org.fudaa.ebli.calque.dessin.DeMultiPoint; @@ -47,19 +50,21 @@ /** * Permet la saisie interactive de formes g\xE9om\xE9triques. - * @version $Id: ZCalqueEditionInteraction.java,v 1.16.6.2 2008-03-27 15:26:27 bmarchan Exp $ + * @version $Id$ * @author */ -public class ZCalqueEditionInteraction extends BCalqueInteraction implements KeyListener, MouseListener, MouseMotionListener { +public class ZCalqueEditionInteraction extends BCalqueInteraction implements KeyListener, MouseListener, MouseMotionListener, ZCatchListener { /** * La classe deleguee pour la saisie de forme. * * @author Fred Deniger - * @version $Id: ZCalqueEditionInteraction.java,v 1.16.6.2 2008-03-27 15:26:27 bmarchan Exp $ + * @version $Id$ */ public abstract class FormDelegate extends MouseAdapter implements KeyListener, MouseMotionListener { + /** LE dernier point d'accrochage definit */ + GrPoint ptAccro_=null; /** * Enleve le dernier point saisie. */ @@ -126,6 +131,10 @@ * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent) */ public void keyTyped(KeyEvent _e) {} + + public void setAccroche(GrPoint _ptReel) { + ptAccro_=_ptReel; + } } class FormDelegateLigneBrisee extends FormDelegate { @@ -174,6 +183,7 @@ g2d.setXORMode(getBackground()); ligne_.affiche(g2d, tl_, isRapide(), tmp_, getVersEcran()); ligne_.enleveDernier(); + data_.removeLastInfo(); if (pointFin_ != null) { pointFin_ = ligne_.getDernier(); } @@ -302,12 +312,16 @@ tmp_.x_ = _x; tmp_.y_ = _y; tmp_.autoApplique(getVersReel()); - support_.setMessage(CtuluLib.getS("Distance:") - + CtuluLibString.ESPACE - + CtuluLib.DEFAULT_NUMBER_FORMAT.format(CtuluLibGeometrie.getDistance(tmp_.x_, tmp_.y_, pointFin_.x_, - pointFin_.y_))); + + if (ptAccro_==null) { + support_.setMessage(CtuluLib.getS("Distance:") + + CtuluLibString.ESPACE + + CtuluLib.DEFAULT_NUMBER_FORMAT.format(CtuluLibGeometrie.getDistance(tmp_.x_, tmp_.y_, pointFin_.x_, + pointFin_.y_))); + } } else { - support_.unsetMessage(); + if (ptAccro_==null) + support_.unsetMessage(); } } @@ -325,11 +339,15 @@ } else { data_ = features_.createLigneBriseeData(); } - pointDep_ = getPointReel(_e); + if (ptAccro_==null) + pointDep_ = getPointReel(_e); + else + pointDep_=ptAccro_; + pointFin_ = pointDep_; ligne_.ajoute(pointDep_); if (data_ != null) { - data_.addPoint(); + data_.addPoint(ptAccro_); } if (support_ != null) { @@ -340,10 +358,13 @@ else { boolean afficheLigne = true; if (_e.getClickCount() < 2) { - pointFin_ = getPointReel(_e); + if (ptAccro_==null) + pointFin_ = getPointReel(_e); + else + pointFin_=ptAccro_; ligne_.ajoute(pointFin_); if (data_ != null) { - data_.addPoint(); + data_.addPoint(ptAccro_); } if (_e.isControlDown()) { afficheLigne = polyAdded(); @@ -392,6 +413,7 @@ } else { multipoint_.enleveDernier(); + data_.removeLastInfo(); multipoint_.affiche(g2d, tp_, isRapide(), tmp_, getVersEcran()); support_.atomicChanged(); @@ -467,10 +489,10 @@ } boolean afficheLigne=true; if (_e.getClickCount()<2) { - GrPoint pt=getPointReel(_e); + GrPoint pt=ptAccro_==null ? getPointReel(_e):ptAccro_; multipoint_.ajoute(pt); if (data_!=null) { - data_.addPoint(); + data_.addPoint(ptAccro_); } if (_e.isControlDown()) { afficheLigne=polyAdded(); @@ -532,7 +554,8 @@ if (pt_==null) return; final ZEditionAttributesDataI d = features_ == null ? null : features_.createPointData(); if (d != null) { - d.addPoint(); + if (ptAccro_!=null) pt_=ptAccro_; + d.addPoint(ptAccro_); support_.addNewPoint(pt_, d); } pt_=null; @@ -630,6 +653,8 @@ public void mousePressed(final MouseEvent _e) { if (origine_==null) { origine_=getPointReel(_e); + if (ptAccro_!=null) + origine_=ptAccro_; if (support_!=null) support_.atomicChanged(); moved_=false; @@ -640,8 +665,12 @@ if (enCours()) { moved_=true; effaceDessin(); - grandRayon_=Math.abs(getPointReel(_e).x_-origine_.x_); - petitRayon_=Math.abs(getPointReel(_e).y_-origine_.y_); + GrPoint pt=getPointReel(_e); + if (ptAccro_!=null) + pt=ptAccro_; + + grandRayon_=Math.abs(pt.x_-origine_.x_); + petitRayon_=Math.abs(pt.y_-origine_.y_); // Si la touche Ctrl est pressee, on est en mode 'cercle' if (keyPresse_.contains((Object)KeyEvent.VK_CONTROL)) { grandRayon_ = (grandRayon_ + petitRayon_)/2; @@ -743,7 +772,7 @@ } for (double t=0; t<2*Math.PI; t+=incT) { poly.sommets_.ajoute(getXEllipse(t)+origine_.x_, getYEllipse(t)+origine_.y_, 0); - if(_withData) data_.addPoint(); + if(_withData) data_.addPoint(null); } // Mise a jour des attributs if(_withData) addData(); @@ -1035,6 +1064,8 @@ public void mousePressed(final MouseEvent _e) { if (pointDep_ == null) { pointDep_ = getPointReel(_e); + if (ptAccro_!=null) + pointDep_=ptAccro_; if (support_ != null) support_.atomicChanged(); moved_ = false; @@ -1046,6 +1077,8 @@ effaceDessin(); moved_=true; pointFin_=getPointReel(_e); + if (ptAccro_!=null) + pointFin_=ptAccro_; // Si la touche Ctrl est pressee, on est en mode 'carre' if (keyPresse_.contains((Object)KeyEvent.VK_CONTROL)) { double cote=(Math.abs(pointDep_.x_-pointFin_.x_)+Math.abs(pointDep_.y_-pointFin_.y_))/2; @@ -1143,28 +1176,28 @@ double largeur = Math.abs(x1 - x0), hauteur = Math.abs(y1 - y0); // Ajout des sommets dans le bonne ordre poly.sommets_.ajoute(x0, y0, z0); - if(_withData) data_.addPoint(); + if(_withData) data_.addPoint(null); for (int i=0; i<nbPointsHauteur_; i++){ poly.sommets_.ajoute(x0, y0 + (i + 1) * (hauteur / (nbPointsHauteur_ + 1)), z0); - if(_withData) data_.addPoint(); + if(_withData) data_.addPoint(null); } poly.sommets_.ajoute(x0, y1, z0); - if(_withData) data_.addPoint(); + if(_withData) data_.addPoint(null); ... [truncated message content] |
From: <emm...@us...> - 2009-01-27 15:34:05
|
Revision: 4407 http://fudaa.svn.sourceforge.net/fudaa/?rev=4407&view=rev Author: emmanuel_martin Date: 2009-01-27 15:34:03 +0000 (Tue, 27 Jan 2009) Log Message: ----------- Modifications mineurs Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStReader.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/EbliSingleObjectEditorPanel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditorDefault.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStReader.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStReader.java 2009-01-27 15:07:27 UTC (rev 4406) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStReader.java 2009-01-27 15:34:03 UTC (rev 4407) @@ -71,11 +71,11 @@ in_.setCommentInOneField("#"); in_.setJumpCommentLine(true); - final List lignes = new ArrayList(200); - final List names=new ArrayList(200); - final List coordinatesEnCours = new ArrayList(); + final List<LineString> lignes = new ArrayList<LineString>(200); + final List<String> names=new ArrayList<String>(200); + final List<Coordinate> coordinatesEnCours = new ArrayList<Coordinate>(); // Contient les listes de coordonn\xE9es pour les lignes directrices (Map<String,ArrayList<Coordinate>> en Java 1.5) - final Map mdirs=new HashMap(20); + final Map<String, List<Coordinate>> mdirs=new HashMap<String, List<Coordinate>>(20); final int[] fmt = new int[] { 13, 13, 13, 1, 3 }; final int[] fmt1Line=new int[]{6,6,6,6,13,1,42}; @@ -102,12 +102,12 @@ // Ligne directrice eventuelle. Pas de controle que la ligne directrice est bien sur tous les profils. String namedir=in_.stringField(4).trim(); if (!"".equals(namedir)) { - List coordldir=(List)mdirs.get(namedir); + List<Coordinate> coordldir=(List<Coordinate>)mdirs.get(namedir); if (coordldir==null) { - coordldir=new ArrayList(200); + coordldir=new ArrayList<Coordinate>(200); mdirs.put(namedir,coordldir); } - coordldir.add(last.clone()); + coordldir.add((Coordinate) last.clone()); } in_.readFields(fmt); @@ -172,7 +172,7 @@ String[] namedirs=(String[])mdirs.keySet().toArray(new String[0]); LineString[] ldirs=new LineString[namedirs.length]; for (int i=0; i<namedirs.length; i++) { - ldirs[i]=GISLib.createLineOrLinearFromList((List)(mdirs.get(namedirs[i]))); + ldirs[i]=GISLib.createLineOrLinearFromList((List<Coordinate>)(mdirs.get(namedirs[i]))); } zdirs.addAllLineStringClosedOrNode(ldirs, null); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/EbliSingleObjectEditorPanel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/EbliSingleObjectEditorPanel.java 2009-01-27 15:07:27 UTC (rev 4406) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/EbliSingleObjectEditorPanel.java 2009-01-27 15:34:03 UTC (rev 4407) @@ -648,7 +648,7 @@ tabbedPane_.add(EbliLib.getS("Courbe"), courbeRep_); add(tabbedPane_, BuBorderLayout.CENTER); } - if (zone_.getIndiceOf(zAttr)==-1) { + else { modelData_=new TableModelModeleAdapter(modeleSrc_, idx_, _xyFormatter, new CtuluCommandComposite(), _editVertexAttribut); tableRep_=new TableRepresentation(_editAttribut, _editVertexAttribut, _xyFormatter); add(tableRep_, BuBorderLayout.CENTER); @@ -697,8 +697,10 @@ public void cancel() { super.cancel(); // D\xE9active le model - modelData_.setSource(null, -1); - ((CtuluCommandComposite) modelData_.getUndoRedoContainer()).undo(); + if (modelData_!=null) { + modelData_.setSource(null, -1); + ((CtuluCommandComposite)modelData_.getUndoRedoContainer()).undo(); + } } public final CtuluCommandContainer getCmd() { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditorDefault.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditorDefault.java 2009-01-27 15:07:27 UTC (rev 4406) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditorDefault.java 2009-01-27 15:34:03 UTC (rev 4407) @@ -53,9 +53,6 @@ import org.fudaa.ebli.trace.TraceIcon; import com.memoire.bu.BuDesktop; -import com.memoire.bu.BuInternalFrame; -import com.memoire.bu.BuLabel; -import com.memoire.bu.BuPopupWindow; import com.memoire.bu.BuResource; import com.memoire.fu.Fu; import com.memoire.fu.FuLog; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2009-01-28 12:55:31
|
Revision: 4416 http://fudaa.svn.sourceforge.net/fudaa/?rev=4416&view=rev Author: emmanuel_martin Date: 2009-01-28 11:46:22 +0000 (Wed, 28 Jan 2009) Log Message: ----------- Tache #163 : "Prise en compte des lignes de contrainte au moment du passage au 1D." Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueBief.java Added Paths: ----------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dLimiteStockage.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dLimiteStockage.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/persistence/MdlLayer1dLimiteStockageLinePersistence.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-01-27 20:57:12 UTC (rev 4415) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-01-28 11:46:22 UTC (rev 4416) @@ -58,6 +58,8 @@ public final static String ATT_NATURE_AH="AH"; /** Nature rive (gauche ou droite) */ public final static String ATT_NATURE_RV="RV"; + /** Nature limite de stockage */ + public final static String ATT_NATURE_LS="LS"; /** * Un attribut nom, global. Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java 2009-01-27 20:57:12 UTC (rev 4415) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java 2009-01-28 11:46:22 UTC (rev 4416) @@ -24,6 +24,7 @@ import org.fudaa.fudaa.modeleur.action.CalqueNewCalqueAction; import org.fudaa.fudaa.modeleur.layer.MdlLayer1dAxe; import org.fudaa.fudaa.modeleur.layer.MdlLayer1dBank; +import org.fudaa.fudaa.modeleur.layer.MdlLayer1dLimiteStockage; import org.fudaa.fudaa.modeleur.layer.MdlLayer1dTrace; import org.fudaa.fudaa.modeleur.layer.MdlLayer2dCloud; import org.fudaa.fudaa.modeleur.layer.MdlLayer2dConstraintLine; @@ -294,6 +295,10 @@ cqDirect.setName(BGroupeCalque.findUniqueChildName(cqBief, cqDirect.getExtName())); cqBief.add(cqDirect); + MdlLayer1dLimiteStockage cqLimite=new MdlLayer1dLimiteStockage(getEditor()); + cqLimite.setName(BGroupeCalque.findUniqueChildName(cqBief, cqLimite.getExtName())); + cqBief.add(cqLimite); + MdlLayer2dConstraintLine cqConst=new MdlLayer2dConstraintLine(getEditor()); cqConst.setName(BGroupeCalque.findUniqueChildName(cqBief, cqConst.getExtName())); cqBief.add(cqConst); Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dLimiteStockage.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dLimiteStockage.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dLimiteStockage.java 2009-01-28 11:46:22 UTC (rev 4416) @@ -0,0 +1,65 @@ +/* + * @creation 28 janv. 2009 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2009 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.fudaa.modeleur.layer; + +import java.awt.Color; + +import org.fudaa.ebli.calque.BCalquePersistenceInterface; +import org.fudaa.ebli.calque.dessin.DeForme; +import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; +import org.fudaa.ebli.trace.TraceLigne; +import org.fudaa.ebli.trace.TraceLigneModel; +import org.fudaa.fudaa.modeleur.MdlResource; +import org.fudaa.fudaa.modeleur.persistence.MdlLayer1dLimiteStockageLinePersistence; +import org.fudaa.fudaa.sig.layer.FSigEditor; + +/** + * Un calque pour le stockage et la manipulation des lignes de constraintes. + * + * @author Emmanuel MARTIN + * @version $Id:$ + * */ +public class MdlLayer1dLimiteStockage extends MdlLayer2dLine { + + /** + * Constructeur. Utilise un mod\xE8le de donn\xE9es et un editeur. + * + * @param _model + * Modele + * @param _editor + * Editeur. + */ + private MdlLayer1dLimiteStockage(ZModeleLigneBriseeEditable _model, final FSigEditor _editor) { + super(_model, _editor); + setLineModel(0, new TraceLigneModel(TraceLigne.LISSE, 1.5f, Color.green)); + setLineModelOuvert(getLineModel(0)); + setName(getExtName()); + setTitle(MdlResource.MDL.getString("Limites de stockages")); + } + + public MdlLayer1dLimiteStockage(FSigEditor _editor) { + this(new MdlModel1dLimiteStockage(_editor, _editor.getMng()), _editor); + } + + public BCalquePersistenceInterface getPersistenceMng() { + return new MdlLayer1dLimiteStockageLinePersistence(); + } + + /** + * Retourne le nom par defaut du calque. + * + * @return Le nom. + */ + public String getExtName() { + return "limiteStockage"; + } + + public boolean canAddForme(int _typeForme) { + return _typeForme==DeForme.LIGNE_BRISEE; + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dLimiteStockage.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dLimiteStockage.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dLimiteStockage.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dLimiteStockage.java 2009-01-28 11:46:22 UTC (rev 4416) @@ -0,0 +1,41 @@ +/* + * @creation 28 janv. 2009 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2009 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ + +package org.fudaa.fudaa.modeleur.layer; + +import org.fudaa.ctulu.CtuluCommandContainer; +import org.fudaa.ctulu.gis.GISAttribute; +import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ebli.calque.ZModelGeometryListener; + +/** + * Un mod\xE8le de calque pour le calque 2D des lignes de constraintes. Les lignes + * sont des polylignes XYZ, non ferm\xE9es. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class MdlModel1dLimiteStockage extends MdlModel2dLine { + + /** + * Construction d'un modele avec pile de commandes. + * + * @param _cmd + * La pile de commandes pour le undo/redo. + */ + public MdlModel1dLimiteStockage(final ZModelGeometryListener _listener, final CtuluCommandContainer _cmd) { + super(_listener); + GISAttribute[] attrs=new GISAttribute[]{GISAttributeConstants.BATHY, GISAttributeConstants.ETAT_GEOM, + GISAttributeConstants.TITRE, GISAttributeConstants.NATURE, GISAttributeConstants.VISIBILITE}; + // Pas de container de commande pour cette op\xE9ration, sinon conserv\xE9 en + // undo/redo. + getGeomData().setAttributes(attrs, null); + getGeomData().setAttributeIsZ(GISAttributeConstants.BATHY); + getGeomData().setFixedAttributeValue(GISAttributeConstants.NATURE, GISAttributeConstants.ATT_NATURE_LS); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dLimiteStockage.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-01-27 20:57:12 UTC (rev 4415) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-01-28 11:46:22 UTC (rev 4416) @@ -17,10 +17,13 @@ import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ctulu.gis.GISAttributeInterface; import org.fudaa.ctulu.gis.GISAttributeModel; +import org.fudaa.ctulu.gis.GISAttributeModelDoubleArray; +import org.fudaa.ctulu.gis.GISAttributeModelDoubleInterface; import org.fudaa.ctulu.gis.GISAttributeModelIntegerList; import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; import org.fudaa.ctulu.gis.GISCoordinateSequenceFactory; import org.fudaa.ctulu.gis.GISPolyligne; +import org.fudaa.ctulu.gis.GISReprojectInterpolateur1DDouble; import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ctulu.gis.GISZoneCollectionGeometry; import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; @@ -29,6 +32,7 @@ import org.fudaa.fudaa.commun.FudaaLib; import org.fudaa.fudaa.modeleur.layer.MdlModel1dAxe; import org.fudaa.fudaa.modeleur.layer.MdlModel1dBank; +import org.fudaa.fudaa.modeleur.layer.MdlModel1dLimiteStockage; import org.fudaa.fudaa.modeleur.layer.MdlModel2dConstraintLine; import org.fudaa.fudaa.modeleur.layer.MdlModel2dDirectionLine; import org.fudaa.fudaa.modeleur.layer.MdlModel2dProfile; @@ -48,6 +52,7 @@ public ZModeleLigneBrisee rives_; public ZModeleLigneBrisee limitesStockages_; public ZModeleLigneBrisee lignesDirectrices_; + public ZModeleLigneBrisee lignesContraints_; /** Le synchroniser de gis. */ private GisZoneSynchroniser gisSynchroniser_=new GisZoneSynchroniser(); @@ -61,7 +66,8 @@ profils_=new MdlModel2dProfile(null, null); normalizeProfilAttributes(profils_.getGeomData()); rives_=new MdlModel1dBank(null, null); - limitesStockages_=new MdlModel2dConstraintLine(null, null); + limitesStockages_=new MdlModel1dLimiteStockage(null, null); + lignesContraints_=new MdlModel2dConstraintLine(null, null); lignesDirectrices_=new MdlModel2dDirectionLine(null, null); } @@ -98,48 +104,53 @@ private void testAndValuateModels(ZModeleLigneBrisee[] _models) { if (_models==null) - throw new IllegalArgumentException("_models ne peut pas \xEAtre null."); + throw new IllegalArgumentException(FudaaLib.getS("Erreur programmation : _models ne peut pas \xEAtre null.")); for (int i=0; i<_models.length; i++) { if (_models[i]==null) - throw new IllegalArgumentException("_models ne doit pas contenir de valeurs null"); + throw new IllegalArgumentException(FudaaLib.getS("Erreur programmation : _models ne doit pas contenir de valeurs null")); if (_models[i].getGeomData()==null) - throw new IllegalArgumentException("Certain model n'ont pas de GSIZone."); + throw new IllegalArgumentException(FudaaLib.getS("Erreur programmation : Certain model n'ont pas de GSIZone.")); if (!(_models[i].getGeomData() instanceof GISZoneCollectionLigneBrisee)) - throw new IllegalArgumentException("Toutes les GISZone doivent \xEAtre des GISZoneCollectionLigneBrisee."); + throw new IllegalArgumentException(FudaaLib.getS("Erreur programmation : Toutes les GISZone doivent \xEAtre des GISZoneCollectionLigneBrisee.")); String nature=(String)_models[i].getGeomData().getFixedAttributValue(GISAttributeConstants.NATURE); if (nature==null) - throw new IllegalArgumentException("Une des GISZone ne contient pas l'attribut NATURE."); + throw new IllegalArgumentException(FudaaLib.getS("Un des modeles ne contient pas l'attribut NATURE.")); if (nature==GISAttributeConstants.ATT_NATURE_AH) if (axeHydraulique_!=null) - throw new IllegalArgumentException("Plusieurs models d'axe hydrauliques sont donn\xE9es."); + throw new IllegalArgumentException(FudaaLib.getS("Plusieurs models d'axe hydrauliques sont donn\xE9es.")); else if (_models[i].getGeomData().getNbGeometries()>1) - throw new IllegalArgumentException("Il ne peut pas y avoir plusieurs Axes hydrauliques dans le bief."); + throw new IllegalArgumentException(FudaaLib.getS("Il ne peut pas y avoir plusieurs Axes hydrauliques dans le bief.")); else axeHydraulique_=_models[i]; else if (nature==GISAttributeConstants.ATT_NATURE_LD) if (lignesDirectrices_!=null) - throw new IllegalArgumentException("Plusieurs models de lignes directrices sont donn\xE9es."); + throw new IllegalArgumentException(FudaaLib.getS("Plusieurs models de lignes directrices sont donn\xE9es.")); else lignesDirectrices_=_models[i]; - else if (nature==GISAttributeConstants.ATT_NATURE_LC) + else if (nature==GISAttributeConstants.ATT_NATURE_LS) if (limitesStockages_!=null) - throw new IllegalArgumentException("Plusieurs models de limites de stockage sont donn\xE9es."); + throw new IllegalArgumentException(FudaaLib.getS("Plusieurs models de limites de stockage sont donn\xE9es.")); else if (_models[i].getGeomData().getNbGeometries()>2) - throw new IllegalArgumentException("Il ne peut pas y avoir plus de 2 limites de stockage."); + throw new IllegalArgumentException(FudaaLib.getS("Il ne peut pas y avoir plus de 2 limites de stockage.")); else limitesStockages_=_models[i]; else if (nature==GISAttributeConstants.ATT_NATURE_PF) if (profils_!=null) - throw new IllegalArgumentException("Plusieurs models de profils sont donn\xE9es."); + throw new IllegalArgumentException(FudaaLib.getS("Plusieurs models de profils sont donn\xE9es.")); else profils_=_models[i]; else if (nature==GISAttributeConstants.ATT_NATURE_RV) if (rives_!=null) - throw new IllegalArgumentException("Plusieurs models de rives sont donn\xE9es."); + throw new IllegalArgumentException(FudaaLib.getS("Plusieurs models de rives sont donn\xE9es.")); else if (_models[i].getGeomData().getNbGeometries()>2) - throw new IllegalArgumentException("Il ne peut pas y avoir plus de 2 rives."); + throw new IllegalArgumentException(FudaaLib.getS("Il ne peut pas y avoir plus de 2 rives.")); else rives_=_models[i]; + else if (nature==GISAttributeConstants.ATT_NATURE_LC) + if (lignesContraints_!=null) + throw new IllegalArgumentException(FudaaLib.getS("Plusieurs models de lignes de contraintes sont donn\xE9es.")); + else + lignesContraints_=_models[i]; } // Remplissage des models vides par des ZModeles vides if (axeHydraulique_==null) @@ -149,9 +160,11 @@ if (rives_==null) rives_=new MdlModel1dBank(null, null); if (limitesStockages_==null) - limitesStockages_=new MdlModel2dConstraintLine(null, null); + limitesStockages_=new MdlModel1dLimiteStockage(null, null); if (lignesDirectrices_==null) lignesDirectrices_=new MdlModel2dDirectionLine(null, null); + if(lignesContraints_==null) + lignesContraints_=new MdlModel2dConstraintLine(null, null); } private void buildWithTrustData(ZModeleLigneBrisee[] _models) { @@ -218,6 +231,9 @@ // Cr\xE9ation des nouveaux points sur les profils \\ for (int k=0; k<profils_.getNombre(); k++) { // Ajout des points au profil si n\xE9c\xE9ssaire pour les intersections \\ + // Lignes de contraintes + for (int l=0; l<lignesContraints_.getNombre(); l++) + createPointIfNeededKeepZ(k, l, lignesContraints_); // Rives for (int l=0; l<rives_.getNombre(); l++) createPointIfNeeded(k, (GISPolyligne) rives_.getObject(l)); @@ -446,12 +462,71 @@ int previousIdx=UtilsProfil1d.getPreviousIndex(seq, coord); int nextIdx=UtilsProfil1d.getNextIndex(seq, coord); // Le point n'appartient pas au profil ou La coordonn\xE9e correspond d\xE9j\xE0 \xE0 un point - if (previousIdx==-2||nextIdx==-2||previousIdx+1==nextIdx-1||nextIdx==-1||previousIdx==-1) - return; - // La coordonn\xE9e correspond \xE0 aucun point connu - ((GISZoneCollectionGeometry)profils_.getGeomData()).addAtomic(_idxProfil, previousIdx, coord.x, coord.y, null); + if (previousIdx!=-2&&nextIdx!=-2&&previousIdx+1!=nextIdx-1&&nextIdx!=-1&&previousIdx!=-1) + // La coordonn\xE9e correspond \xE0 aucun point connu + ((GISZoneCollectionGeometry)profils_.getGeomData()).addAtomic(_idxProfil, previousIdx, coord.x, coord.y, null); } } + + /** + * Cr\xE9e un point \xE0 l'intersection du profil indiqu\xE9 par _idxProfil et de + * _ligne. Le z du point cr\xE9e prendra la valeur z du point correspondant dans + * _ligne (interpol\xE9 si n\xE9c\xE9ssaire). + */ + private void createPointIfNeededKeepZ(int _idxProfil, int _idxLigne, ZModeleLigneBrisee _modelLigne) { + GISZoneCollection zoneLigne=_modelLigne.getGeomData(); + GISZoneCollection zoneProfil=profils_.getGeomData(); + GISPolyligne ligne=(GISPolyligne) zoneLigne.getGeometry(_idxLigne); + GISPolyligne profil=(GISPolyligne) zoneProfil.getGeometry(_idxProfil); + CoordinateSequence seqLigne=zoneLigne.getCoordinateSequence(_idxLigne); + CoordinateSequence seqProfil=zoneProfil.getCoordinateSequence(_idxProfil); + Geometry intersection=ligne.intersection(profil); + if (intersection.getNumPoints()==1) { + Coordinate coordIntersection=intersection.getCoordinate(); + int previousIdx=UtilsProfil1d.getPreviousIndex(seqProfil, coordIntersection); + int nextIdx=UtilsProfil1d.getNextIndex(seqProfil, coordIntersection); + // Le point n'appartient pas au profil ou La coordonn\xE9e correspond d\xE9j\xE0 \xE0 un point + if (previousIdx!=-2&&nextIdx!=-2&&previousIdx+1!=nextIdx-1&&nextIdx!=-1&&previousIdx!=-1) { + // La coordonn\xE9e correspond \xE0 aucun point connu + ((GISZoneCollectionGeometry) zoneProfil).addAtomic(_idxProfil, previousIdx, coordIntersection.x, coordIntersection.y, null); + seqProfil=zoneProfil.getCoordinateSequence(_idxProfil); + } + // Valuation du z par la valeur de la ligne si _zLigne \xE0 vrai + if(zoneLigne.getAttributeIsZ()!=null) { + int idxPProfil=UtilsProfil1d.getIndex(seqProfil, coordIntersection); + int idxPLigne=UtilsProfil1d.getIndex(seqLigne, coordIntersection); + GISAttributeModel modelZLigne=zoneLigne.getModel(zoneLigne.getAttributeIsZ()); + double z; + // Si l'attribut est global + if(!zoneLigne.getAttributeIsZ().isAtomicValue()) + z=(Double) modelZLigne.getObjectValueAt(_idxLigne); + // Le point existe dans la ligne + else if(idxPLigne!=-1) + z=(Double) ((GISAttributeModel) modelZLigne.getObjectValueAt(_idxLigne)).getObjectValueAt(idxPLigne); + // Le point n'existe pas => interpole une valeur + else { + // Extraction des index pr\xE9c\xE9dent et suivant \\ + int idxPrevious=UtilsProfil1d.getPreviousIndex(seqLigne, coordIntersection); + if (idxPrevious==-1) idxPrevious=0; + Coordinate previous=seqLigne.getCoordinate(idxPrevious); + int idxNext=UtilsProfil1d.getNextIndex(seqLigne, coordIntersection); + if (idxNext==-1) idxNext=seqLigne.size()-1; + Coordinate next=seqLigne.getCoordinate(UtilsProfil1d.getNextIndex(seqLigne, coordIntersection)); + // Cr\xE9ation d'un model temporaire contenant les z \\ + double valZ1=(Double) ((GISAttributeModel) modelZLigne.getObjectValueAt(_idxLigne)).getObjectValueAt(idxPrevious); + double valZ2=(Double) ((GISAttributeModel) modelZLigne.getObjectValueAt(_idxLigne)).getObjectValueAt(idxNext); + GISAttributeModelDoubleInterface zModel=new GISAttributeModelDoubleArray(new double[]{valZ1, valZ2}, zoneLigne + .getAttributeIsZ()); + // Interpolation \\ + GISCoordinateSequenceFactory factory=new GISCoordinateSequenceFactory(); + z=new GISReprojectInterpolateur1DDouble(factory.create(new Coordinate[]{previous, next}), factory + .create(new Coordinate[]{previous, new Coordinate(coordIntersection.x, coordIntersection.y, 0), next}), zModel).interpol(1); + } + ((GISAttributeModel)zoneProfil.getModel(zoneProfil.getAttributeIsZ()).getObjectValueAt(_idxProfil)).setObject(idxPProfil, + z, null); + } + } + } /** * Retourne vrai si les donn\xE9es contenues dans les champs sont coh\xE9rentes. Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueBief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueBief.java 2009-01-27 20:57:12 UTC (rev 4415) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueBief.java 2009-01-28 11:46:22 UTC (rev 4416) @@ -18,7 +18,7 @@ import org.fudaa.fudaa.modeleur.MdlImplementation; import org.fudaa.fudaa.modeleur.layer.MdlLayer1dAxe; import org.fudaa.fudaa.modeleur.layer.MdlLayer1dBank; -import org.fudaa.fudaa.modeleur.layer.MdlLayer2dConstraintLine; +import org.fudaa.fudaa.modeleur.layer.MdlLayer1dLimiteStockage; import org.fudaa.fudaa.modeleur.layer.MdlLayer2dDirectionLine; import org.fudaa.fudaa.modeleur.layer.MdlLayer2dProfile; import org.fudaa.fudaa.modeleur.modeleur1d.controller.ControllerBief; @@ -79,7 +79,7 @@ lignesDirectrices.modele(bief.lignesDirectrices_); groupeCalque.add(lignesDirectrices); // Ajout du calque de limites de stockage - MdlLayer2dConstraintLine limitesStockage=new MdlLayer2dConstraintLine((FSigEditor)gisEditor_); + MdlLayer1dLimiteStockage limitesStockage=new MdlLayer1dLimiteStockage((FSigEditor)gisEditor_); limitesStockage.setSelectable(false); limitesStockage.modele(bief.limitesStockages_); groupeCalque.add(limitesStockage); Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/persistence/MdlLayer1dLimiteStockageLinePersistence.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/persistence/MdlLayer1dLimiteStockageLinePersistence.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/persistence/MdlLayer1dLimiteStockageLinePersistence.java 2009-01-28 11:46:22 UTC (rev 4416) @@ -0,0 +1,26 @@ +/* + * @creation 28 janv. 2009 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2009 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.fudaa.modeleur.persistence; + +import org.fudaa.fudaa.modeleur.layer.MdlLayer1dLimiteStockage; +import org.fudaa.fudaa.modeleur.layer.MdlLayer2dLine; +import org.fudaa.fudaa.sig.layer.FSigEditor; + +/** + * Gestion de la persistance pour un calque de lignes de contraintes. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class MdlLayer1dLimiteStockageLinePersistence extends MdlLayer2dLinePersistence { + + @Override + protected MdlLayer2dLine createNewLayer(FSigEditor _editor) { + return new MdlLayer1dLimiteStockage(_editor); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/persistence/MdlLayer1dLimiteStockageLinePersistence.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bma...@us...> - 2009-02-02 09:49:01
|
Revision: 4433 http://fudaa.svn.sourceforge.net/fudaa/?rev=4433&view=rev Author: bmarchan Date: 2009-02-02 09:48:56 +0000 (Mon, 02 Feb 2009) Log Message: ----------- Recup?\195?\169ration/sauvegarde des pk sur fichiers Rubar ST. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStCnFileFormat.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStReader.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStWriter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dProfile.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerExporter.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-01-30 18:59:41 UTC (rev 4432) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-02-02 09:48:56 UTC (rev 4433) @@ -158,6 +158,15 @@ }; /** + * Un attribut commentaire hydraulique, utilis\xE9 dans la lecture/ecriture des fichiers. + */ + public final static GISAttributeString COMMENTAIRE_HYDRO = new GISAttributeString(CtuluLib.getS("Commentaire hydro"), false) { + public String getID() { + return "ATTRIBUTE_HYDRO_COMMENT"; + } + }; + + /** * Un attribut bathy, atomique. */ public final static GISAttributeDouble BATHY = new GISAttributeDouble(CtuluLib.getS("z"), true) { @@ -180,7 +189,7 @@ /** La liste des attributs syst\xE8mes. */ protected final static List<GISAttribute> attrs_= - Arrays.asList(new GISAttribute[]{BATHY,TITRE,NATURE,VISIBILITE,ETAT_GEOM}); + Arrays.asList(new GISAttribute[]{BATHY,TITRE,NATURE,VISIBILITE,ETAT_GEOM,COMMENTAIRE_HYDRO}); private GISAttributeConstants() {} @@ -242,6 +251,9 @@ else if (VISIBILITE.isSameContent(res)) { res = VISIBILITE; } + else if (COMMENTAIRE_HYDRO.isSameContent(res)) { + res = COMMENTAIRE_HYDRO; + } } return res; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStCnFileFormat.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStCnFileFormat.java 2009-01-30 18:59:41 UTC (rev 4432) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStCnFileFormat.java 2009-02-02 09:48:56 UTC (rev 4433) @@ -25,6 +25,9 @@ */ public class RubarStCnFileFormat extends FileFormatUnique { + /** Commentaire hydro PK. Utilis\xE9 pour transporter les infos de l'import vers l'export. */ + public static final String COMM_HYDRO_PK="PK"; + public RubarStCnFileFormat() { super(1); extensions_ = new String[] { "st", "cn", "m", "sem" }; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStReader.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStReader.java 2009-01-30 18:59:41 UTC (rev 4432) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStReader.java 2009-02-02 09:48:56 UTC (rev 4433) @@ -75,6 +75,7 @@ final List<LineString> lignes = new ArrayList<LineString>(200); final List<String> names=new ArrayList<String>(200); + final List<String> pks=new ArrayList<String>(200); final List<Coordinate> coordinatesEnCours = new ArrayList<Coordinate>(); // Contient les listes de coordonn\xE9es pour les lignes directrices (Map<String,ArrayList<Coordinate>> en Java 1.5) final Map<String, List<Coordinate>> mdirs=new HashMap<String, List<Coordinate>>(20); @@ -83,12 +84,14 @@ final int[] fmt1Line=new int[]{6,6,6,6,13,1,42}; Coordinate last = null; String name=""; + String pk=""; try { while (true) { if (isSt_) { in_.readFields(fmt1Line); name=in_.stringField(6).trim(); + pk=RubarStCnFileFormat.COMM_HYDRO_PK+"="+in_.stringField(4).trim(); } String first = CtuluLibString.EMPTY_STRING; String sec = CtuluLibString.EMPTY_STRING; @@ -119,6 +122,7 @@ final LineString str = GISLib.createLineOrLinearFromList(coordinatesEnCours); if (str != null) { lignes.add(str); + pks.add(pk); if ("".equals(name)) { names.add(CtuluLib.getS(isSt_?"P":"N")+((GISGeometry)str).getId()); } @@ -149,7 +153,9 @@ if (lignes.size() > 0) { final GISZoneCollectionLigneBrisee zligs = new GISZoneCollectionLigneBrisee(null); zligs.addAllLineStringClosedOrNode((LineString[]) lignes.toArray(new LineString[lignes.size()]), null); - zligs.setAttributes(new GISAttributeInterface[] { GISAttributeConstants.BATHY, GISAttributeConstants.TITRE, GISAttributeConstants.NATURE}, null); + zligs.setAttributes(new GISAttributeInterface[] { + GISAttributeConstants.BATHY, GISAttributeConstants.TITRE, + GISAttributeConstants.NATURE, GISAttributeConstants.COMMENTAIRE_HYDRO}, null); if(zligs.getAttributeIsZ()==null) zligs.setAttributeIsZ(GISAttributeConstants.BATHY); zligs.postImport(0); @@ -159,6 +165,13 @@ for (int i=0; i<names.size(); i++) { attmod.setObject(i,attmod.getAttribute().createDataForGeom(names.get(i),1),null); } + + // Affectation de l'attribut commentaire hydro. + attmod=zligs.getModel(GISAttributeConstants.COMMENTAIRE_HYDRO); + for (int i=0; i<pks.size(); i++) { + attmod.setObject(i,attmod.getAttribute().createDataForGeom(pks.get(i),1),null); + } + // Affectation de l'attribut nature attmod=zligs.getModel(GISAttributeConstants.NATURE); for (int i=0; i<attmod.getSize(); i++) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStWriter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStWriter.java 2009-01-30 18:59:41 UTC (rev 4432) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStWriter.java 2009-02-02 09:48:56 UTC (rev 4433) @@ -48,6 +48,31 @@ } /** + * Retourne la valeur pour une propri\xE9t\xE9 hydraulique de type double. + * @param _comm Commentaire hydro sous la forme "<prop1>=<val>; <prop2>=<val>" + * @param _prop La propri\xE9t\xE9 a extraire. + * @return La valeur de la propri\xE9t\xE9. + */ + private double getHydroCommentDouble(String _comm, String _prop) { + double r=0; + + if (_comm!=null && !_comm.trim().equals("")) { + for (String cpl : _comm.split(";")) { + String[] nameval=cpl.split("="); + if (nameval.length==2 && nameval[0].equalsIgnoreCase(_prop)) { + try { + r=Double.parseDouble(nameval[1]); + break; + } + // En cas d'erreur, retourne 0. + catch (NumberFormatException _exc) {} + } + } + } + return r; + } + + /** * Ecrit les profils et les lignes directrices. * param _o Un tableau GISDataModel[2]. * [0] : le modele des profils (ou null si aucun profil), @@ -68,6 +93,7 @@ // profs_ = ((GISDataModel[])_o)[0]; final int attName=profs_.getIndiceOf(GISAttributeConstants.TITRE); + final int attPk=profs_.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO); final int attNameLines=bldirs?lines.getIndiceOf(GISAttributeConstants.TITRE):-1; final int[] fmtEntete = new int[] { 6, 6, 6, 6, 13, 1, 42 }; @@ -81,13 +107,18 @@ for (int i = 0; i < profs_.getNumGeometries(); i++) { HashMap<Integer,ArrayList<Integer>> pts2ld=bldirs?pts2lds_[i]:null; String name; + double pk=0; final CoordinateSequence str = ((LineString) profs_.getGeometry(i)).getCoordinateSequence(); if (isSt_) { if (attName==-1||(name=(String)profs_.getValue(attName, i))==null) name=""; + // PK, issu du commentaire hydrualique. + if (attPk!=-1) { + pk=getHydroCommentDouble((String)profs_.getValue(attPk, i),RubarStCnFileFormat.COMM_HYDRO_PK); + } writer.setSpaceBefore(false); writer.stringField(6, name); writer.stringField(5, ""); - writer.doubleField(4, 0); + writer.doubleField(4, pk); writer.intField(3, str.size()); writer.intField(2, 0); writer.intField(1, 0); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dProfile.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dProfile.java 2009-01-30 18:59:41 UTC (rev 4432) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dProfile.java 2009-02-02 09:48:56 UTC (rev 4433) @@ -31,6 +31,7 @@ GISAttributeConstants.ETAT_GEOM, GISAttributeConstants.TITRE, GISAttributeConstants.NATURE, + GISAttributeConstants.COMMENTAIRE_HYDRO, GISAttributeConstants.VISIBILITE }; // Pas de container de commande pour cette op\xE9ration, sinon conserv\xE9 en undo/redo. Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerExporter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerExporter.java 2009-01-30 18:59:41 UTC (rev 4432) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerExporter.java 2009-02-02 09:48:56 UTC (rev 4433) @@ -195,11 +195,11 @@ int idxAtt=col.getIndiceOf(GISAttributeConstants.NATURE); if (idxAtt==-1) { mdlautres.add(GISDataModelFilterAdapter.buildAdapter(_filter.getCollect(_filter.polyCq_.get(i)), - new GISAttributeInterface[]{GISAttributeConstants.TITRE})); + new GISAttributeInterface[]{GISAttributeConstants.TITRE, GISAttributeConstants.COMMENTAIRE_HYDRO})); } else { GISDataModel mdl=GISDataModelFilterAdapter.buildAdapter(_filter.getCollect(_filter.polyCq_.get(i)), - new GISAttributeInterface[]{GISAttributeConstants.TITRE, GISAttributeConstants.NATURE}); + new GISAttributeInterface[]{GISAttributeConstants.TITRE, GISAttributeConstants.NATURE, GISAttributeConstants.COMMENTAIRE_HYDRO}); if (GISAttributeConstants.ATT_NATURE_CN.equals(col.getValue(idxAtt, 0))) { mdlniv.add(mdl); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bma...@us...> - 2009-02-04 17:31:37
|
Revision: 4440 http://fudaa.svn.sourceforge.net/fudaa/?rev=4440&view=rev Author: bmarchan Date: 2009-02-04 17:31:34 +0000 (Wed, 04 Feb 2009) Log Message: ----------- Tache #156 : Ajout d'un sommet a l'extr?\195?\169mit?\195?\169 d'un polyligne Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionGeometry.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionMultiPoint.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueClickInteraction.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueClikInteractionListener.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/action/CalqueGISEditionAction.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/BPaletteEdition.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueEditable.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueLigneBriseeEditable.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueMultiPointEditable.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalquePointEditable.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditorDefault.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleLigneBriseeEditable.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleMultiPointEditable.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlEditionManager.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSigImageWizardStepCalage.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/rubar/TrRubarLimniSaisie.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/rubar/TrRubarOuvrageSaisie.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrTelemacSourceSaisie.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionGeometry.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionGeometry.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionGeometry.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -116,29 +116,31 @@ } /** - * Ajoute un sommet a une g\xE9om\xE9trie. + * Ajoute un sommet a une g\xE9om\xE9trie. Les attributs atomiques sont ajout\xE9s au sommet ins\xE9r\xE9, par interpolation. * @param _idxGeom L'index de la g\xE9om\xE9trie - * @param _idxBefore L'indice du point juste avant. + * @param _idxBefore L'indice du point juste avant. Si _idxBefore est \xE9gal \xE0 -1, le point est ajout\xE9 en d\xE9but de g\xE9om\xE9trie * @param _x La coordonn\xE9e X du sommet ajout\xE9. - * @param _y LA coordonn\xE9e Y du sommet ajout\xE9. + * @param _y La coordonn\xE9e Y du sommet ajout\xE9. * @param _cmd Le manager de commandes. */ public void addAtomic(final int _idxGeom, final int _idxBefore, final double _x, final double _y, final CtuluCommandContainer _cmd) { + if (!isGeomModifiable_) { return; } Geometry geom = (Geometry)super.geometry_.getValueAt(_idxGeom); final Coordinate[] oldcs = geom.getCoordinates(); final int initSize = oldcs.length; - if(_idxBefore<0||_idxBefore>=initSize) + if(_idxBefore<-1||_idxBefore>=initSize) throw new IllegalArgumentException("L'index du point \xE0 ajouter doit appartenir \xE0 la g\xE9om\xE9trie."); final Coordinate[] cs = new Coordinate[initSize + 1]; int idx = 0; - for (int i = 0; i < initSize; i++) { - cs[idx++] = (Coordinate)oldcs[i].clone(); + for (int i = -1; i < initSize; i++) { + if (i>=0) + cs[idx++] = (Coordinate)oldcs[i].clone(); if (i == _idxBefore) { - cs[idx++] = new Coordinate(_x, _y, oldcs[i].z); + cs[idx++] = new Coordinate(_x, _y, 0.); } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionMultiPoint.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionMultiPoint.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionMultiPoint.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -82,7 +82,7 @@ newIdxOldIdx.put(idx,i); // Pour les attributs cs[idx++] = (Coordinate)oldcs[i].clone(); if (i == _idxBefore) { - cs[idx++] = new Coordinate(_x, _y, oldcs[i].z); + cs[idx++] = new Coordinate(_x, _y, 0); } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueClickInteraction.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueClickInteraction.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueClickInteraction.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -12,14 +12,20 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; +import org.fudaa.ebli.geometrie.GrPoint; + /** * @author Fred Deniger * @version $Id: ZCalqueClickInteraction.java,v 1.10.8.1 2008-03-27 15:26:28 bmarchan Exp $ */ public class ZCalqueClickInteraction extends BCalqueInteraction implements MouseListener, - MouseMotionListener { + MouseMotionListener, ZCatchListener { ZCalqueClikInteractionListener listener_; + /** Le point d'accrochage, ou null si pas de point d'accrochage */ + GrPoint ptAccroch_=null; + /** Le point interm\xE9diaire */ + GrPoint ptTmp_=new GrPoint(); public ZCalqueClickInteraction() { setName("cqInteractClicked"); @@ -48,7 +54,14 @@ public void mouseClicked(final MouseEvent _e){ if (isOkLeftEvent(_e) && (listener_ != null)) { - listener_.pointClicked(_e.getX(), _e.getY()); + if (ptAccroch_==null) { + ptTmp_.setCoordonnees(_e.getX(), _e.getY(),0); + ptTmp_.autoApplique(getVersReel()); + } + else { + ptTmp_.setCoordonnees(ptAccroch_.x_, ptAccroch_.y_, ptAccroch_.z_); + } + listener_.pointClicked(ptTmp_); } } @@ -67,4 +80,11 @@ public final void setListener(final ZCalqueClikInteractionListener _listener){ listener_ = _listener; } + + public void catchChanged(ZCatchEvent _evt) { + if (_evt.type==ZCatchEvent.UNCAUGHT) + ptAccroch_=null; + else + ptAccroch_=_evt.selection.getScene().getVertex(_evt.idxGeom, _evt.idxVertex); + } } \ No newline at end of file Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueClikInteractionListener.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueClikInteractionListener.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueClikInteractionListener.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -7,13 +7,20 @@ */ package org.fudaa.ebli.calque; +import org.fudaa.ebli.geometrie.GrPoint; + /** + * Un listener du calque {@link ZCalqueClickInteraction}. * @author Fred Deniger * @version $Id: ZCalqueClikInteractionListener.java,v 1.4 2006-04-12 15:27:10 deniger Exp $ */ public interface ZCalqueClikInteractionListener { - void pointClicked(int _xEcran,int _yEcran); + /** + * Le point 3D saisi (la coordonn\xE9e Z peut provenir d'un sommet accroch\xE9), en coordonn\xE9es r\xE9elles. + * @param _ptReel Le point saisi. + */ + void pointClicked(GrPoint _ptReel); } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/action/CalqueGISEditionAction.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/action/CalqueGISEditionAction.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/action/CalqueGISEditionAction.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -17,6 +17,8 @@ import org.fudaa.ebli.calque.BCalqueInteraction; import org.fudaa.ebli.calque.ZScene; +import org.fudaa.ebli.calque.ZSelectionEvent; +import org.fudaa.ebli.calque.ZSelectionListener; import org.fudaa.ebli.calque.edition.BPaletteEdition; import org.fudaa.ebli.calque.edition.ZCalqueEditable; import org.fudaa.ebli.calque.edition.ZCalqueEditionInteraction; @@ -30,7 +32,7 @@ * @author Fred Deniger * @version $Id: CalqueGISEditionAction.java,v 1.6.6.2 2008-05-13 12:10:47 emartin Exp $ */ -public class CalqueGISEditionAction extends EbliActionPaletteTreeModel implements PropertyChangeListener { +public class CalqueGISEditionAction extends EbliActionPaletteTreeModel implements PropertyChangeListener, ZSelectionListener { private ZEditorDefault editor_; private ZScene scene_; @@ -61,6 +63,7 @@ setEnabled(isTargetValid(null)); setResizable(true); target_ = (target_ instanceof ZCalqueEditable)?target_:null; + _scene.addSelectionListener(this); } protected boolean isTargetValid(final Object _o) { @@ -167,4 +170,13 @@ if(editor_.getPanel().getController().getCqSelectionI()!=null) editor_.getPanel().getController().getCqSelectionI().setGele(false); } + + /* (non-Javadoc) + * @see org.fudaa.ebli.calque.ZSelectionListener#selectionChanged(org.fudaa.ebli.calque.ZSelectionEvent) + */ + public void selectionChanged(ZSelectionEvent _evt) { + if (editor_!=null) { + editor_.updatePaletteWhenSelectionChanged(); + } + } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/BPaletteEdition.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/BPaletteEdition.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/BPaletteEdition.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -301,7 +301,7 @@ _target.add(null); bt = new BuToolToggleButton(); bt.setActionCommand("ATOME_ADD"); - bt.setToolTipText(EbliLib.getS("Ajouter un sommet (la g\xE9om\xE9trie doit \xEAtre s\xE9lectionn\xE9e)")); + bt.setToolTipText(EbliLib.getS("Ajouter un sommet (une g\xE9om\xE9trie, un sommet extr\xE9mit\xE9 ou 2 sommets cons\xE9cutifs doivent \xEAtre s\xE9lectionn\xE9s)")); bt.setIcon(EbliResource.EBLI.getToolIcon("node-add")); decoreButton(bt); group.add(bt); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueEditable.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueEditable.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueEditable.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -14,6 +14,7 @@ import org.fudaa.ebli.calque.ZCalqueAffichageDonneesInterface; import org.fudaa.ebli.geometrie.GrObjet; +import org.fudaa.ebli.geometrie.GrPoint; import org.fudaa.ebli.trace.TraceIcon; /** @@ -103,13 +104,12 @@ * Ajoute un sommet a l'objet selectionn\xE9. Si le nombre d'objets selectionn\xE9s est diff\xE9rent de 1, * le point n'est pas ajout\xE9. * - * @param _xEcran le x ecran de l'atome a ajouter - * @param _yEcran le y ecran de l'atome a ajouter + * @param _ptReel le point 3D r\xE9el de l'atome a ajouter * @param _cmd le receveur de command * @param _ui l'interface utilisateur * @return true si atome ajoute */ - boolean addAtome(int _xEcran,int _yEcran,CtuluCommandContainer _cmd, CtuluUI _ui); + boolean addAtome(GrPoint _ptReel, CtuluCommandContainer _cmd, CtuluUI _ui); /** * @return true si le mode atomique est autorise */ Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueLigneBriseeEditable.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueLigneBriseeEditable.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueLigneBriseeEditable.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -15,7 +15,6 @@ import org.fudaa.ctulu.CtuluCommandContainer; import org.fudaa.ctulu.CtuluListSelectionInterface; import org.fudaa.ctulu.CtuluUI; -import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ebli.calque.ZCalqueLigneBrisee; import org.fudaa.ebli.calque.ZModeleLigneBrisee; import org.fudaa.ebli.calque.dessin.DeForme; @@ -53,10 +52,6 @@ return editor_ == null ? EbliLib.getS("Edition impossible") : editor_.edit(); } - private void addPoint(final int _ligneIdx, final int _idxBefore, final double _x, final double _y, final CtuluCommandContainer _cmd) { - getModelePoly().addPoint(_ligneIdx, _idxBefore, _x, _y, _cmd); - } - /** * Scinde en 2 une polyligne dont deux sommets cons\xE9cutifs sont s\xE9lectionn\xE9. Les attributs sont copi\xE9s. * @param _cmd La pile de commandes. @@ -162,45 +157,93 @@ } } - public boolean addAtome(final int _xEcran, final int _yEcran, final CtuluCommandContainer _cmd, final CtuluUI _ui) { - if (isAtomicMode() || getNbSelected()!=1) return false; + /** + * Ajoute un sommet a l'objet selectionn\xE9. Le sommet peut \xEAtre ajout\xE9 en bout de ligne, si un point extremit\xE9 est selectionn\xE9, + * ou bien inser\xE9 si 2 sommets s\xE9lectionn\xE9s. + * + * Si le nombre d'objets selectionn\xE9s est diff\xE9rent de 1, le point n'est pas ajout\xE9. + * + * @param _ptReel le point 3D r\xE9el de l'atome a ajouter + * @param _cmd le receveur de command + * @param _ui l'interface utilisateur + * @return true si atome ajoute + */ + public boolean addAtome(final GrPoint _ptReel, final CtuluCommandContainer _cmd, final CtuluUI _ui) { + if (getNbSelected()!=1) return false; +// if (isAtomicMode() || getNbSelected()!=1) return false; - final GrMorphisme versEcran = getVersEcran(); - final GrMorphisme versReel = getVersReel(); - final GrBoite bClip = getDomaine(); - bClip.autoApplique(versEcran); - final int tolerance = 5; - // Point \xE0 projeter - final GrPoint pt = new GrPoint(_xEcran, _yEcran, 0); - if ((!bClip.contientXY(pt)) && (bClip.distanceXY(pt) > tolerance)) { - return false; + if (isAtomicMode()) { + int idxGeom=selectionMulti_.getIdxSelected()[0]; + int idxBefore; + + if (selectionMulti_.getNbSelectedItem()==1) { + // Cas d'un polygone => Interdit d'ajouter un point en fin de g\xE9om\xE9trie. + if (getModelePoly().isGeometryFermee(idxGeom)) return false; + + if (selectionMulti_.getSelection(idxGeom).getMinIndex()==0) + idxBefore=-1; + else if (selectionMulti_.getSelection(idxGeom).getMaxIndex()==getModelePoly().getGeomData().getGeometry(idxGeom).getNumPoints()-1) + idxBefore=selectionMulti_.getSelection(idxGeom).getMaxIndex(); + else + return false; + } + else if (selectionMulti_.getNbSelectedItem()==2) { + if (selectionMulti_.getSelection(idxGeom).getMaxIndex()==selectionMulti_.getSelection(idxGeom).getMinIndex()+1) + idxBefore=selectionMulti_.getSelection(idxGeom).getMinIndex(); + else + return false; + } + else { + return false; + } + + getModelePoly().addPoint(idxGeom,idxBefore, _ptReel.x_, _ptReel.y_, _ptReel.z_, _cmd); + return true; } - final double distanceReel = GrMorphisme.convertDistanceXY(versReel, tolerance); - final GrPoint ptToTest = pt.applique(versReel); - final GrSegment seg = new GrSegment(new GrPoint(), new GrPoint()); - final GrBoite bPoly = new GrBoite(new GrPoint(), new GrPoint()); - int i=selection_.getMinIndex(); - modele_.getDomaineForGeometry(i, bPoly); - if (bPoly.contientXY(ptToTest)||bPoly.distanceXY(ptToTest)<distanceReel) { - for (int j=modele_.getNbPointForGeometry(i)-1; j>0; j--) { - modele_.point(seg.e_, i, j); - modele_.point(seg.o_, i, j-1); - if (seg.distanceXY(ptToTest)<distanceReel) { - addPoint(i, j-1, ptToTest.x_, ptToTest.y_, _cmd); - return true; - } + // En mode non atomique, le point ajout\xE9 est obligatoirement sur la polyligne. + else { + final GrMorphisme versEcran=getVersEcran(); + final GrMorphisme versReel=getVersReel(); + final GrBoite bClip=getDomaine(); + bClip.autoApplique(versEcran); + final int tolerance=5; + // Point \xE0 projeter + // final GrPoint pt = new GrPoint(_xEcran, _yEcran, 0); + final GrPoint ptEcran=_ptReel.applique(versEcran); + if ((!bClip.contientXY(ptEcran))&&(bClip.distanceXY(ptEcran)>tolerance)) { + return false; } - if (modele_.isGeometryFermee(i)) { - modele_.point(seg.e_, i, 0); - modele_.point(seg.o_, i, modele_.getNbPointForGeometry(i)-1); - if (seg.distanceXY(ptToTest)<distanceReel) { - addPoint(i, modele_.getNbPointForGeometry(i)-1, ptToTest.x_, ptToTest.y_, _cmd); - return true; + + final double distanceReel=GrMorphisme.convertDistanceXY(versReel, tolerance); + // final GrPoint _ptReel = pt.applique(versReel); + final GrSegment seg=new GrSegment(new GrPoint(), new GrPoint()); + final GrBoite bPoly=new GrBoite(new GrPoint(), new GrPoint()); + + int i=selection_.getMinIndex(); + modele_.getDomaineForGeometry(i, bPoly); + if (bPoly.contientXY(_ptReel)||bPoly.distanceXY(_ptReel)<distanceReel) { + for (int j=modele_.getNbPointForGeometry(i)-1; j>0; j--) { + modele_.point(seg.e_, i, j); + modele_.point(seg.o_, i, j-1); + if (seg.distanceXY(_ptReel)<distanceReel) { + GrPoint ptOnSeg=seg.pointPlusProcheXY(_ptReel); + getModelePoly().addPoint(i, j-1, ptOnSeg.x_, ptOnSeg.y_, null, _cmd); + return true; + } } + if (modele_.isGeometryFermee(i)) { + modele_.point(seg.e_, i, 0); + modele_.point(seg.o_, i, modele_.getNbPointForGeometry(i)-1); + if (seg.distanceXY(_ptReel)<distanceReel) { + GrPoint ptOnSeg=seg.pointPlusProcheXY(_ptReel); + getModelePoly().addPoint(i, modele_.getNbPointForGeometry(i)-1, ptOnSeg.x_, ptOnSeg.y_, null, _cmd); + return true; + } + } } + return false; } - return false; } public boolean addForme(final GrObjet _o, final int _deforme, final CtuluCommandContainer _cmd, final CtuluUI _ui, Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueMultiPointEditable.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueMultiPointEditable.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalqueMultiPointEditable.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -15,6 +15,7 @@ import org.fudaa.ctulu.CtuluCommandContainer; import org.fudaa.ctulu.CtuluListSelectionInterface; import org.fudaa.ctulu.CtuluUI; +import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; import org.fudaa.ctulu.gis.GISGeometryFactory; import org.fudaa.ctulu.gis.GISMultiPoint; @@ -88,19 +89,17 @@ // return getModelePoly().joinGeometries(idxLines, idxSels, _cmd)!=-1; // } - public boolean addAtome(final int _xEcran, final int _yEcran, final CtuluCommandContainer _cmd, final CtuluUI _ui) { - if (isAtomicMode() || getNbSelected()!=1) return false; + public boolean addAtome(final GrPoint _ptReel, final CtuluCommandContainer _cmd, final CtuluUI _ui) { + if (getNbSelected()!=1) return false; - final GrMorphisme versEcran = getVersEcran(); - final GrMorphisme versReel = getVersReel(); - - final GrBoite bClip = getDomaineOnSelected(); - bClip.autoApplique(versEcran); - final GrPoint pt = new GrPoint(_xEcran, _yEcran, 0); - final GrPoint ptToTest = pt.applique(versReel); - - int idx=selection_.getMinIndex(); - ((ZModeleMultiPointEditable)modele_).addAtomic(idx,0, ptToTest.x_, ptToTest.y_, _cmd); + int idx; + if (isAtomicMode()) + idx=selectionMulti_.getIdxSelected()[0]; + else + idx=selection_.getMinIndex(); + + int idxBefore=modeleDonnees().getGeomData().getGeometry(idx).getNumGeometries()-1; + ((ZModeleMultiPointEditable)modele_).addAtomic(idx,idxBefore, _ptReel.x_, _ptReel.y_, _ptReel.z_, _cmd); return true; } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalquePointEditable.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalquePointEditable.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZCalquePointEditable.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -21,7 +21,6 @@ import org.fudaa.ctulu.CtuluLibArray; import org.fudaa.ctulu.CtuluUI; import org.fudaa.ctulu.gis.GISAttributeInterface; -import org.fudaa.ctulu.gis.GISAttributeModel; import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ebli.calque.ZCalquePoint; @@ -105,7 +104,7 @@ editor_ = _editor; } - public boolean addAtome(final int _xEcran, final int _yEcran, final CtuluCommandContainer _cmd, final CtuluUI _ui) { + public boolean addAtome(final GrPoint _ptReel, final CtuluCommandContainer _cmd, final CtuluUI _ui) { return false; } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditorDefault.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditorDefault.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditorDefault.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -24,12 +24,15 @@ import javax.swing.KeyStroke; import javax.swing.SwingUtilities; +import org.fudaa.ctulu.CtuluCommandComposite; import org.fudaa.ctulu.CtuluCommandManager; import org.fudaa.ctulu.CtuluCommandPersitant; import org.fudaa.ctulu.CtuluLib; import org.fudaa.ctulu.CtuluListSelectionInterface; import org.fudaa.ctulu.CtuluUI; +import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; import org.fudaa.ctulu.gis.GISGuiBuilder; +import org.fudaa.ctulu.gis.GISMultiPoint; import org.fudaa.ctulu.gis.GISZoneCollectionPoint; import org.fudaa.ctulu.gui.CtuluDialogPanel; import org.fudaa.ctulu.gui.CtuluLibSwing; @@ -41,6 +44,7 @@ import org.fudaa.ebli.calque.ZEbliCalquesPanel; import org.fudaa.ebli.calque.ZModeleGeometry; import org.fudaa.ebli.calque.ZScene; +import org.fudaa.ebli.calque.ZScene.SceneSelectionHelper; import org.fudaa.ebli.calque.dessin.DeForme; import org.fudaa.ebli.commun.EbliActionInterface; import org.fudaa.ebli.commun.EbliActionSimple; @@ -50,6 +54,7 @@ import org.fudaa.ebli.geometrie.GrPoint; import org.fudaa.ebli.geometrie.GrPolygone; import org.fudaa.ebli.geometrie.GrPolyligne; +import org.fudaa.ebli.ressource.EbliResource; import org.fudaa.ebli.trace.TraceIcon; import com.memoire.bu.BuDesktop; @@ -80,11 +85,16 @@ class NodeAddListener implements ZCalqueClikInteractionListener { - public void pointClicked(final int _xEcran, final int _yEcran) { + public void pointClicked(GrPoint _ptReel) { if (getSupport().canUseAtomicMode()) { int idGeom=getSupport().getSelectionHelper().getUniqueSelectedIdx(); - if(idGeom!=-1) - ((ZCalqueEditable)getSupport().getLayerForId(idGeom)).addAtome(_xEcran, _yEcran, mng_, null); + if(idGeom!=-1) { + CtuluCommandComposite cmp=new CtuluCommandComposite(EbliLib.getS("Ajout d'un sommet")); + if (((ZCalqueEditable)getSupport().getLayerForId(idGeom)).addAtome(_ptReel, cmp, null)) { + if (mng_!=null) + mng_.addCmd(cmp.getSimplify()); + } + } } } } @@ -344,7 +354,8 @@ palette_.setEnable("GLOBAL_ADD_SEMIS", target_.canAddForme(DeForme.MULTI_POINT) && isModifiable); } -// updatePaletteState(); + + updatePaletteWhenSelectionChanged(); palette_.checkEnableAndCheckBt(); final AbstractButton bt = palette_.getSelectedButton(); if (bt == null) { @@ -353,7 +364,40 @@ changeState(bt.getActionCommand()); } } + + public void updatePaletteWhenSelectionChanged() { + if (palette_==null) return; + + ZScene scn=getSupport(); + SceneSelectionHelper hlp=scn.getSelectionHelper(); + int idGeom=-1; + boolean b=true; + // Si la selection est sur le m\xEAme objet. + b=b && (idGeom=hlp.getUniqueSelectedIdx())!=-1; + // Si le nombre d'atomiques est de 2 cons\xE9cutifs sur une g\xE9om\xE9trie de type polyligne. + if (b && scn.isAtomicMode()) { + if (scn.getObject(idGeom) instanceof GISCoordinateSequenceContainerInterface) { + GISCoordinateSequenceContainerInterface geom=(GISCoordinateSequenceContainerInterface)scn.getObject(idGeom); + if (!(geom instanceof GISMultiPoint)) { + if (hlp.getNbAtomicSelected()==1) { + b=b + &&(hlp.getUniqueAtomicSelection().getMinIndex()==0||hlp.getUniqueAtomicSelection().getMaxIndex()+1==geom + .getCoordinateSequence().size()); + } + else if (hlp.getNbAtomicSelected()==2) { + b=b&&Math.abs(hlp.getUniqueAtomicSelection().getMinIndex()-hlp.getUniqueAtomicSelection().getMaxIndex())==1; + } + else { + b=false; + } + } + } + } + + palette_.setEnable("ATOME_ADD", b); + } + protected boolean changeState(final String _s) { // Pas de changement: le cas null,null et meme etat if (_s == state_ || (_s != null && _s.equals(state_))) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleLigneBriseeEditable.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleLigneBriseeEditable.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleLigneBriseeEditable.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -27,6 +27,7 @@ import org.fudaa.ctulu.CtuluListSelectionInterface; import org.fudaa.ctulu.CtuluUI; import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ctulu.gis.GISAttributeDouble; import org.fudaa.ctulu.gis.GISAttributeInterface; import org.fudaa.ctulu.gis.GISAttributeModel; import org.fudaa.ctulu.gis.GISAttributeModelDoubleArray; @@ -271,20 +272,35 @@ CtuluLibString.DEUX); } - public void addPoint(final int _ligneIdx,final int _idxBefore,final double _x,final double _y,final CtuluCommandContainer _cmd){ + /** + * Ajoute un sommet 3D \xE0 une g\xE9om\xE9trie. + * @param _ligneIdx L'indice de la g\xE9om\xE9trie + * @param _idxBefore L'indice de sommet pr\xE9c\xE9dent pour l'insertion. Peut \xEAtre \xE9gal \xE0 -1. + * @param _x La coordonn\xE9e X du sommet \xE0 inserer + * @param _y La coordonn\xE9e Y du sommet \xE0 inserer + * @param _z La coordonn\xE9e Z du sommet \xE0 inserer. Peut \xEAtre null. Dans ce cas, le z est interpol\xE9 depuis les autres valeurs. + * @param _cmd Le container de commande. + */ + public void addPoint(final int _ligneIdx,final int _idxBefore,final double _x,final double _y,final Double _z,final CtuluCommandContainer _cmd){ if (geometries_ == null) { return; } - final CoordinateSequence g = ((LineString) geometries_.getGeometry(_ligneIdx)) - .getCoordinateSequence(); + + CtuluCommandComposite cmp=new CtuluCommandComposite(); + // Modification de l'\xE9tat de la g\xE9om\xE9trie - setGeomModif(_ligneIdx, _cmd); - // Cr\xE9ation du segment d\xE9fini par les deux point de la forme - // Construction du point projet\xE9 grace \xE0 'pointPlusProche' - GrPoint point = (new GrSegment(new GrPoint(g.getX(_idxBefore), g.getY(_idxBefore), 0), - new GrPoint(g.getX(_idxBefore + 1), g.getY(_idxBefore + 1), 0))) - .pointPlusProche(new GrPoint(_x, _y, 0)); - geometries_.addAtomic(_ligneIdx, _idxBefore, point.x_, point.y_, _cmd); + setGeomModif(_ligneIdx, cmp); + geometries_.addAtomic(_ligneIdx, _idxBefore, _x, _y, cmp); + + // Mise a jour du Z si necessaire. + GISAttributeInterface attZ=geometries_.getAttributeIsZ(); + if (_z!=null && attZ!=null && attZ.isAtomicValue()) { + GISAttributeModel md=(GISAttributeModel)geometries_.getModel(attZ).getObjectValueAt(_ligneIdx); + md.setObject(_idxBefore+1, _z, cmp); + } + + if (_cmd!=null) + _cmd.addCmd(cmp.getSimplify()); } /** Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleMultiPointEditable.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleMultiPointEditable.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleMultiPointEditable.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -333,18 +333,32 @@ } /** - * Ajoute un sommet X,Y \xE0 la g\xE9om\xE9trie donn\xE9e.<p> + * Ajoute un sommet X,Y,Z \xE0 la g\xE9om\xE9trie donn\xE9e.<p> * <b>ATTENTION</b> : Les valeurs des attributs pour ce sommet sont d\xE9finies par d\xE9faut. * @param _idxGeom La g\xE9om\xE9trie modifi\xE9e. * @param _idxBefore Le sommet qui sera le pr\xE9cedent de celui ajout\xE9. * @param _x La coordonn\xE9e X du point. * @param _y La coordonn\xE9e Y du point. + * @param _z La coordonn\xE9e Z du point. * @param _cmd Le manager de commandes. */ - public void addAtomic(final int _idxGeom,final int _idxBefore,final double _x,final double _y,final CtuluCommandContainer _cmd){ + public void addAtomic(final int _idxGeom,final int _idxBefore,final double _x,final double _y, final double _z,final CtuluCommandContainer _cmd){ if (geometries_ == null) return; + + CtuluCommandComposite cmp=new CtuluCommandComposite(); + setGeomModif(_idxGeom, _cmd); // Modification de l'\xE9tat de la g\xE9om\xE9trie geometries_.addAtomic(_idxGeom, _idxBefore, _x, _y, _cmd); + + // Mise a jour du Z si necessaire. + GISAttributeInterface attZ=geometries_.getAttributeIsZ(); + if (attZ!=null && attZ.isAtomicValue()) { + GISAttributeModel md=(GISAttributeModel)geometries_.getModel(attZ).getObjectValueAt(_idxGeom); + md.setObject(_idxBefore+1, _z, cmp); + } + + if (_cmd!=null) + _cmd.addCmd(cmp.getSimplify()); } protected GISZoneCollectionMultiPoint createCollection(){ Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlEditionManager.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlEditionManager.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlEditionManager.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -192,8 +192,8 @@ palette_.setEnable("GLOBAL_ADD_ELLIPSE", target_.canAddForme(DeForme.ELLIPSE) && isModifiable); palette_.setEnable("GLOBAL_ADD_POLYGONE", target_.canAddForme(DeForme.POLYGONE) && isModifiable); palette_.setEnable("GLOBAL_ADD_SEMIS", target_.canAddForme(DeForme.MULTI_POINT) && isModifiable); - } + updatePaletteWhenSelectionChanged(); palette_.checkEnableAndCheckBt(); final AbstractButton bt = palette_.getSelectedButton(); if (bt == null) { @@ -202,5 +202,4 @@ changeState(bt.getActionCommand()); } } - } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSigImageWizardStepCalage.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSigImageWizardStepCalage.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSigImageWizardStepCalage.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -30,7 +30,6 @@ import org.fudaa.ctulu.image.RasterDataInterface; import org.fudaa.ebli.calque.BVueCalque; -import org.fudaa.ebli.calque.ZCalqueAffichageDonneesInterface; import org.fudaa.ebli.calque.ZCalqueClickInteraction; import org.fudaa.ebli.calque.ZCalqueClikInteractionListener; import org.fudaa.ebli.calque.ZCalqueImageRaster; @@ -94,8 +93,8 @@ calqueClickInteraction_ = new ZCalqueClickInteraction(); calqueClickInteraction_.setListener(new ZCalqueClikInteractionListener() { - public void pointClicked(final int _xEcran, final int _yEcran) { - mouseClickedOnReal(_xEcran, _yEcran); + public void pointClicked(final GrPoint _ptReel) { + mouseClickedOnReal(_ptReel); } @@ -201,19 +200,11 @@ return FSigLib.getS("G\xE9or\xE9f\xE9rencer l'image"); } - GrPoint reel_; - - public void pointClicked(final int _xEcran, final int _yEcran) { + public void pointClicked(final GrPoint _ptReel) { if (click_.isGele()) { return; } - if (reel_ == null) { - reel_ = new GrPoint(); - } - reel_.setCoordonnees(_xEcran, _yEcran, 0); - reel_.autoApplique(image_.getVersReel()); - control_.ptClickedInImg((int) reel_.x_, (int) reel_.y_); - + control_.ptClickedInImg((int) _ptReel.x_, (int) _ptReel.y_); } public void restaurer() { @@ -243,13 +234,8 @@ // cqDest_.setCalqueInteractionActif(calqueClickInteraction_); } - public void mouseClickedOnReal(final int _x, final int _y) { - if (reel_ == null) { - reel_ = new GrPoint(); - } - reel_.setCoordonnees(_x, _y, 0); - reel_.autoApplique(cqDest_.getVueCalque().getVersReel()); - control_.ptClickedInReel(reel_.x_, reel_.y_); + public void mouseClickedOnReal(final GrPoint _ptReel) { + control_.ptClickedInReel(_ptReel.x_, _ptReel.y_); } public void setRasterData(final RasterDataInterface _data) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/rubar/TrRubarLimniSaisie.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/rubar/TrRubarLimniSaisie.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/rubar/TrRubarLimniSaisie.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -7,8 +7,6 @@ */ package org.fudaa.fudaa.tr.rubar; -import com.vividsolutions.jts.geom.Coordinate; - import org.fudaa.ctulu.CtuluLibString; import org.fudaa.ebli.calque.ZCalquePoint; @@ -32,14 +30,10 @@ super(_pn, _layer); } - GrPoint pt_ = new GrPoint(); - Coordinate m_ = new Coordinate(); - public void pointClicked(final int _xEcran,final int _yEcran){ - pt_.setCoordonnees(_xEcran, _yEcran, 0); - pt_.autoApplique(layer_.getVersReel()); + public void pointClicked(final GrPoint _ptReel){ final TrRubarLimniModel model = (TrRubarLimniModel) layer_.modeleDonnees(); - final int idxToAdd = model.mng_.getEltContaining(pt_.x_, pt_.y_); + final int idxToAdd = model.mng_.getEltContaining(_ptReel.x_, _ptReel.y_); if (idxToAdd < 0) { super.errMessage(TrResource.getS("Le point n'appartient pas \xE0 un \xE9l\xE9ment")); return; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/rubar/TrRubarOuvrageSaisie.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/rubar/TrRubarOuvrageSaisie.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/rubar/TrRubarOuvrageSaisie.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -166,20 +166,24 @@ } } - public void pointClicked(final int _xEcran, final int _yEcran) { + public void pointClicked(final GrPoint _ptReel) { + _ptReel.autoApplique(layer_.getVersEcran()); + final int xEcran=(int)_ptReel.x_; + final int yEcran=(int)_ptReel.y_; + boolean ok = false; switch (step_) { case 0: - ok = pointClickedElt1(_xEcran, _yEcran); + ok = pointClickedElt1(xEcran, yEcran); break; case 1: - ok = pointClickedArete1(_xEcran, _yEcran); + ok = pointClickedArete1(xEcran, yEcran); break; case 2: - ok = pointClickedElt2(_xEcran, _yEcran); + ok = pointClickedElt2(xEcran, yEcran); break; case 3: - ok = pointClickedArete2(_xEcran, _yEcran); + ok = pointClickedArete2(xEcran, yEcran); break; default: Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrTelemacSourceSaisie.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrTelemacSourceSaisie.java 2009-02-04 12:21:32 UTC (rev 4439) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/telemac/TrTelemacSourceSaisie.java 2009-02-04 17:31:34 UTC (rev 4440) @@ -46,13 +46,11 @@ add(bt_); } - public void pointClicked(final int _xEcran,final int _yEcran){ + public void pointClicked(final GrPoint _ptReel){ if (!editor_.valide()) { return; } - final GrPoint p = new GrPoint(_xEcran, _yEcran, 0); - p.autoApplique(nodes_.getVersReel()); - final int i = ZCalquePoint.getSelectedPoint(nodes_.modele(), p, 5, nodes_.getVersReel(), pn_.getVueCalque().getViewBoite()); + final int i = ZCalquePoint.getSelectedPoint(nodes_.modele(), _ptReel, 5, nodes_.getVersReel(), pn_.getVueCalque().getViewBoite()); if (i < 0) { infoLabel_.setText(TrResource.getS("Aucun noeud trouv\xE9")); return; @@ -63,11 +61,11 @@ infoLabel_.setText(TrResource.getS("Noeud fronti\xE8re non autoris\xE9")); return; } - nodes_.modele().point(p, i, true); + nodes_.modele().point(_ptReel, i, true); final H2dTelemacSourceMng mng = ((TrTelemacSourceLayer) layer_).getNodeModel().getMng(); final String[] val = editor_.getValues(); - val[0] = CtuluLib.DEFAULT_NUMBER_FORMAT.format(p.x_); - val[1] = CtuluLib.DEFAULT_NUMBER_FORMAT.format(p.y_); + val[0] = CtuluLib.DEFAULT_NUMBER_FORMAT.format(_ptReel.x_); + val[1] = CtuluLib.DEFAULT_NUMBER_FORMAT.format(_ptReel.y_); mng.addSource(val, pn_.getCmdMng()); pointAjouteOk(val[0], val[1]); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bma...@us...> - 2009-02-06 13:30:21
|
Revision: 4445 http://fudaa.svn.sourceforge.net/fudaa/?rev=4445&view=rev Author: bmarchan Date: 2009-02-06 13:30:12 +0000 (Fri, 06 Feb 2009) Log Message: ----------- Tache#17: Sauvegarde des attributs atomiques dans les fichiers projets. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelFeatureAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/gml/GISGMLZoneExporter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerExporter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerFilter.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelFeatureAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelFeatureAdapter.java 2009-02-05 18:21:55 UTC (rev 4444) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelFeatureAdapter.java 2009-02-06 13:30:12 UTC (rev 4445) @@ -114,8 +114,39 @@ while (it.hasNext()) { final Feature f = it.next(); geom.add(f.getDefaultGeometry()); + for (int i = 0; i < finalAttributeCount; i++) { - values[i].add(f.getAttribute(idxInFeature.getQuick(i))); + // Les attributs atomiques sont autoris\xE9s. La valeur lue sur les features doit \xEAtre sous la forme {val1,val2,val3} + if (finalAtt[i].isAtomicValue()) { + String s=(String)f.getAttribute(idxInFeature.getQuick(i)); + String[] svals=s.substring(1,s.length()-1).split(","); + for (int j=0; j<svals.length; j++) + svals[j]=svals[j].replaceAll("‚", ","); + + if (finalAtt[i].getDataClass().equals(Integer.class)) { + Integer[] vals=new Integer[svals.length]; + for (int j=0; j<vals.length; j++) vals[j]=new Integer(svals[j]); + values[i].add(finalAtt[i].createDataForGeom(vals,vals.length)); + } + else if (finalAtt[i].getDataClass().equals(Boolean.class)) { + Boolean[] vals=new Boolean[svals.length]; + for (int j=0; j<vals.length; j++) vals[j]=new Boolean(svals[j]); + values[i].add(finalAtt[i].createDataForGeom(vals,vals.length)); + } + else if (finalAtt[i].getDataClass().equals(Double.class)) { + Double[] vals=new Double[svals.length]; + for (int j=0; j<vals.length; j++) vals[j]=new Double(svals[j]); + values[i].add(finalAtt[i].createDataForGeom(vals,vals.length)); + } + else if (finalAtt[i].getDataClass().equals(String.class)) { + String[] vals=new String[svals.length]; + for (int j=0; j<vals.length; j++) vals[j]=svals[j]; + values[i].add(finalAtt[i].createDataForGeom(vals,vals.length)); + } + } + // La valeur lue est globale. + else + values[i].add(f.getAttribute(idxInFeature.getQuick(i))); } if(indexGeomAttr!=-1) indexGeom.add((Integer) f.getAttribute(indexGeomAttr)); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java 2009-02-05 18:21:55 UTC (rev 4444) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java 2009-02-06 13:30:12 UTC (rev 4445) @@ -14,6 +14,7 @@ import org.fudaa.ctulu.ProgressionUpdater; import org.fudaa.ctulu.gui.CtuluValueEditorDefaults; import org.geotools.feature.AttributeType; +import org.geotools.feature.AttributeTypeFactory; import com.memoire.fu.FuLog; import com.vividsolutions.jts.algorithm.CGAlgorithms; @@ -622,14 +623,85 @@ return true; } + /** + * Cr\xE9e un attribut a partir d'un {@link AttributeType}, utilis\xE9 dans les DataStore. + * @param _type L'attribute type. + * @return L'attribut. + * @see {@link #createAttributeFrom(GISAttributeInterface, boolean)} + */ public static GISAttributeInterface createAttributeFrom(final AttributeType _type) { final GISAttributeInterface known = GISAttributeConstants.getConstantAttribute(_type.getName()); if (known != null && known.getDataClass().equals(_type.getType())) { return known; } - return createAttributeFrom(_type.getName(), _type.getType(), false); + + String name=_type.getName(); + Class<?> clazz=_type.getType(); + boolean isAtomic=false; + + // Gestion des attributs atomiques. + if (name.startsWith("[I]")) { + clazz=Integer.class; + name=name.substring(3); + isAtomic=true; + } + else if (name.startsWith("[S]")) { + clazz=String.class; + name=name.substring(3); + isAtomic=true; + } + else if (name.startsWith("[B]")) { + clazz=Boolean.class; + name=name.substring(3); + isAtomic=true; + } + else if (name.startsWith("[D]")) { + clazz=Double.class; + name=name.substring(3); + isAtomic=true; + } + + return createAttributeFrom(name, clazz, isAtomic); } + /** + * Cr\xE9e un {@link AttributeType}, utilis\xE9 dans les DataStore a partir d'un attribut.<p> + * Les AttributeType n'autorisant pas les tableaux, les attributs atomiques sont g\xE9r\xE9s de la mani\xE8re suivante:<br> + * <ul> + * <li>Le nom de l'AttributeType (getName()) indique l'atomicit\xE9, on y adjoint le type du tableau ([I],[S],[B],[D]). + * Exemple : [I]Indices</li> + * <li>Le type de l'AttributType (getType()) est toujours String.class</li> + * <li>La valeur de l'attribut sera une chaine contenant les valeurs, s\xE9par\xE9es par des virgules.</li> + * </ul> + * + * @param _att L'attribut. + * @return L'attribute type. + */ + public static AttributeType createAttributeFrom(final GISAttributeInterface _att, boolean _useIdAsName) { + AttributeType type; + + // Pour les attributs atomique, le type d'attribut est syst\xE9matique String, le type de tableau est mis dans le nom!! + if (_att.isAtomicValue()) { + String tbType=""; + if (_att.getDataClass().equals(String.class)) + tbType="[S]"; + else if (_att.getDataClass().equals(Integer.class)) + tbType="[I]"; + else if (_att.getDataClass().equals(Double.class)) + tbType="[D]"; + else if (_att.getDataClass().equals(Boolean.class)) + tbType="[B]"; + + type=AttributeTypeFactory.newAttributeType(tbType+(_useIdAsName ? _att.getID() : _att.getName()), String.class, true, 18); + } + // 18 pour les shapefiles ...; + else { + type=AttributeTypeFactory.newAttributeType(_useIdAsName ? _att.getID() : _att.getName(), _att + .getDataClass(), true, 18); + } + return type; + } + public static GISAttributeInterface createAttributeFrom(final String _name, final Class _c, final boolean _isAtomic) { if (Number.class.isAssignableFrom(_c)) { if (Integer.class.isAssignableFrom(_c)) { @@ -645,7 +717,7 @@ return createNonNumberAttr(_name, _c, _isAtomic); } - public static GISAttributeInterface createNonNumberAttr(final String _name, final Class _c, final boolean _isAtomic) { + private static GISAttributeInterface createNonNumberAttr(final String _name, final Class _c, final boolean _isAtomic) { if (Boolean.class.isAssignableFrom(_c)) { return new GISAttributeBoolean(_name, _isAtomic); } else if (String.class.isAssignableFrom(_c)) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/gml/GISGMLZoneExporter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/gml/GISGMLZoneExporter.java 2009-02-05 18:21:55 UTC (rev 4444) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/gml/GISGMLZoneExporter.java 2009-02-06 13:30:12 UTC (rev 4445) @@ -17,7 +17,10 @@ import org.fudaa.ctulu.ProgressionInterface; import org.fudaa.ctulu.ProgressionUpdater; import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ctulu.gis.GISAttributeDouble; import org.fudaa.ctulu.gis.GISAttributeInterface; +import org.fudaa.ctulu.gis.GISAttributeModel; +import org.fudaa.ctulu.gis.GISLib; import org.fudaa.ctulu.gis.GISZoneCollection; import org.geotools.data.DataStore; import org.geotools.data.FeatureWriter; @@ -54,13 +57,23 @@ private boolean useIdAsName_; - public AttributeType[] createAttributes(final GISDataModel _zone, final TObjectIntHashMap _attrIdx) { + /** + * Cr\xE9ation de tous les attributes types a partir des attributs de la zone. L'attribut pris pour Z n'est pas + * cr\xE9\xE9, car transf\xE9r\xE9 dans le Z. + * + * @param _zone La zone. + * @param _attIsZ L'attribut pris pour Z + * @param _attrIdx Argument de sortie. Une table associant l'indice des attributs de la zone a un attribut cr\xE9\xE9. + * @return Les attributs cr\xE9es. + */ + public AttributeType[] createAttributes(final GISDataModel _zone, final GISAttributeDouble _attIsZ, final TObjectIntHashMap _attrIdx) { final int attributeNb = _zone.getNbAttributes(); final TIntArrayList attribute = new TIntArrayList(attributeNb); - // pour l'instant, les attributs atomiques (definis sur chaque sommets) ne sont pas - // support\xE9s. + for (int i = 0; i < attributeNb; i++) { - if (!_zone.getAttribute(i).isAtomicValue()) { + // Seul l'attribut pris pour Z n'est pas enregistr\xE9. + if (!_zone.getAttribute(i).equals(_attIsZ)) { +// if (!_zone.getAttribute(i).isAtomicValue()) { attribute.add(i); if (FuLog.isDebug()) { FuLog.debug("add attribute " + _zone.getAttribute(i).getID() + " classe " @@ -76,12 +89,10 @@ for (int i = 0; i < size; i++) { final int posInZone = attribute.get(i); - final GISAttributeInterface atti = _zone.getAttribute(posInZone); - // 18 pour les shapefiles ...; - atts[1 + i] = AttributeTypeFactory.newAttributeType(useIdAsName_ ? atti.getID() : atti.getName(), atti - .getDataClass(), true, 18); - _attrIdx.put(atts[i + 1], posInZone); + atts[i+1] = GISLib.createAttributeFrom(_zone.getAttribute(posInZone),useIdAsName_); + _attrIdx.put(atts[i+1], posInZone); } + // Le dernier correspond \xE0 l'index de la g\xE9om\xE9trie dans la GISZone GISAttributeInterface attInd=GISAttributeConstants.INDEX_GEOM; atts[atts.length-1]=AttributeTypeFactory.newAttributeType(attInd.getID(), attInd.getDataClass()); @@ -107,11 +118,11 @@ * @throws SchemaException * @throws IllegalAttributeException */ - public void process(final ProgressionInterface _prog, final GISDataModel _zone, final DataStore _dest) + public void process(final ProgressionInterface _prog, final GISDataModel _zone, final GISAttributeDouble _attIsZ, final DataStore _dest) throws IOException, SchemaException, IllegalAttributeException { out_ = null; store_ = _dest; - process(_prog, _zone); + process(_prog, _zone, _attIsZ); } /** @@ -129,20 +140,29 @@ out_ = _dest; store_ = null; _zone.prepareExport(); - process(_prog, _zone); - + process(_prog, _zone, _zone.getAttributeIsZ()); } - private void process(final ProgressionInterface _prog, final GISDataModel _zone) throws IOException, + /** + * Enregistre la zone sous un format GML.<p> + * + * Les attributs globaux sont enregistr\xE9s comme attributs globaux de chaque g\xE9om\xE9trie, + * l'attribut pris pour Z est enregistr\xE9 dans les coordonn\xE9es Z des g\xE9om\xE9tries.<br> + * Les attributs atomiques sont enregistr\xE9s sous forme de tableau de String, s\xE9par\xE9s par une virgule. + * + * @param _prog Progression de la tache. + * @param _zone La zone a enregistrer + * @param _attIsZ L'attrribut pris pour Z (atomique ou non). + */ + private void process(final ProgressionInterface _prog, final GISDataModel _zone, GISAttributeDouble _attIsZ) throws IOException, SchemaException, IllegalAttributeException { /* - * Pour que les z atomiques soient exporter correctement, il faut que - * prepareExport() est \xE9t\xE9 appel\xE9 sur la GISZoneCollection dans le - * GISDataModel. + * Pour que les z atomiques soient export\xE9s correctement, il faut que + * prepareExport() ait \xE9t\xE9 appel\xE9 en amont de cette m\xE9thode. */ stop_ = false; final TObjectIntHashMap attIdx = new TObjectIntHashMap(_zone.getNbAttributes()); - final AttributeType[] atts = createAttributes(_zone, attIdx); + final AttributeType[] atts = createAttributes(_zone, _attIsZ, attIdx); if (stop_) { return; } @@ -164,8 +184,24 @@ final Feature feature = writer.next(); feature.setDefaultGeometry(_zone.getGeometry(i)); for (int j = 1; j < nbAttribute-1; j++) { - feature.setAttribute(j, _zone.getValue(attIdx.get(atts[j]), i)); + + // Pour les attributs atomiques, les valeurs sont stock\xE9es sous forme d'un tableau {a,b,c,...} + if (_zone.getAttribute(attIdx.get(atts[j])).isAtomicValue()) { + GISAttributeModel md=(GISAttributeModel)_zone.getValue(attIdx.get(atts[j]),i); + StringBuilder sb=new StringBuilder(); + + sb.append("{").append(md.getObjectValueAt(0).toString().replaceAll(",","‚")); + for (int k=1; k<md.getSize(); k++) sb.append(",").append(md.getObjectValueAt(k).toString().replaceAll(",","‚")); + sb.append("}"); + + feature.setAttribute(j, sb); + } + + /// Atributs standards. + else + feature.setAttribute(j, _zone.getValue(attIdx.get(atts[j]), i)); } + // Enregistrement de l'index de la g\xE9om\xE9trie dans le fichier feature.setAttribute(nbAttribute-1, new Integer(i)); writer.write(); @@ -181,7 +217,6 @@ } } } - } public FeatureType createFeatureType(final GISDataModel _zone, final AttributeType[] _atts) Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerExporter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerExporter.java 2009-02-05 18:21:55 UTC (rev 4444) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerExporter.java 2009-02-06 13:30:12 UTC (rev 4445) @@ -22,6 +22,7 @@ import org.fudaa.ctulu.ProgressionInterface; import org.fudaa.ctulu.fileformat.FileFormatUnique; import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ctulu.gis.GISAttributeDouble; import org.fudaa.ctulu.gis.GISAttributeInterface; import org.fudaa.ctulu.gis.GISDataModel; import org.fudaa.ctulu.gis.GISDataModelFilterAdapter; @@ -96,7 +97,8 @@ } } GISDataModel collect = _filter.getCollect(oi); - exporter.process(_prog, collect, GISExportDataStoreFactory.createDataStore(dataStore_, file.toURL(), collect + GISAttributeDouble attIsZ=_filter.getAttributeIsZ(oi); + exporter.process(_prog, collect, attIsZ, GISExportDataStoreFactory.createDataStore(dataStore_, file.toURL(), collect .getEnvelopeInternal(), true)); } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerFilter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerFilter.java 2009-02-05 18:21:55 UTC (rev 4444) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/layer/FSigLayerFilter.java 2009-02-06 13:30:12 UTC (rev 4445) @@ -16,6 +16,7 @@ import org.fudaa.ctulu.CtuluIOOperationSynthese; import org.fudaa.ctulu.CtuluUI; import org.fudaa.ctulu.ProgressionInterface; +import org.fudaa.ctulu.gis.GISAttributeDouble; import org.fudaa.ctulu.gis.GISDataModel; import org.fudaa.ctulu.gis.GISDataModelFilterAdapter; import org.fudaa.ctulu.gis.GISZoneCollection; @@ -81,6 +82,15 @@ else return zone; } + + /** + * Retourne l'attribut pris pour Z dans la zone. + * @param _o Le calque + * @return L'attribut pris pour Z. Peut \xEAtre null. + */ + final GISAttributeDouble getAttributeIsZ(final ZCalqueAffichageDonneesInterface _o) { + return ((ZModeleGeometry) _o.modeleDonnees()).getGeomData().getAttributeIsZ(); + } final GISDataModel getCollect(final Object _o) { return getCollect((ZCalqueAffichageDonneesInterface) _o); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2009-02-11 13:22:26
|
Revision: 4456 http://fudaa.svn.sourceforge.net/fudaa/?rev=4456&view=rev Author: emmanuel_martin Date: 2009-02-11 11:48:56 +0000 (Wed, 11 Feb 2009) Log Message: ----------- Impl?\195?\169mentation partielle de la tache #178 : "Utilisation du PK des profils 2D rubar dans le modeleur 1D" Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStWriter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZScene.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionAxeHydraulique.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueTableau.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java 2009-02-11 10:57:27 UTC (rev 4455) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java 2009-02-11 11:48:56 UTC (rev 4456) @@ -806,6 +806,67 @@ return GISGeometryFactory.INSTANCE.createLinearRing(seq); } + /** + * Retourne la valeur pour une propri\xE9t\xE9 hydraulique de type double. + * @param _comm Commentaire hydro sous la forme "<prop1>=<val>; <prop2>=<val>" + * @param _prop La propri\xE9t\xE9 a extraire. + * @return La valeur de la propri\xE9t\xE9. + */ + static public double getHydroCommentDouble(String _comm, String _prop) { + double r=0; + + if (_comm!=null && !_comm.trim().equals("")) { + for (String cpl : _comm.split(";")) { + String[] nameval=cpl.split("="); + if (nameval.length==2 && nameval[0].equalsIgnoreCase(_prop)) { + try { + r=Double.parseDouble(nameval[1]); + break; + } + // En cas d'erreur, retourne 0. + catch (NumberFormatException _exc) {} + } + } + } + return r; + } + /** + * Retourne vrai si la propri\xE9t\xE9 est valu\xE9e. + */ + static public boolean isHydroCommentValued(final String _comm, String _prop) { + if (_comm!=null&&!_comm.trim().equals("")) + for (String cpl : _comm.split(";")) { + String[] nameval=cpl.split("="); + if (nameval.length==2&&nameval[0].equalsIgnoreCase(_prop)) + return true; + } + return false; + } + /** + * Retourne une nouvelle instance de commentaire ayant pour nouvelle valeur de '_prop' '_value'. + * @param _comm Commentaire hydro sous la forme "<prop1>=<val>; <prop2>=<val>" + * @param _prop La propri\xE9t\xE9. + * @param _value la nouvelle valeur pour prop. + * @return Nouvelle instance du commentaire. + */ + static public String setHydroCommentDouble(final String _comm, double _value, String _prop) { + StringBuilder str=new StringBuilder(); + boolean found=false; + if (_comm!=null && !_comm.trim().equals("")) { + for (String cpl : _comm.split(";")) { + String[] nameval=cpl.split("="); + if (nameval.length==2 && nameval[0].equalsIgnoreCase(_prop)) { + found=true; + str.append(nameval[0]+"="+Double.toString(_value)); + } + else + str.append(cpl); + } + } + if(!found) + str.append(_prop+"="+_value); + return str.toString(); + } } \ No newline at end of file Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStWriter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStWriter.java 2009-02-11 10:57:27 UTC (rev 4455) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/rubar/io/RubarStWriter.java 2009-02-11 11:48:56 UTC (rev 4456) @@ -20,6 +20,7 @@ import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ctulu.gis.GISDataModel; import org.fudaa.ctulu.gis.GISDataModelFilterAdapter; +import org.fudaa.ctulu.gis.GISLib; import org.fudaa.dodico.fortran.FileOpWriterCharSimpleAbstract; import org.fudaa.dodico.fortran.FortranWriter; @@ -46,31 +47,6 @@ isSt_ = !_f.getName().toLowerCase().endsWith(".cn"); super.setFile(_f); } - - /** - * Retourne la valeur pour une propri\xE9t\xE9 hydraulique de type double. - * @param _comm Commentaire hydro sous la forme "<prop1>=<val>; <prop2>=<val>" - * @param _prop La propri\xE9t\xE9 a extraire. - * @return La valeur de la propri\xE9t\xE9. - */ - private double getHydroCommentDouble(String _comm, String _prop) { - double r=0; - - if (_comm!=null && !_comm.trim().equals("")) { - for (String cpl : _comm.split(";")) { - String[] nameval=cpl.split("="); - if (nameval.length==2 && nameval[0].equalsIgnoreCase(_prop)) { - try { - r=Double.parseDouble(nameval[1]); - break; - } - // En cas d'erreur, retourne 0. - catch (NumberFormatException _exc) {} - } - } - } - return r; - } /** * Ecrit les profils et les lignes directrices. @@ -113,7 +89,7 @@ if (attName==-1||(name=(String)profs_.getValue(attName, i))==null) name=""; // PK, issu du commentaire hydrualique. if (attPk!=-1) { - pk=getHydroCommentDouble((String)profs_.getValue(attPk, i),RubarStCnFileFormat.COMM_HYDRO_PK); + pk=GISLib.getHydroCommentDouble((String)profs_.getValue(attPk, i),RubarStCnFileFormat.COMM_HYDRO_PK); } writer.setSpaceBefore(false); writer.stringField(6, name); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZScene.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZScene.java 2009-02-11 10:57:27 UTC (rev 4455) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZScene.java 2009-02-11 11:48:56 UTC (rev 4456) @@ -186,14 +186,15 @@ for (int i=0; i<cqs.length; i++) { if (cqs[i].getLayerSelection()!=null) { int[] isels=cqs[i].getLayerSelection().getSelectedIndex(); - if (isels!=null){ - for (int j=0; j<isels.length; j++) isels[j]+=idecal; + if (isels!=null) { + for (int j=0; j<isels.length; j++) + isels[j]+=idecal; System.arraycopy(isels, 0, iglobsels, ipt, isels.length); ipt+=isels.length; } - if(cqs[i].modeleDonnees()!=null) - idecal+=cqs[i].modeleDonnees().getNombre(); } + if (cqs[i].modeleDonnees()!=null) + idecal+=cqs[i].modeleDonnees().getNombre(); } // for (int i=0; i<lists_.length-1; i++) { // int[] isels=lists_[i].getSelectedIndex(); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java 2009-02-11 10:57:27 UTC (rev 4455) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java 2009-02-11 11:48:56 UTC (rev 4456) @@ -21,6 +21,7 @@ import org.fudaa.ctulu.CtuluListSelection; import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ctulu.gis.GISCoordinateSequenceFactory; +import org.fudaa.ctulu.gis.GISLib; import org.fudaa.ctulu.gis.GISPolyligne; import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ebli.calque.BCalque; @@ -224,25 +225,30 @@ * Fusion de deux biefs. */ public void fusionnerBiefs(int _idxBief1, int _idxBief2){ - // D\xE9termine le premier axe hydraulique et le second - double bief1BaseCurv; - double bief2BaseCurv; + // D\xE9termine quel bief est le premier et lequel est le second (curvilignement parlant) + double bief1BaseCurv=0; + double bief2BaseCurv=0; { // Bloque r\xE9duisant artificiellement la port\xE9 des variables String name1=biefSet_.getBiefName(_idxBief1); String name2=biefSet_.getBiefName(_idxBief2); Bief bief1=biefSet_.getBief(name1); Bief bief2=biefSet_.getBief(name2); - GISZoneCollection zoneAxeHydrau1=bief1.axeHydraulique_.getGeomData(); - bief1BaseCurv=(Double)zoneAxeHydrau1.getValue(zoneAxeHydrau1.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE), 0); - GISZoneCollection zoneAxeHydrau2=bief2.axeHydraulique_.getGeomData(); - bief2BaseCurv=(Double)zoneAxeHydrau2.getValue(zoneAxeHydrau2.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE), 0); - + // Verifications if(bief1==null||bief2==null) throw new IllegalArgumentException(FudaaLib.getS("Au moins un des index ne correspond pas \xE0 un bief.")); if(bief1.lignesDirectrices_.getNombre()!=bief2.lignesDirectrices_.getNombre()) throw new IllegalArgumentException(FudaaLib.getS("Il doit y avoir le m\xEAme nombre de lignes directrices dans les deux biefs.")); + if(bief1.axeHydraulique_.getNombre()!=bief2.axeHydraulique_.getNombre()) + throw new IllegalArgumentException(FudaaLib.getS("Les deux biefs doivent avoir la m\xEAme pr\xE9sence d'axe hydraulique.")); + GISZoneCollection zoneAxeHydrau1=bief1.axeHydraulique_.getGeomData(); + if(zoneAxeHydrau1.getNumGeometries()>0) + bief1BaseCurv=(Double)zoneAxeHydrau1.getValue(zoneAxeHydrau1.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE), 0); + GISZoneCollection zoneAxeHydrau2=bief2.axeHydraulique_.getGeomData(); + if(zoneAxeHydrau2.getNumGeometries()>0) + bief2BaseCurv=(Double)zoneAxeHydrau2.getValue(zoneAxeHydrau2.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE), 0); + // Inversion des biefs si n\xE9c\xE9ssaire if (bief1BaseCurv>bief2BaseCurv) { int idxTmp=_idxBief1; @@ -256,10 +262,20 @@ { // Bloque r\xE9duisant artificiellement la port\xE9 des variables String name1=biefSet_.getBiefName(_idxBief1); String name2=biefSet_.getBiefName(_idxBief2); - CoordinateSequence seqAxe1=biefSet_.getBief(name1).axeHydraulique_.getGeomData().getCoordinateSequence(0); - CoordinateSequence seqAxe2=biefSet_.getBief(name2).axeHydraulique_.getGeomData().getCoordinateSequence(0); - double bief1MaxCurvBrut=UtilsProfil1d.abscisseCurviligne(seqAxe1, seqAxe1.getCoordinate(seqAxe1.size()-1)); - double bief2MaxCurvBrut=UtilsProfil1d.abscisseCurviligne(seqAxe2, seqAxe2.getCoordinate(seqAxe2.size()-1)); + double bief1MaxCurvBrut; + double bief2MaxCurvBrut; + if(biefSet_.getBief(name1).axeHydraulique_.getGeomData().getNumGeometries()>0) { + CoordinateSequence seqAxe1=biefSet_.getBief(name1).axeHydraulique_.getGeomData().getCoordinateSequence(0); + bief1MaxCurvBrut=UtilsProfil1d.abscisseCurviligne(seqAxe1, seqAxe1.getCoordinate(seqAxe1.size()-1)); + CoordinateSequence seqAxe2=biefSet_.getBief(name2).axeHydraulique_.getGeomData().getCoordinateSequence(0); + bief2MaxCurvBrut=UtilsProfil1d.abscisseCurviligne(seqAxe2, seqAxe2.getCoordinate(seqAxe2.size()-1)); + } + else { + GISZoneCollection zone1=biefSet_.getBief(name1).profils_.getGeomData(); + bief1MaxCurvBrut=Double.parseDouble(((String) zone1.getValue(zone1.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO), zone1.getNumGeometries()-1)).substring(3)); + GISZoneCollection zone2=biefSet_.getBief(name2).profils_.getGeomData(); + bief2MaxCurvBrut=Double.parseDouble(((String) zone2.getValue(zone2.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO), zone2.getNumGeometries()-1)).substring(3)); + } if(bief1BaseCurv+bief1MaxCurvBrut>bief2BaseCurv) { VueFusionBief vueFusionBief=new VueFusionBief(controller1d_.getFormater(), name1, bief1BaseCurv, bief1MaxCurvBrut, name2, bief2BaseCurv, bief2MaxCurvBrut); @@ -279,15 +295,51 @@ bief2BaseCurv=valTmp; } } - + String name1=biefSet_.getBiefName(_idxBief1); String name2=biefSet_.getBiefName(_idxBief2); Bief bief1=biefSet_.getBief(name1); Bief bief2=biefSet_.getBief(name2); + // Extraction/Cr\xE9ation des axes hydrauliques GISZoneCollection zoneAxeHydrau1=bief1.axeHydraulique_.getGeomData(); GISZoneCollection zoneAxeHydrau2=bief2.axeHydraulique_.getGeomData(); - CoordinateSequence seqAxeHydraulique1=zoneAxeHydrau1.getCoordinateSequence(0); - CoordinateSequence seqAxeHydraulique2=zoneAxeHydrau2.getCoordinateSequence(0); + CoordinateSequence seqAxeHydraulique1; + CoordinateSequence seqAxeHydraulique2; + boolean fakeAH=false; + if(zoneAxeHydrau1.getNbGeometries()==0) { + fakeAH=true; + // Construction d'un faux axe hydraulique + if(bief1.profils_.getNombre()>=2) { + CoordinateSequence prof1=bief1.profils_.getGeomData().getCoordinateSequence(0); + CoordinateSequence prof2=bief1.profils_.getGeomData().getCoordinateSequence(bief1.profils_.getNombre()-1); + seqAxeHydraulique1=new GISCoordinateSequenceFactory().create(new Coordinate[]{prof1.getCoordinate(prof1.size()/2), prof2.getCoordinate(prof2.size()/2)}); + } + else if(bief1.profils_.getNombre()==1) { + CoordinateSequence prof1=bief1.profils_.getGeomData().getCoordinateSequence(0); + Coordinate coord1=prof1.getCoordinate(prof1.size()/2); + Coordinate coord2=new Coordinate(coord1.x-10, coord1.y-1, 0); + seqAxeHydraulique1=new GISCoordinateSequenceFactory().create(new Coordinate[]{coord1, coord2}); + } + else + return; + if(bief2.profils_.getNombre()>=2) { + CoordinateSequence prof1=bief2.profils_.getGeomData().getCoordinateSequence(0); + CoordinateSequence prof2=bief2.profils_.getGeomData().getCoordinateSequence(bief2.profils_.getNombre()-1); + seqAxeHydraulique2=new GISCoordinateSequenceFactory().create(new Coordinate[]{prof1.getCoordinate(prof1.size()/2), prof2.getCoordinate(prof2.size()/2)}); + } + else if(bief2.profils_.getNombre()==1) { + CoordinateSequence prof1=bief2.profils_.getGeomData().getCoordinateSequence(0); + Coordinate coord1=prof1.getCoordinate(prof1.size()/2); + Coordinate coord2=new Coordinate(coord1.x-10, coord1.y-1, 0); + seqAxeHydraulique2=new GISCoordinateSequenceFactory().create(new Coordinate[]{coord1, coord2}); + } + else + return; + } + else { + seqAxeHydraulique1=zoneAxeHydrau1.getCoordinateSequence(0); + seqAxeHydraulique2=zoneAxeHydrau2.getCoordinateSequence(0); + } Coordinate debutAxe2=UtilsProfil1d.getCoordinateXY(seqAxeHydraulique1, bief2BaseCurv-bief1BaseCurv); Coordinate move=UtilsProfil1d.vec(seqAxeHydraulique2.getCoordinate(0), debutAxe2); @@ -306,41 +358,66 @@ // Ajout de g\xE9om\xE9tries au nouveau bief \\ // Ajout des profils des biefs d'origines - for(int i=0;i<bief1.profils_.getNombre();i++) - zoneProfils.addGeometry(bief1ZoneProfil.getGeometry(i), UtilsProfil1d.getData(i, bief1ZoneProfil), null); - for(int i=0;i<bief2.profils_.getNombre();i++) - zoneProfils.addGeometry(bief2ZoneProfil.getGeometry(i), UtilsProfil1d.getData(i, bief2ZoneProfil), null); + int idxAttrComm=zoneProfils.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO); + for(int i=0;i<bief1.profils_.getNombre();i++) { + int idxGeom=zoneProfils.addGeometry(bief1ZoneProfil.getGeometry(i), UtilsProfil1d.getData(i, bief1ZoneProfil), null); + if (fakeAH) { + // Dans le cas de l'utilisation de l'attribut CommentaireHydro, on + // r\xE9percute le changement de baseCurv sur les valeurs de l'attribut + String comm=(String)zoneProfils.getValue(idxAttrComm, idxGeom); + double newPK=GISLib.getHydroCommentDouble(comm, "PK")+bief1BaseCurv; + String newValue=GISLib.setHydroCommentDouble(comm, newPK, "PK"); + zoneProfils.setAttributValue(idxAttrComm, i, newValue, null); + } + } + for(int i=0;i<bief2.profils_.getNombre();i++) { + int idxGeom=zoneProfils.addGeometry(bief2ZoneProfil.getGeometry(i), UtilsProfil1d.getData(i, bief2ZoneProfil), null); + if (fakeAH) { + // Dans le cas de l'utilisation de l'attribut CommentaireHydro, on + // r\xE9percute le changement de baseCurv sur les valeurs de l'attribut + String comm=(String)zoneProfils.getValue(idxAttrComm, idxGeom); + double newPK=GISLib.getHydroCommentDouble(comm, "PK")+bief1BaseCurv; + String newValue=GISLib.setHydroCommentDouble(comm, newPK, "PK"); + zoneProfils.setAttributValue(idxAttrComm, i, newValue, null); + } + } // Ajout de l'axe hydraulique du second bief (utile pour la translation) - zoneAxeHydraulique.addGeometry(zoneAxeHydrau2.getGeometry(0), UtilsProfil1d.getData(0, zoneAxeHydrau2), null); + if(!fakeAH) + zoneAxeHydraulique.addGeometry(zoneAxeHydrau2.getGeometry(0), UtilsProfil1d.getData(0, zoneAxeHydrau2), null); // Translation du second bief \\ // Cr\xE9ation d'une selection contenant le second axe hydraulique - BitSet bs=new BitSet(1); - bs.set(0); - CtuluListSelection selection=new CtuluListSelection(bs); - // Application de la translation sur le second axe hydraulique - ((ZModeleLigneBriseeEditable) newBief.axeHydraulique_).moveGlobal(selection, move.x, move.y, 0, null); + if (!fakeAH) { + BitSet bs=new BitSet(1); + bs.set(0); + CtuluListSelection selection=new CtuluListSelection(bs); + // Application de la translation sur le second axe hydraulique + ((ZModeleLigneBriseeEditable)newBief.axeHydraulique_).moveGlobal(selection, move.x, move.y, 0, null); + } // Cr\xE9ation d'une selection contenant les profils du second axe hydraulique - bs=new BitSet(zoneProfils.getNbGeometries()); + BitSet bs=new BitSet(zoneProfils.getNbGeometries()); bs.set(bief1.profils_.getNombre(), zoneProfils.getNbGeometries()); - selection=new CtuluListSelection(bs); + CtuluListSelection selection=new CtuluListSelection(bs); // Application de la translation sur les profils du second axe hydraulique ((ZModeleLigneBriseeEditable) newBief.profils_).moveGlobal(selection, move.x, move.y, 0, null); // Fusion des deux axes Hydrauliques \\ - String newTitre=agregeTitres(0, zoneAxeHydrau1, zoneAxeHydrau2, -1, -1); - seqAxeHydraulique2=zoneAxeHydraulique.getCoordinateSequence(0); - Coordinate[] coords=new Coordinate[seqAxeHydraulique1.size()+seqAxeHydraulique2.size()]; - int i=0; - for(;i<seqAxeHydraulique1.size();i++) - coords[i]=seqAxeHydraulique1.getCoordinate(i); - for(;i<seqAxeHydraulique2.size()+seqAxeHydraulique1.size();i++) - coords[i]=seqAxeHydraulique2.getCoordinate(i-seqAxeHydraulique1.size()); - zoneAxeHydraulique.addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(coords)), null, null); - zoneAxeHydraulique.setAttributValue(zoneAxeHydraulique.getIndiceOf(GISAttributeConstants.TITRE), 1, newTitre, null); - zoneAxeHydraulique.setAttributValue(zoneAxeHydrau1.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE), 1, bief1BaseCurv, null); - // suppression de l'axe hydraulique 2 du nouveau bief - zoneAxeHydraulique.removeGeometries(new int[]{0}, null); + if (!fakeAH) { + String newTitre=agregeTitres(0, zoneAxeHydrau1, zoneAxeHydrau2, -1, -1); + seqAxeHydraulique2=zoneAxeHydraulique.getCoordinateSequence(0); + Coordinate[] coords=new Coordinate[seqAxeHydraulique1.size()+seqAxeHydraulique2.size()]; + int i=0; + for (; i<seqAxeHydraulique1.size(); i++) + coords[i]=seqAxeHydraulique1.getCoordinate(i); + for (; i<seqAxeHydraulique2.size()+seqAxeHydraulique1.size(); i++) + coords[i]=seqAxeHydraulique2.getCoordinate(i-seqAxeHydraulique1.size()); + zoneAxeHydraulique.addGeometry(new GISPolyligne(new GISCoordinateSequenceFactory().create(coords)), null, null); + zoneAxeHydraulique.setAttributValue(zoneAxeHydraulique.getIndiceOf(GISAttributeConstants.TITRE), 1, newTitre, null); + zoneAxeHydraulique.setAttributValue(zoneAxeHydrau1.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE), 1, bief1BaseCurv, + null); + // suppression de l'axe hydraulique 2 du nouveau bief + zoneAxeHydraulique.removeGeometries(new int[]{0}, null); + } // Traitement des g\xE9om\xE9tries volatiles \\ // Rives Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-02-11 10:57:27 UTC (rev 4455) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java 2009-02-11 11:48:56 UTC (rev 4456) @@ -22,6 +22,7 @@ import org.fudaa.ctulu.gis.GISAttributeModelIntegerList; import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; import org.fudaa.ctulu.gis.GISCoordinateSequenceFactory; +import org.fudaa.ctulu.gis.GISLib; import org.fudaa.ctulu.gis.GISPolyligne; import org.fudaa.ctulu.gis.GISReprojectInterpolateur1DDouble; import org.fudaa.ctulu.gis.GISZoneCollection; @@ -120,10 +121,6 @@ if (nature==GISAttributeConstants.ATT_NATURE_AH) if (axeHydraulique_!=null) throw new IllegalArgumentException(FudaaLib.getS("Plusieurs models d'axe hydrauliques sont donn\xE9es.")); - else if (_models[i].getGeomData().getNbGeometries()>1) - throw new IllegalArgumentException(FudaaLib.getS("Il ne peut pas y avoir plusieurs axes hydrauliques dans le bief.")); - else if (_models[i].getGeomData().getNbGeometries()==0) - throw new IllegalArgumentException(FudaaLib.getS("Il doit y avoir au moins un axe hydraulique dans le bief.")); else axeHydraulique_=_models[i]; else if (nature==GISAttributeConstants.ATT_NATURE_LD) @@ -182,47 +179,124 @@ // Valuation des attributs sp\xE9cifiques au 1d pour les profils \\ GISZoneCollection zone=profils_.getGeomData(); normalizeProfilAttributes(zone); + + // D\xE9termination de la r\xE9f\xE9rence hydraulique \\ + int idxAttCommentaireHydraulique=zone.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO); + boolean useAttAxeHydrau=false; + boolean attrIsCorrectlyValued=false; + if(idxAttCommentaireHydraulique!=-1) { + attrIsCorrectlyValued=true; + int i=-1; + while(attrIsCorrectlyValued&&++i<profils_.getNombre()) + attrIsCorrectlyValued=GISLib.isHydroCommentValued((String) profils_.getGeomData().getValue(idxAttCommentaireHydraulique, i), "PK"); + } + if(axeHydraulique_.getNombre()==0&&!attrIsCorrectlyValued) { + useAttAxeHydrau=true; + // Ajout de l'attribut COMMENTAIRE_HYDRO + if (idxAttCommentaireHydraulique==-1) { + GISAttributeInterface[] atts=new GISAttributeInterface[zone.getNbAttributes()+1]; + for (int k=0; k<zone.getNbAttributes(); k++) + atts[k]=zone.getAttribute(k); + atts[atts.length-1]=GISAttributeConstants.COMMENTAIRE_HYDRO; + zone.setAttributes(atts, null); + } + // Valuation de l'attribut + idxAttCommentaireHydraulique=zone.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO); + for (int k=0; k<zone.getNumGeometries(); k++) { + String comm=(String)profils_.getGeomData().getValue(idxAttCommentaireHydraulique, k); + if (!GISLib.isHydroCommentValued(comm, "PK")) + zone.setAttributValue(idxAttCommentaireHydraulique, k, GISLib.setHydroCommentDouble(comm, 0, "PK"), null); + } + } + else if(axeHydraulique_.getNombre()>0&&attrIsCorrectlyValued) { + //TODO : demander \xE0 l'utilisateur lequel utiliser + boolean useAxeHydraulique=true; + if(useAxeHydraulique) { + // Destruction de l'attribut COMMENTAIRE_HYDRO + GISAttributeInterface[] atts=new GISAttributeInterface[zone.getNbAttributes()-1]; + int l=0; + for (int k=0; k<zone.getNbAttributes(); k++) + if(zone.getAttribute(k)!=GISAttributeConstants.COMMENTAIRE_HYDRO) + atts[l++]=zone.getAttribute(k); + zone.setAttributes(atts, null); + useAttAxeHydrau=true; + } + else { + // Destruction des axes hydrauliques + int[] idx=new int[axeHydraulique_.getNombre()]; + for(int i=0;i<axeHydraulique_.getNombre();i++) + idx[i]=i; + axeHydraulique_.getGeomData().removeGeometries(idx, null); + } + } + else if(axeHydraulique_.getNombre()==0) + useAttAxeHydrau=true; + int idxAttRiveGauche=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); int idxAttRiveDroite=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); int idxAttlsGauche=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); int idxAttlsDroite=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); int idxAttLignesDirectrices=zone.getIndiceOf(GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); - - Geometry axeHydraulique=(Geometry)axeHydraulique_.getObject(0); - CoordinateSequence seqAxeHydraulique=((GISCoordinateSequenceContainerInterface)axeHydraulique).getCoordinateSequence(); + idxAttCommentaireHydraulique=zone.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO); + orderProfils(-1, null); // Normalise le sens du profil \\ for (int k=0; k<profils_.getNombre(); k++) { Geometry profil=zone.getGeometry(k); CoordinateSequence seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); // Normalisation du sens (gauche/droite) du profil \\ - Coordinate interAxeProfil=profil.intersection(axeHydraulique).getCoordinate(); + Coordinate interAxeProfil=seqProfil.getCoordinate(seqProfil.size()/2); // Cr\xE9ation du vecteur contenant le sens de l'axe hydraulique - Coordinate vAxeH; - int idxPrevious=UtilsProfil1d.getPreviousIndex(seqAxeHydraulique, interAxeProfil); - int idxNext=UtilsProfil1d.getNextIndex(seqAxeHydraulique, interAxeProfil); - if (idxPrevious!=-1) - vAxeH=new Coordinate(interAxeProfil.x-seqAxeHydraulique.getCoordinate(idxPrevious).x, interAxeProfil.y - -seqAxeHydraulique.getCoordinate(idxPrevious).y, 0); - else - vAxeH=new Coordinate(seqAxeHydraulique.getCoordinate(idxNext).x-interAxeProfil.x, - seqAxeHydraulique.getCoordinate(idxNext).y-interAxeProfil.y, 0); + Coordinate vAxeH=null; + boolean noReorientation=false; + if (k>0) { + CoordinateSequence profilPrevious=zone.getCoordinateSequence(k-1); + Coordinate pointProfilPrevious=profilPrevious.getCoordinate(profilPrevious.size()/2); + vAxeH=new Coordinate(interAxeProfil.x-pointProfilPrevious.x, interAxeProfil.y-pointProfilPrevious.y, 0); + } + else if(k<profils_.getNombre()-1){ + CoordinateSequence profilPrevious=zone.getCoordinateSequence(k+1); + Coordinate pointProfilPrevious=profilPrevious.getCoordinate(profilPrevious.size()/2); + vAxeH=new Coordinate(pointProfilPrevious.x-interAxeProfil.x, pointProfilPrevious.y-interAxeProfil.y, 0); + } + else { + if(axeHydraulique_.getNombre()>0) { + Geometry axeHydraulique=(Geometry)axeHydraulique_.getObject(0); + CoordinateSequence seqAxeHydraulique=((GISCoordinateSequenceContainerInterface)axeHydraulique).getCoordinateSequence(); + // Normalisation du sens (gauche/droite) du profil \\ + Coordinate interAxeProfil2=profil.intersection(axeHydraulique).getCoordinate(); + // Cr\xE9ation du vecteur contenant le sens de l'axe hydraulique + int idxPrevious=UtilsProfil1d.getPreviousIndex(seqAxeHydraulique, interAxeProfil2); + int idxNext=UtilsProfil1d.getNextIndex(seqAxeHydraulique, interAxeProfil2); + if (idxPrevious!=-1) + vAxeH=new Coordinate(interAxeProfil2.x-seqAxeHydraulique.getCoordinate(idxPrevious).x, interAxeProfil2.y + -seqAxeHydraulique.getCoordinate(idxPrevious).y, 0); + else + vAxeH=new Coordinate(seqAxeHydraulique.getCoordinate(idxNext).x-interAxeProfil2.x, + seqAxeHydraulique.getCoordinate(idxNext).y-interAxeProfil2.y, 0); + } + else + // Pas de r\xE9orientatin du profil dans ce cas l\xE0. + noReorientation=true; + } // Cr\xE9ation du vecteur contenant le sens du profil - Coordinate vProfilH; - idxPrevious=UtilsProfil1d.getPreviousIndex(seqProfil, interAxeProfil); - idxNext=UtilsProfil1d.getNextIndex(seqProfil, interAxeProfil); - if (idxPrevious!=-1) - vProfilH=new Coordinate(interAxeProfil.x-seqProfil.getCoordinate(idxPrevious).x, interAxeProfil.y - -seqProfil.getCoordinate(idxPrevious).y, 0); - else - vProfilH=new Coordinate(seqProfil.getCoordinate(idxNext).x-interAxeProfil.x, seqProfil.getCoordinate(idxNext).y - -interAxeProfil.y, 0); - // Inversion du sens du profil si besoin - double produitVectorielCoordZ=vAxeH.x*vProfilH.y-vAxeH.y*vProfilH.x; - if (produitVectorielCoordZ>0) { - inverseProfil(k); - profil=(Geometry)profils_.getGeomData().getGeometry(k); - seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); + if (!noReorientation) { + Coordinate vProfilH; + int idxPrevious=UtilsProfil1d.getPreviousIndex(seqProfil, interAxeProfil); + int idxNext=UtilsProfil1d.getNextIndex(seqProfil, interAxeProfil); + if (idxPrevious!=-1) + vProfilH=new Coordinate(interAxeProfil.x-seqProfil.getCoordinate(idxPrevious).x, interAxeProfil.y + -seqProfil.getCoordinate(idxPrevious).y, 0); + else + vProfilH=new Coordinate(seqProfil.getCoordinate(idxNext).x-interAxeProfil.x, seqProfil.getCoordinate(idxNext).y + -interAxeProfil.y, 0); + // Inversion du sens du profil si besoin + double produitVectorielCoordZ=vAxeH.x*vProfilH.y-vAxeH.y*vProfilH.x; + if (produitVectorielCoordZ>0) { + inverseProfil(k); + profil=(Geometry)profils_.getGeomData().getGeometry(k); + seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); + } } } // Cr\xE9ation des nouveaux points sur les profils \\ @@ -244,9 +318,16 @@ // Valuation des attributs simple d'intersection (rives et limites) \\ for (int k=0; k<profils_.getNombre(); k++) { Geometry profil=zone.getGeometry(k); - CoordinateSequence seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); - Coordinate interAxeProfil=profil.intersection(axeHydraulique).getCoordinate(); - double abscisseCurvIntersectionAxe=UtilsProfil1d.abscisseCurviligne(seqProfil, interAxeProfil); + CoordinateSequence seqProfil=zone.getCoordinateSequence(k); + double abscisseCurvIntersectionAxe; + if(useAttAxeHydrau) { + String value=(String) profils_.getGeomData().getValue(idxAttCommentaireHydraulique, k); + abscisseCurvIntersectionAxe=GISLib.getHydroCommentDouble(value, "PK"); + } + else { + Coordinate interAxeProfil=profil.intersection((GISPolyligne) axeHydraulique_.getObject(0)).getCoordinate(); + abscisseCurvIntersectionAxe=UtilsProfil1d.abscisseCurviligne(seqProfil, interAxeProfil); + } // Valuation des attributs avec les index des points des intersections \\ // Rives zone.setAttributValue(idxAttRiveGauche, k, 0, null); @@ -432,10 +513,15 @@ // Extraction d'informations sur le profils et l'axe hydraulique Geometry profil=profils_.getGeomData().getGeometry(idxTest); CoordinateSequence seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); - Coordinate intersection=profil.intersection((Geometry)axeHydraulique_.getObject(0)).getCoordinate(); - int idxAxe=UtilsProfil1d.getPreviousIndex(seqProfil, intersection); - if (idxAxe==-1) - idxAxe=0; + int idxAxe; + if(axeHydraulique_.getNombre()==0) + idxAxe=seqProfil.size()/2; + else { + Coordinate intersection=profil.intersection((Geometry)axeHydraulique_.getObject(0)).getCoordinate(); + idxAxe=UtilsProfil1d.getPreviousIndex(seqProfil, intersection); + if (idxAxe==-1) + idxAxe=0; + } // Enregistrement de l'index if (lstIntersectionTmp[idxTest]<=idxAxe) lst.add(0); @@ -525,48 +611,6 @@ } } } - - /** - * Retourne vrai si les donn\xE9es contenues dans les champs sont coh\xE9rentes. - */ - public boolean checkCoherence(){ - // TODO ajouter la verification de la pr\xE9sences des attribtus n\xE9c\xE9ssaires - if (axeHydraulique_==null||profils_==null||rives_==null||limitesStockages_==null||lignesDirectrices_==null) - return false; - // Axe hydraulique - if (axeHydraulique_.getGeomData()==null||!(axeHydraulique_.getGeomData() instanceof GISZoneCollectionLigneBrisee)) - return false; - if ((String)axeHydraulique_.getGeomData().getFixedAttributValue(GISAttributeConstants.NATURE)!=GISAttributeConstants.ATT_NATURE_AH) - return false; - if(axeHydraulique_.getNbPolyligne()>1) - return false; - // Lignes directrices - if (lignesDirectrices_.getGeomData()==null||!(lignesDirectrices_.getGeomData() instanceof GISZoneCollectionLigneBrisee)) - return false; - if ((String)lignesDirectrices_.getGeomData().getFixedAttributValue(GISAttributeConstants.NATURE)!=GISAttributeConstants.ATT_NATURE_LD) - return false; - // Limite de stockage - if (limitesStockages_.getGeomData()==null||!(limitesStockages_.getGeomData() instanceof GISZoneCollectionLigneBrisee)) - return false; - if ((String)limitesStockages_.getGeomData().getFixedAttributValue(GISAttributeConstants.NATURE)!=GISAttributeConstants.ATT_NATURE_LC) - return false; - if(limitesStockages_.getNbPolyligne()>2) - return false; - // Profil - if (profils_.getGeomData()==null||!(profils_.getGeomData() instanceof GISZoneCollectionLigneBrisee)) - return false; - if ((String)profils_.getGeomData().getFixedAttributValue(GISAttributeConstants.NATURE)!=GISAttributeConstants.ATT_NATURE_PF) - return false; - // rives - if (rives_.getGeomData()==null||!(rives_.getGeomData() instanceof GISZoneCollectionLigneBrisee)) - return false; - if ((String)rives_.getGeomData().getFixedAttributValue(GISAttributeConstants.NATURE)!=GISAttributeConstants.ATT_NATURE_RV) - return false; - if(rives_.getNbPolyligne()>2) - return false; - // Tout est ok - return true; - } /** * R\xE9ordonne les profils du bief. Retourne le nouvel indice de l'indice pass\xE9 @@ -603,19 +647,28 @@ boolean synchroniserEnable=isSynchronizerActived(); if(synchroniserEnable) gisSynchroniser_.disable(); - Geometry axeHydraulique=(Geometry)axeHydraulique_.getObject(0); - CoordinateSequence seqAxeHydraulique=((GISCoordinateSequenceContainerInterface)axeHydraulique).getCoordinateSequence(); // R\xE9ordonnancement des profils selon leur placement sur l'axe hydaulique (abs curv) \\ // Calcul des abscisses curvilignes Object[][] idxAbsCurv=new Object[profils_.getNombre()][]; - for(int j=0;j<profils_.getNombre();j++) { - Geometry intersection=axeHydraulique.intersection((Geometry) profils_.getObject(j)); - if(intersection.getNumPoints()==0) - throw new IllegalArgumentException("Au moins un des profils ne coupe jamais l'axe hydraulique."); - if(intersection.getNumPoints()>1) - throw new IllegalArgumentException("Au moins un des profils coupe plusieurs fois l'axe hydraulique."); - idxAbsCurv[j]=new Object[]{j, UtilsProfil1d.abscisseCurviligne(seqAxeHydraulique, intersection.getCoordinate())}; + if(axeHydraulique_.getNombre()==0) { + for(int j=0;j<profils_.getNombre();j++) { + GISZoneCollection zone=profils_.getGeomData(); + String value=(String) zone.getValue(zone.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO), j); + idxAbsCurv[j]=new Object[]{j, GISLib.getHydroCommentDouble(value, "PK")}; + } } + else { + Geometry axeHydraulique=(Geometry)axeHydraulique_.getObject(0); + CoordinateSequence seqAxeHydraulique=((GISCoordinateSequenceContainerInterface)axeHydraulique).getCoordinateSequence(); + for(int j=0;j<profils_.getNombre();j++) { + Geometry intersection=axeHydraulique.intersection((Geometry) profils_.getObject(j)); + if(intersection.getNumPoints()==0) + throw new IllegalArgumentException("Au moins un des profils ne coupe jamais l'axe hydraulique."); + if(intersection.getNumPoints()>1) + throw new IllegalArgumentException("Au moins un des profils coupe plusieurs fois l'axe hydraulique."); + idxAbsCurv[j]=new Object[]{j, UtilsProfil1d.abscisseCurviligne(seqAxeHydraulique, intersection.getCoordinate())}; + } + } // Tri en fonction des abcsisses curvilignes Arrays.sort((Object[])idxAbsCurv, new Comparator<Object>(){ public int compare(Object o1, Object o2) { @@ -779,6 +832,8 @@ * Retourne -1 si \xE0 gauche, 0 si ind\xE9terminable, 1 si \xE0 droite. */ private int position(Geometry _geom) { + if(axeHydraulique_.getNombre()==0) + return 0; // Recherche d'intersection de _geom avec un profil boolean found=false; int i=-1; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java 2009-02-11 10:57:27 UTC (rev 4455) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java 2009-02-11 11:48:56 UTC (rev 4456) @@ -25,6 +25,7 @@ import org.fudaa.ctulu.gis.GISAttributeModelIntegerList; import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; import org.fudaa.ctulu.gis.GISGeometryFactory; +import org.fudaa.ctulu.gis.GISLib; import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; import org.fudaa.fudaa.commun.FudaaLib; @@ -232,8 +233,12 @@ } else if (biefContainer_.getZoneProfils()!=null&&idxProfilSelected_>=0&&idxProfilSelected_<biefContainer_.getZoneProfils().getNbGeometries()&&biefContainer_.getZoneProfils().getAttributeIsZ()!=null) { try { - int idxAttrDecCurv=biefContainer_.getZoneAxeHydraulique().getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE); - curviligneDecalage_=(Double) biefContainer_.getZoneAxeHydraulique().getValue(idxAttrDecCurv, 0); + if(biefContainer_.getZoneAxeHydraulique().getNumGeometries()==0) + curviligneDecalage_=0; + else { + int idxAttrDecCurv=biefContainer_.getZoneAxeHydraulique().getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE); + curviligneDecalage_=(Double) biefContainer_.getZoneAxeHydraulique().getValue(idxAttrDecCurv, 0); + } z_=(CtuluCollection)biefContainer_.getZoneProfils().getValue(biefContainer_.getZoneProfils().getIndiceOf(biefContainer_.getZoneProfils().getAttributeIsZ()), idxProfilSelected_); curv_=new ArrayList<Double>(); CoordinateSequence seq=((GISCoordinateSequenceContainerInterface)biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_)).getCoordinateSequence(); @@ -350,10 +355,16 @@ } public double getAbsCurvProfilOnAxeHydraulique() { - if (idxProfilSelected_==-1||biefContainer_.getZoneAxeHydraulique().getNbGeometries()==0) + if (idxProfilSelected_==-1) return -1; - return UtilsProfil1d.abscisseCurviligne(((GISCoordinateSequenceContainerInterface)biefContainer_.getZoneAxeHydraulique() - .getGeometry(0)).getCoordinateSequence(), getCoordSeq())+curviligneDecalage_; + if(biefContainer_.getZoneAxeHydraulique().getNbGeometries()==0) { + GISZoneCollection zone=biefContainer_.getZoneProfils(); + String value=(String)zone.getValue(zone.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO), idxProfilSelected_); + return GISLib.getHydroCommentDouble(value, "PK"); + } + else + return UtilsProfil1d.abscisseCurviligne(biefContainer_.getZoneAxeHydraulique() + .getCoordinateSequence(0), getCoordSeq())+curviligneDecalage_; } public int getNbLignesDirectrices() { @@ -450,7 +461,7 @@ } public double getAbsCurvAxeHydrauliqueOnProfil() { - if(idxProfilSelected_==-1||biefContainer_.getZoneAxeHydraulique().getNbGeometries()==0) + if (idxProfilSelected_==-1||biefContainer_.getZoneAxeHydraulique().getNbGeometries()==0) return -1; Geometry intersection=biefContainer_.getZoneAxeHydraulique().getGeometry(0).intersection( biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_)); @@ -526,134 +537,120 @@ public boolean setAbsCurvProfilOnAxeHydraulique(double _value, CtuluCommandContainer _cmd) throws ProfilContainerException { _value=_value-curviligneDecalage_; - CoordinateSequence axeHydrau=((GISCoordinateSequenceContainerInterface)biefContainer_.getZoneAxeHydraulique().getGeometry(0)) - .getCoordinateSequence(); - Geometry geomAxeHydrau=biefContainer_.getZoneAxeHydraulique().getGeometry(0); - if (_value<0||_value>UtilsProfil1d.abscisseCurviligne(axeHydrau, axeHydrau.getCoordinate(axeHydrau.size()-1))) - throw new IllegalArgumentException(FudaaLib.getS("L'abscisse curviligne doit \xEAtre entre " +curviligneDecalage_+" et " - +(UtilsProfil1d.abscisseCurviligne(axeHydrau, axeHydrau.getCoordinate(axeHydrau.size()-1))+curviligneDecalage_)+" inclus.")); - CtuluCommandComposite cmd=new CtuluCommandComposite(FudaaLib.getS("D\xE9placement d'un profil")); - // Calcul de la coordonn\xE9e actuelle de croisement entre l'axe et le profil - Geometry intersection=geomAxeHydrau.intersection( - biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_)); - if (intersection.getNumPoints()!=1) - throw new ProfilContainerException(FudaaLib - .getS("Soit il n'y a pas de croisement avec l'axe hydraulique, soit il y en a plusieurs.")); - // Point de croisement actuel entre l'axe et le profil - Coordinate oldCoordCroisement=intersection.getCoordinate(); - double oldAbscisseCurviligne=UtilsProfil1d.abscisseCurviligne(axeHydrau, oldCoordCroisement); - if (!UtilsProfil1d.egal(_value, oldAbscisseCurviligne)) { - // Cr\xE9ation d'une selection contenant la g\xE9om\xE9trie \xE0 modifier - BitSet bs=new BitSet(biefContainer_.getZoneProfils().getNbGeometries()); - bs.set(idxProfilSelected_); - CtuluListSelection selection=new CtuluListSelection(bs); - // Calcul du future point de croisement entre l'axe et le profil - Coordinate newCoordCroisement=UtilsProfil1d.getCoordinateXY(axeHydrau, _value); - // Application de la translation - Coordinate move=UtilsProfil1d.vec(oldCoordCroisement, newCoordCroisement); - biefContainer_.getModelProfils().moveGlobal(selection, move.x, move.y, 0, cmd); - // Somme de tous les angles de l'axe entre les deux points de translation - int oldNextIdx=UtilsProfil1d.getNextIndex(axeHydrau, oldCoordCroisement); - if (oldNextIdx==-1) - oldNextIdx=axeHydrau.size()-1; - double oldAngle=0; - for (int i=0; i+2<=oldNextIdx; i++) - oldAngle+=Math.PI - -UtilsProfil1d.getAngle(axeHydrau.getCoordinate(i), axeHydrau.getCoordinate(i+1), axeHydrau.getCoordinate(i+2)); - int newNextIdx=UtilsProfil1d.getNextIndex(axeHydrau, newCoordCroisement); - if (newNextIdx==-1) - newNextIdx=axeHydrau.size()-1; - double newAngle=0; - for (int i=0; i+2<=newNextIdx; i++) - newAngle+=Math.PI - -UtilsProfil1d.getAngle(axeHydrau.getCoordinate(i), axeHydrau.getCoordinate(i+1), axeHydrau.getCoordinate(i+2)); - // Application de la rotation - biefContainer_.getModelProfils().rotateGlobal(selection, newAngle-oldAngle, newCoordCroisement.x, newCoordCroisement.y, cmd); - // Verifie que le profil ne coupe pas deux fois l'axe hydraulique - Geometry intersect=geomAxeHydrau.intersection(biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_)); - if(intersect.getNumPoints()!=1) { - cmd.undo(); // Annulation des modifications - throw new ProfilContainerException(FudaaLib.getS("Le profil couperait l'axe hydraulique en au moins deux endroits.")); + if (biefContainer_.getZoneAxeHydraulique().getNumGeometries()>0) { + CoordinateSequence axeHydrau=((GISCoordinateSequenceContainerInterface)biefContainer_.getZoneAxeHydraulique().getGeometry(0)) + .getCoordinateSequence(); + Geometry geomAxeHydrau=biefContainer_.getZoneAxeHydraulique().getGeometry(0); + if (_value<0||_value>UtilsProfil1d.abscisseCurviligne(axeHydrau, axeHydrau.getCoordinate(axeHydrau.size()-1))) + throw new IllegalArgumentException(FudaaLib.getS("L'abscisse curviligne doit \xEAtre entre "+curviligneDecalage_+" et " + +(UtilsProfil1d.abscisseCurviligne(axeHydrau, axeHydrau.getCoordinate(axeHydrau.size()-1))+curviligneDecalage_) + +" inclus.")); + CtuluCommandComposite cmd=new CtuluCommandComposite(FudaaLib.getS("D\xE9placement d'un profil")); + // Calcul de la coordonn\xE9e actuelle de croisement entre l'axe et le profil + Geometry intersection=geomAxeHydrau.intersection(biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_)); + if (intersection.getNumPoints()!=1) + throw new ProfilContainerException(FudaaLib + .getS("Soit il n'y a pas de croisement avec l'axe hydraulique, soit il y en a plusieurs.")); + // Point de croisement actuel entre l'axe et le profil + Coordinate oldCoordCroisement=intersection.getCoordinate(); + double oldAbscisseCurviligne=UtilsProfil1d.abscisseCurviligne(axeHydrau, oldCoordCroisement); + if (!UtilsProfil1d.egal(_value, oldAbscisseCurviligne)) { + // Cr\xE9ation d'une selection contenant la g\xE9om\xE9trie \xE0 modifier + BitSet bs=new BitSet(biefContainer_.getZoneProfils().getNbGeometries()); + bs.set(idxProfilSelected_); + CtuluListSelection selection=new CtuluListSelection(bs); + // Calcul du future point de croisement entre l'axe et le profil + Coordinate newCoordCroisement=UtilsProfil1d.getCoordinateXY(axeHydrau, _value); + // Application de la translation + Coordinate move=UtilsProfil1d.vec(oldCoordCroisement, newCoordCroisement); + biefContainer_.getModelProfils().moveGlobal(selection, move.x, move.y, 0, cmd); + // Somme de tous les angles de l'axe entre les deux points de + // translation + int oldNextIdx=UtilsProfil1d.getNextIndex(axeHydrau, oldCoordCroisement); + if (oldNextIdx==-1) + oldNextIdx=axeHydrau.size()-1; + double oldAngle=0; + for (int i=0; i+2<=oldNextIdx; i++) + oldAngle+=Math.PI + -UtilsProfil1d.getAngle(axeHydrau.getCoordinate(i), axeHydrau.getCoordinate(i+1), axeHydrau.getCoordinate(i+2)); + int newNextIdx=UtilsProfil1d.getNextIndex(axeHydrau, newCoordCroisement); + if (newNextIdx==-1) + newNextIdx=axeHydrau.size()-1; + double newAngle=0; + for (int i=0; i+2<=newNextIdx; i++) + newAngle+=Math.PI + -UtilsProfil1d.getAngle(axeHydrau.getCoordinate(i), axeHydrau.getCoordinate(i+1), axeHydrau.getCoordinate(i+2)); + // Application de la rotation + biefContainer_.getModelProfils() + .rotateGlobal(selection, newAngle-oldAngle, newCoordCroisement.x, newCoordCroisement.y, cmd); + // Verifie que le profil ne coupe pas deux fois l'axe hydraulique + Geometry intersect=geomAxeHydrau.intersection(biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_)); + if (intersect.getNumPoints()!=1) { + cmd.undo(); // Annulation des modifications + throw new ProfilContainerException(FudaaLib.getS("Le profil couperait l'axe hydraulique en au moins deux endroits.")); + } + // Gestion de l'undo/redo + if (_cmd!=null) + _cmd.addCmd(cmd.getSimplify()); + // Retourne vrai si il faut r\xE9ordonnancer les profils + int oldPreviousIdx=UtilsProfil1d.getPreviousIndex(axeHydrau, oldCoordCroisement); + if (oldPreviousIdx==-1) + oldPreviousIdx=0; + if (idxProfilSelected_==0) { + if (biefContainer_.getNbProfil()>1) { + Geometry inter=geomAxeHydrau.intersection(biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_+1)); + if (inter.getNumPoints()!=1) + throw new ProfilContainerException(FudaaLib + .getS("Au moins un profil n'a pas de croisement avec l'axe hydraulique ou en a plusieurs.")); + if (_value>UtilsProfil1d.abscisseCurviligne(axeHydrau, inter.getCoordinate())) + return true; + } + } + else if (idxProfilSelected_==biefContainer_.getNbProfil()-1) { + if (biefContainer_.getNbProfil()>1) { + Geometry inter=geomAxeHydrau.intersection(biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_-1)); + if (inter.getNumPoints()!=1) + throw new ProfilContainerException(FudaaLib + .getS("Au moins un profil n'a pas de croisement avec l'axe hydraulique ou en a plusieurs.")); + if (_value<UtilsProfil1d.abscisseCurviligne(axeHydrau, inter.getCoordinate())) + return true; + } + } + else { + Geometry intersect1=geomAxeHydrau.intersection(biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_+1)); + Geometry intersect2=geomAxeHydrau.intersection(biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_-1)); + if (intersect1.getNumPoints()!=1||intersect2.getNumPoints()!=1) + throw new ProfilContainerException(FudaaLib + .getS("Au moins un profil n'a pas de croisement avec l'axe hydraulique ou en a plusieurs.")); + double abscCurvProfilPrecedent=UtilsProfil1d.abscisseCurviligne(axeHydrau, intersect2.getCoordinate()); + double abscCurvProfilSuivant=UtilsProfil1d.abscisseCurviligne(axeHydrau, intersect1.getCoordinate()); + if (_value<abscCurvProfilPrecedent||_value>abscCurvProfilSuivant) + return true; + } } + return false; + } + else { // Modification bas\xE9e sur l'attribut commentaire hydraulique. + CtuluCommandComposite cmd=new CtuluCommandComposite(FudaaLib.getS("D\xE9placement d'un profil")); + GISZoneCollection zone=biefContainer_.getZoneProfils(); + int idxAttrComm=zone.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO); + String comm=(String) zone.getValue(idxAttrComm, idxProfilSelected_); + zone.setAttributValue(idxAttrComm, idxProfilSelected_, GISLib.setHydroCommentDouble(comm, _value, "PK"), cmd); // Gestion de l'undo/redo if (_cmd!=null) _cmd.addCmd(cmd.getSimplify()); // Retourne vrai si il faut r\xE9ordonnancer les profils - int oldPreviousIdx=UtilsProfil1d.getPreviousIndex(axeHydrau, oldCoordCroisement); - if (oldPreviousIdx==-1) - oldPreviousIdx=0; - if(idxProfilSelected_==0) { - if(biefContainer_.getNbProfil()>1) { - Geometry inter=geomAxeHydrau.intersection(biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_+1)); - if(inter.getNumPoints()!=1) - throw new ProfilContainerException(FudaaLib.getS("Au moins un profil n'a pas de croisement avec l'axe hydraulique ou en a plusieurs.")); - if (_value>UtilsProfil1d.abscisseCurviligne(axeHydrau, inter.getCoordinate())) - return true; - } - } - else if (idxProfilSelected_==biefContainer_.getNbProfil()-1) { - if(biefContainer_.getNbProfil()>1) { - Geometry inter=geomAxeHydrau.intersection(biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_-1)); - if(inter.getNumPoints()!=1) - throw new ProfilContainerException(FudaaLib.getS("Au moins un profil n'a pas de croisement avec l'axe hydraulique ou en a plusieurs.")); - if (_value<UtilsProfil1d.abscisseCurviligne(axeHydrau, inter.getCoordinate())) - return true; - } - } - else { - Geometry intersect1=geomAxeHydrau.intersection(biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_+1)); - Geometry intersect2=geomAxeHydrau.intersection(biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_-1)); - if(intersect1.getNumPoints()!=1||intersect2.getNumPoints()!=1) - throw new ProfilContainerException(FudaaLib.getS("Au moins un profil n'a pas de croisement avec l'axe hydraulique ou en a plusieurs.")); - double abscCurvProfilPrecedent=UtilsProfil1d.abscisseCurviligne(axeHydrau, intersect2.getCoordinate()); - double abscCurvProfilSuivant=UtilsProfil1d.abscisseCurviligne(axeHydrau, intersect1.getCoordinate()); - if (_value<abscCurvProfilPrecedent||_value>abscCurvProfilSuivant) + if(idxProfilSelected_>0) { + if(GISLib.getHydroCommentDouble((String)zone.getValue(idxAttrComm, idxProfilSelected_-1), "PK")>_value) return true; } + else if(zone.getNumGeometries()-1<idxProfilSelected_) + if(GISLib.getHydroCommentDouble((String)zone.getValue(idxAttrComm, idxProfilSelected_+1), "PK")>_value) + return true; + return false; } - return false; } - /** - * Retourne l'angle entre l'axe hydraulique et le profil - * @throws ProfilContainerException - */ - @SuppressWarnings("unused") - private double getAngleAxeHydrauProfil() throws ProfilContainerException { - CoordinateSequence axeHydraulique=((GISCoordinateSequenceContainerInterface)biefContainer_.getZoneAxeHydraulique().getGeometry( - 0)).getCoordinateSequence(); - // Calcul de la coordonn\xE9e de croisement entre l'axe et le profil - Geometry intersection=biefContainer_.getZoneAxeHydraulique().getGeometry(0).intersection( - biefContainer_.getZoneProfils().getGeometry(idxProfilSelected_)); - if (intersection.getNumPoints()!=1) - throw new ProfilContainerException(FudaaLib - .getS("Soit il n'y a pas de croisement avec l'axe hydraulique, soit il y en a plusieurs.")); - Coordinate coordCroisement=intersection.getCoordinate(); - // Recherche du point pr\xE9c\xE9dent le croisement sur l'axe hydraulique - Coordinate previousPointAH; - int idxPointPreviousAH=UtilsProfil1d.getPreviousIndex(axeHydraulique, coordCroisement); - if (idxPointPreviousAH!=-1) - previousPointAH=axeHydraulique.getCoordinate(idxPointPreviousAH); - else - // Cr\xE9ation d'un nouveau point en faisant la sym\xE9trie du second par - // rapport au premier. - previousPointAH=new Coordinate(axeHydraulique.getCoordinate(0).x*2-axeHydraulique.getCoordinate(1).x, axeHydraulique - .getCoordinate(0).y*2-axeHydraulique.getCoordinate(1).y, 0); - // Recherche du point suivant le croisement sur le profil - Coordinate previousPointP; - int idxPointPreviousP=UtilsProfil1d.getPreviousIndex(getCoordSeq(), coordCroisement); - if (idxPointPreviousP!=-1) - previousPointP=getCoordSeq().getCoordinate(idxPointPreviousAH); - else { - CoordinateSequence seq=getCoordSeq(); - // Cr\xE9ation d'un nouveau point en faisant la sym\xE9trie du second par - // rapport au premier. - previousPointP=new Coordinate(seq.getCoordinate(seq.size()-1).x*2-seq.getCoordinate(seq.size()-2).x, seq.getCoordinate(seq - .size()-1).y*2-seq.getCoordinate(seq.size()-2).y, 0); - } - return UtilsProfil1d.getAngle(previousPointAH, coordCroisement, previousPointP); - } - public double getCurv(int _idxPoint) { if(curv_==null||_idxPoint<0||_idxPoint>=curv_.size()) throw new IllegalArgumentException("Cet index n'existe pas."); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java 2009-02-11 10:57:27 UTC (rev 4455) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java 2009-02-11 11:48:56 UTC (rev 4456) @@ -438,4 +438,5 @@ } return data; } + } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionAxeHydraulique.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionAxeHydraulique.java 2009-02-11 10:57:27 UTC (rev 4455) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionAxeHydraulique.java 2009-02-11 11:48:56 UTC (rev 4456) @@ -27,7 +27,7 @@ /** * Petit module permettant de modifier les propri\xE9t\xE9s de l'axe hydraulique. * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public class VueModuleGestionAxeHydraulique extends BuPanel{ @@ -66,8 +66,10 @@ try { double value=Double.parseDouble(btDecalageCurviligne_.getText()); GISZoneCollection zone=controllerBief_.getBiefContainer().getZoneAxeHydraulique(); - int idxAttr=zone.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE); - zone.setAttributValue(idxAttr, 0, value, controllerBief_.getCommandManager()); + if(zone.getNumGeometries()>0) { + int idxAttr=zone.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE); + zone.setAttributValue(idxAttr, 0, value, controllerBief_.getCommandManager()); + } } catch(NumberFormatException _ex) {} } @@ -81,7 +83,7 @@ */ private String getDecalageCurviligne() { GISZoneCollection zone=controllerBief_.getBiefContainer().getZoneAxeHydraulique(); - if(zone==null) + if(zone==null||zone.getNumGeometries()==0) return ""; int idxAttr=zone.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE); return Double.toString((Double) zone.getValue(idxAttr, 0)); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueTableau.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueTableau.java 2009-02-11 10:57:27 UTC (rev 4455) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueTableau.java 2009-02-11 11:48:56 UTC (rev 4456) @@ -23,7 +23,6 @@ import org.fudaa.ctulu.CtuluCommandComposite; import org.fudaa.ctulu.gui.CtuluTable; -import org.fud... [truncated message content] |
From: <bma...@us...> - 2009-02-10 09:33:50
|
Revision: 4450 http://fudaa.svn.sourceforge.net/fudaa/?rev=4450&view=rev Author: bmarchan Date: 2009-02-10 09:33:45 +0000 (Tue, 10 Feb 2009) Log Message: ----------- Tache #161, #160 : Affichage d'un attrribut atomique sous forme de labels. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/EbliSingleObjectEditorPanel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/commun/TableModelModeleAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dAxe.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dTrace.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dCloud.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dConstraintLine.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dContour.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dDirectionLine.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dLevel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dProfile.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dZone.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dAxe.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dTrace.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dCloud.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dConstraintLine.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dContour.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dDirectionLine.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLevel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dProfile.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dZone.java Added Paths: ----------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/SceneShowLabelAction.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -167,6 +167,15 @@ }; /** + * Un attribut label, atomique. + */ + public final static GISAttributeString LABEL = new GISAttributeString(CtuluLib.getS("Label"), true) { + public String getID() { + return "ATTRIBUTE_LABEL"; + } + }; + + /** * Un attribut bathy, atomique. */ public final static GISAttributeDouble BATHY = new GISAttributeDouble(CtuluLib.getS("z"), true) { @@ -189,7 +198,7 @@ /** La liste des attributs syst\xE8mes. */ protected final static List<GISAttribute> attrs_= - Arrays.asList(new GISAttribute[]{BATHY,TITRE,NATURE,VISIBILITE,ETAT_GEOM,COMMENTAIRE_HYDRO}); + Arrays.asList(new GISAttribute[]{BATHY,TITRE,NATURE,VISIBILITE,ETAT_GEOM,COMMENTAIRE_HYDRO,LABEL}); private GISAttributeConstants() {} Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISLib.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -630,11 +630,6 @@ * @see {@link #createAttributeFrom(GISAttributeInterface, boolean)} */ public static GISAttributeInterface createAttributeFrom(final AttributeType _type) { - final GISAttributeInterface known = GISAttributeConstants.getConstantAttribute(_type.getName()); - if (known != null && known.getDataClass().equals(_type.getType())) { - return known; - } - String name=_type.getName(); Class<?> clazz=_type.getType(); boolean isAtomic=false; @@ -660,6 +655,11 @@ name=name.substring(3); isAtomic=true; } + + final GISAttributeInterface known = GISAttributeConstants.getConstantAttribute(name); + if (known != null && known.getDataClass().equals(clazz)) { + return known; + } return createAttributeFrom(name, clazz, isAtomic); } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueGeometry.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -12,8 +12,10 @@ import gnu.trove.TObjectIntHashMap; import java.awt.Color; +import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; import org.fudaa.ctulu.CtuluExpr; import org.fudaa.ctulu.CtuluLib; @@ -21,6 +23,7 @@ import org.fudaa.ctulu.CtuluListSelection; import org.fudaa.ctulu.CtuluListSelectionInterface; import org.fudaa.ctulu.gis.GISAttributeInterface; +import org.fudaa.ctulu.gis.GISAttributeModel; import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; import org.fudaa.ctulu.gis.GISGeometryFactory; import org.fudaa.ctulu.gis.GISLib; @@ -120,8 +123,9 @@ protected ZSelectionTrace traceAtomic_; /** Le mod\xE8le pour le trac\xE9 de surfaces */ protected TraceSurfaceModel surfModel_; + /** L'attribut utilis\xE9 pour afficher les labels */ + protected GISAttributeInterface attrLabels_=null; - /** * Le seul constructeur, avec le mod\xE8le. * @param _modele le modele du calque @@ -410,6 +414,18 @@ } /** + * D\xE9finit l'attribut atomique pris pour afficher les labels. + * @param _att L'attribut. Si Null : Pas d'affichage de labels. + */ + public void setAttributForLabels(GISAttributeInterface _att) { + if (_att==null || !_att.isAtomicValue()) + attrLabels_=null; + else + attrLabels_=_att; + repaint(); + } + + /** * Indique si la s\xE9lection est vide. * @return true Si aucun objet ni aucun point en mode atomique selectionn\xE9. */ @@ -550,7 +566,7 @@ modele_.point(ptOri, i, nbPoints - 1); ptOri.autoApplique(versEcran); } - + // on trace les icones apres pour qu'ils soient dessin\xE9s au-dessus des lignes. if (icone != null) { for (int i = nombre - 1; i >= 0; i--) { @@ -572,6 +588,7 @@ continue; } if (!isRapide()) initTrace(iconeModel, i); + final GrPoint ptDest = new GrPoint(); for (int j = nbPoints - 1; j >= 0; j--) { // le point de dest est initialise @@ -584,6 +601,66 @@ } } } + + // Enfin les labels sur les atomiques. + if (attrLabels_!=null && !isRapide()) { + GISZoneCollection geomData = modeleDonnees().getGeomData(); + int idxLabels=geomData.getIndiceOf(attrLabels_); + + if (idxLabels!=-1) { + final FontMetrics fm = _g.getFontMetrics(); + final Color fgColor = _g.getColor(); + final Color bgColor = getBackground(); + + for (int i=nombre-1; i>=0; i--) { + // il n'y a pas de points pour cette ligne + if (modele_.getNbPointForGeometry(i)<=0) { + continue; + } + // La g\xE9ometrie n'est pas visible + if (!modele_.isGeometryVisible(i)) + continue; + + modele_.getDomaineForGeometry(i, bPoly); + // Si la boite du polygone n'est pas dans la boite d'affichage on + // passe + if (bPoly.intersectionXY(clip)==null) { + continue; + } + final int nbPoints=modele_.getNbPointForGeometry(i); + if (nbPoints<=0) { + continue; + } + + GISAttributeModel mdl=(GISAttributeModel)geomData.getModel(idxLabels).getObjectValueAt(i); + + final GrPoint ptDest=new GrPoint(); + for (int j=nbPoints-1; j>=0; j--) { + modele_.point(ptDest, i, j); + if (!_clipReel.contientXY(ptDest)) { + continue; + } + + Object o=mdl.getObjectValueAt(j); + if (o==null) + continue; + String s=o.toString().trim(); + if (s.equals("")) + continue; + + ptDest.autoApplique(versEcran); + final Rectangle2D rec=fm.getStringBounds(s, _g); + double x=ptDest.x_-rec.getWidth()/2; + double y=ptDest.y_-3; + rec.setFrame(x, y-fm.getAscent(), rec.getWidth(), fm.getAscent()+2); + _g.setColor(bgColor); + _g.fill(rec); + _g.setColor(fgColor); + _g.drawString(s, (int)x, (int)y); + } + } + } + } } public void paintSelection(final Graphics2D _g, final ZSelectionTrace _trace, final GrMorphisme _versEcran, Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZCalqueLigneBrisee.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -12,16 +12,18 @@ import gnu.trove.TObjectIntHashMap; import java.awt.Color; +import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; import org.fudaa.ctulu.CtuluExpr; import org.fudaa.ctulu.CtuluLib; import org.fudaa.ctulu.CtuluLibArray; import org.fudaa.ctulu.CtuluListSelection; import org.fudaa.ctulu.CtuluListSelectionInterface; -import org.fudaa.ctulu.gis.GISZoneListener; import org.fudaa.ctulu.gis.GISAttributeInterface; +import org.fudaa.ctulu.gis.GISAttributeModel; import org.fudaa.ctulu.gis.GISGeometryFactory; import org.fudaa.ctulu.gis.GISLib; import org.fudaa.ctulu.gis.GISZoneCollection; @@ -126,6 +128,8 @@ protected ZSelectionTrace traceAtomic_; /** On dessine une fl\xE8che sur chaque ligne pour indiquer le sens de celle-ci. */ protected boolean showLineOrientation_; + /** L'attribut utilis\xE9 pour afficher les labels */ + protected GISAttributeInterface attrLabels_=null; /** * @@ -478,6 +482,18 @@ return isAtomicMode_; } + /** + * D\xE9finit l'attribut atomique pris pour afficher les labels. + * @param _att L'attribut. Si Null : Pas d'affichage de labels. + */ + public void setAttributForLabels(GISAttributeInterface _att) { + if (_att==null || !_att.isAtomicValue()) + attrLabels_=null; + else + attrLabels_=_att; + repaint(); + } + public boolean isConfigurable() { return true; } @@ -661,6 +677,67 @@ } } } + + // Enfin les labels sur les atomiques. + if (attrLabels_!=null && !isRapide()) { + GISZoneCollection geomData = getModele().getGeomData(); + int idxLabels=geomData.getIndiceOf(attrLabels_); + + if (idxLabels!=-1) { + final FontMetrics fm = _g.getFontMetrics(); + final Color fgColor = _g.getColor(); + final Color bgColor = getBackground(); + + for (int i=nombre-1; i>=0; i--) { + // il n'y a pas de points pour cette ligne + if (modele_.getNbPointForGeometry(i)<=0) { + continue; + } + // La g\xE9ometrie n'est pas visible + if (!modele_.isGeometryVisible(i)) + continue; + + modele_.getDomaineForGeometry(i, bPoly); + // Si la boite du polygone n'est pas dans la boite d'affichage on + // passe + if (bPoly.intersectionXY(clip)==null) { + continue; + } + final int nbPoints=modele_.getNbPointForGeometry(i); + if (nbPoints<=0) { + continue; + } + + GISAttributeModel mdl=(GISAttributeModel)geomData.getModel(idxLabels).getObjectValueAt(i); + + final GrPoint ptDest=new GrPoint(); + for (int j=nbPoints-1; j>=0; j--) { + modele_.point(ptDest, i, j); + if (!_clipReel.contientXY(ptDest)) { + continue; + } + + // Les labels : Uniquement si le string correspondant n'est pas "". + Object o=mdl.getObjectValueAt(j); + if (o==null) + continue; + String s=o.toString().trim(); + if (s.equals("")) + continue; + + ptDest.autoApplique(versEcran); + final Rectangle2D rec=fm.getStringBounds(s, _g); + double x=ptDest.x_-rec.getWidth()/2; + double y=ptDest.y_-3; + rec.setFrame(x, y-fm.getAscent(), rec.getWidth(), fm.getAscent()+2); + _g.setColor(bgColor); + _g.fill(rec); + _g.setColor(fgColor); + _g.drawString(s, (int)x, (int)y); + } + } + } + } } public void paintSelection(final Graphics2D _g, final ZSelectionTrace _trace, final GrMorphisme _versEcran, Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/EbliSingleObjectEditorPanel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/EbliSingleObjectEditorPanel.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/EbliSingleObjectEditorPanel.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -37,7 +37,6 @@ import javax.swing.event.TableModelListener; import javax.swing.table.AbstractTableModel; import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableCellEditor; import javax.swing.table.TableColumnModel; import javax.swing.table.TableModel; @@ -82,7 +81,6 @@ import com.memoire.bu.BuResource; import com.memoire.bu.BuScrollPane; import com.memoire.bu.BuSplit2Pane; -import com.memoire.bu.BuTableCellRenderer; import com.memoire.fu.FuLog; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateSequence; @@ -307,13 +305,12 @@ public class CourbeRepresentation extends BuPanel implements TableModelListener, CtuluListSelectionListener, ListSelectionListener { /** - * Cette classe donne un acc\xE8s restraint au model 'model_'. Concr\xE8tement - * seules trois colonnes sont visibles : index, curviligne et z. Et seul z est \xE9ditable. + * Cette classe donne un acc\xE8s restraint au model 'model_'. Le X et Y sont remplac\xE9s par un asbcisse curviligne. * * @author Emmanuel MARTIN * @version $Id:$ */ - protected class LimitedTableRepresentation extends AbstractTableModel implements TableModelListener { + protected class LimitedTableModel extends AbstractTableModel implements TableModelListener { /** * Le renderer des cellules du tableau. @@ -324,6 +321,8 @@ if(value instanceof Double) return super.getTableCellRendererComponent(table, xyFormatter_.getXYFormatter().format((Double) value), isSelected, hasFocus, row, column); + if(value instanceof Boolean) + return table.getDefaultRenderer(Boolean.class).getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); else return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } @@ -334,13 +333,13 @@ /** * @param _xyFormatter le formateur pour la colonne des curvilignes */ - public LimitedTableRepresentation(EbliFormatterInterface _xyFormatter){ + public LimitedTableModel(EbliFormatterInterface _xyFormatter){ xyFormatter_=_xyFormatter; modelData_.addTableModelListener(this); } public int getColumnCount() { - return 3; + return modelData_.getColumnCount()-1; } public int getRowCount() { @@ -352,24 +351,22 @@ case 0: return _rowIndex+1; case 1: - return /*xyFormatter_.getXYFormatter().format(*/getX(_rowIndex);//); - case 2: - return getY(_rowIndex); + return getX(_rowIndex); default: - return null; + return modelData_.getValueAt(_rowIndex, _columnIndex+1); } } public boolean isCellEditable(final int _rowIndex, final int _columnIndex) { if (_columnIndex<2) return false; -// return modelData_.isCellEditable(_rowIndex, _columnIndex); - return true; + + return modelData_.isCellEditable(_rowIndex, _columnIndex+1); } public void setValueAt(final Object _value, final int _rowIndex, final int _columnIndex) { - if(_columnIndex == 2) - setY(_rowIndex, (Double)_value, null); + if(_columnIndex >= 2) + modelData_.setValueAt(_value, _rowIndex, _columnIndex+1); } public String getColumnName(int _column) { @@ -378,10 +375,8 @@ return EbliLib.getS(EbliLib.getS("Index")); case 1: return EbliLib.getS(EbliLib.getS("Abscisse")); - case 2: - return modelData_.getColumnName(zCol_); default: - return null; + return modelData_.getColumnName(_column+1); } } @@ -391,10 +386,8 @@ return Integer.class; case 1: return Double.class; - case 2: - return Double.class; default: - return null; + return modelData_.getColumnClass(_columnIndex); } } @@ -405,15 +398,23 @@ fireTableChanged(new TableModelEvent((TableModel)_e.getSource(), _e.getFirstRow(), _e.getLastRow(), col, _e.getType())); } - public void updateCellEditor(final JTable _table) { - final TableColumnModel cols = _table.getColumnModel(); - // Editor : Abscisse, Z - final TableCellEditor ed = xyFormatter_.createTableEditorComponent(); - cols.getColumn(1).setCellEditor(ed); - cols.getColumn(2).setCellEditor(ed); - // Renderer : Abscisse, Z - cols.getColumn(1).setCellRenderer(new Renderer()); - cols.getColumn(2).setCellRenderer(new Renderer()); + public void updateCellEditor(JTable _table) { + TableColumnModel cols=_table.getColumnModel(); + + // Renderer \\ + Renderer renderer=new Renderer(); + for(int i=0;i<cols.getColumnCount();i++) + cols.getColumn(i).setCellRenderer(renderer); + + // Editors \\ + // Colonnes des attributs + if (modelData_!=null) { + for (int i=3; i<modelData_.getColumnCount(); i++) { + CtuluValueEditorI editor=modelData_.getAttribute(i).getEditor(); + if (editor!=null) + cols.getColumn(i-1).setCellEditor(editor.createTableEditorComponent()); + } + } } } @@ -436,12 +437,12 @@ private CtuluTable tableauVue_; // Selection update private boolean disable; - /** Indice de la colonne z. */ + /** Indice de la colonne z sur le modele data global. */ protected int zCol_; public CourbeRepresentation() { disable = false; - zCol_=zone_.getIndiceOf(zone_.getAttributeIsZ())+3; // l'index + les colonnes index, x et y + zCol_=/*zone_.getIndiceOf(zone_.getAttributeIsZ())+*/3; // l'index + les colonnes index, x et y modelData_.addTableModelListener(this); // Construction de la courbe \\ setPreferredSize(new Dimension(650,450)); @@ -491,7 +492,7 @@ } } // Construction du tableau \\ - LimitedTableRepresentation tableau = new LimitedTableRepresentation(modelData_.getFormatter()); + LimitedTableModel tableau = new LimitedTableModel(modelData_.getFormatter()); tableauVue_ = new CtuluTable(); tableauVue_.setModel(tableau); tableauVue_.getSelectionModel().addListSelectionListener(this); @@ -584,8 +585,11 @@ int[] selectedIndex=((CtuluListSelectionInterface)_e.getSource()).getSelectedIndex(); ListSelectionModel lstTableauSelect=tableauVue_.getSelectionModel(); lstTableauSelect.clearSelection(); - for (int i=0; i<selectedIndex.length; i++) - lstTableauSelect.addSelectionInterval(selectedIndex[i], selectedIndex[i]); + if (selectedIndex!=null && selectedIndex.length>0) { + for (int i=0; i<selectedIndex.length; i++) + lstTableauSelect.addSelectionInterval(selectedIndex[i], selectedIndex[i]); + tableauVue_.scrollRectToVisible(tableauVue_.getCellRect(selectedIndex[selectedIndex.length-1], 0, false)); + } // R\xE9activation de l'\xE9coute de changement de selection de le tableau disable=false; } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/commun/TableModelModeleAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/commun/TableModelModeleAdapter.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/commun/TableModelModeleAdapter.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -522,6 +522,13 @@ } /** + * Retourne l'attribut pour la colonne + */ + public GISAttributeInterface getAttribute(int _columnIndex) { + return mapColonne_.get(_columnIndex).attribute; + } + + /** * Retourne l'index de la g\xE9om\xE9trie selectionn\xE9e. */ public int getSelectedGeometry() { @@ -586,7 +593,7 @@ return "y"; default: if(mapColonne_!=null) - return mapColonne_.get(columnIndex).attribute.getLongName(); + return mapColonne_.get(columnIndex).attribute.getName(); else return null; } @@ -704,7 +711,7 @@ // Mise \xE0 jour de mapColonne \\ int idxColonne=3; GISAttributeInterface attrZ=zone_.getAttributeIsZ(); - // Cas particulier : attribut z atomique + // Cas particulier : attribut z atomique est lis en debut des attributs atomiques. if (attrZ!=null&&attrZ.isAtomicValue()) { int idxAttr=zone_.getIndiceOf(attrZ); mapColonne_.put(idxColonne++, new AttributeInformation(attrZ, (GISAttributeModel)zone_.getValue(idxAttr, idxSelected_), Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlVisuPanel.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -22,6 +22,7 @@ import org.fudaa.fudaa.commun.impl.FudaaCommonImplementation; import org.fudaa.fudaa.modeleur.action.CalqueDeleteCalqueAction; import org.fudaa.fudaa.modeleur.action.CalqueNewCalqueAction; +import org.fudaa.fudaa.modeleur.action.SceneShowLabelAction; import org.fudaa.fudaa.modeleur.layer.MdlLayer1dAxe; import org.fudaa.fudaa.modeleur.layer.MdlLayer1dBank; import org.fudaa.fudaa.modeleur.layer.MdlLayer1dLimiteStockage; @@ -93,10 +94,11 @@ protected EbliActionInterface[] getActionsInterface(){ EbliActionInterface[] actions=super.getActionsInterface(); - EbliActionInterface[] allActions=new EbliActionInterface[actions.length+1]; + EbliActionInterface[] allActions=new EbliActionInterface[actions.length+2]; for(int i=0;i<actions.length;i++) allActions[i]=actions[i]; - allActions[allActions.length-1]=new SceneShowOrientationAction(gisEditor_.getPanel().getArbreCalqueModel()); + allActions[allActions.length-2]=new SceneShowOrientationAction(gisEditor_.getPanel().getArbreCalqueModel()); + allActions[allActions.length-1]=new SceneShowLabelAction(gisEditor_.getPanel().getArbreCalqueModel()); return allActions; } Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/SceneShowLabelAction.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/SceneShowLabelAction.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/SceneShowLabelAction.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -0,0 +1,85 @@ +/* + * @creation 14 nov. 2008 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.fudaa.modeleur.action; + +import javax.swing.event.TreeModelEvent; +import javax.swing.event.TreeModelListener; + +import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ebli.calque.BArbreCalqueModel; +import org.fudaa.ebli.calque.BCalque; +import org.fudaa.ebli.calque.BCalqueVisitor; +import org.fudaa.ebli.calque.ZCalqueLigneBrisee; +import org.fudaa.ebli.calque.ZCalqueMultiPoint; +import org.fudaa.ebli.commun.EbliActionChangeState; +import org.fudaa.ebli.commun.EbliLib; + +import com.memoire.bu.BuResource; + +/** + * Une action pour afficher les labels dans les calques. + * @author Bertrand Marchand + * @version $Id$ + */ +public class SceneShowLabelAction extends EbliActionChangeState implements TreeModelListener { + + protected BArbreCalqueModel treeModel_; + + public SceneShowLabelAction(BArbreCalqueModel _treeModel) { + super(EbliLib.getS("Afficher les labels sur les sommets"), null, "SHOW_LABELS"); + treeModel_=_treeModel; + treeModel_.addTreeModelListener(this); + setEnabled(true); + setSelected(true); + } + + private void applyConf(){ + treeModel_.getRootCalque().apply(new BCalqueVisitor(){ + public boolean visit(BCalque _cq) { + if(_cq instanceof ZCalqueLigneBrisee) + ((ZCalqueLigneBrisee)_cq).setAttributForLabels(isSelected()?GISAttributeConstants.LABEL:null); + else if(_cq instanceof ZCalqueMultiPoint) + ((ZCalqueMultiPoint)_cq).setAttributForLabels(isSelected()?GISAttributeConstants.LABEL:null); + return true; + } + }); + } + + /* (non-Javadoc) + * @see javax.swing.event.TreeModelListener#treeNodesChanged(javax.swing.event.TreeModelEvent) + */ + public void treeNodesChanged(TreeModelEvent e) { + } + + /* (non-Javadoc) + * @see javax.swing.event.TreeModelListener#treeNodesInserted(javax.swing.event.TreeModelEvent) + */ + public void treeNodesInserted(TreeModelEvent e) { + applyConf(); + } + + /* (non-Javadoc) + * @see javax.swing.event.TreeModelListener#treeNodesRemoved(javax.swing.event.TreeModelEvent) + */ + public void treeNodesRemoved(TreeModelEvent e) { + } + + /* (non-Javadoc) + * @see javax.swing.event.TreeModelListener#treeStructureChanged(javax.swing.event.TreeModelEvent) + */ + public void treeStructureChanged(TreeModelEvent e) { + } + + /* (non-Javadoc) + * @see org.fudaa.ebli.commun.EbliActionChangeState#changeAction() + */ + @Override + public void changeAction() { + applyConf(); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/SceneShowLabelAction.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dAxe.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dAxe.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dAxe.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -9,6 +9,7 @@ import java.awt.Color; +import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ebli.calque.BCalquePersistenceInterface; import org.fudaa.ebli.calque.dessin.DeForme; import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; @@ -36,6 +37,7 @@ setLineModelOuvert(getLineModel(0)); setName(getExtName()); setTitle(MdlResource.MDL.getString("Axes hydrauliques")); + setAttributForLabels(GISAttributeConstants.LABEL); } public MdlLayer1dAxe(FSigEditor _editor) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dTrace.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dTrace.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer1dTrace.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -9,6 +9,7 @@ import java.awt.Color; +import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ebli.calque.BCalquePersistenceInterface; import org.fudaa.ebli.calque.dessin.DeForme; import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; @@ -37,6 +38,7 @@ // _model.addListener(this); A implementer. setName(getExtName()); setTitle(MdlResource.MDL.getString("Trace profils")); + setAttributForLabels(GISAttributeConstants.LABEL); } public MdlLayer1dTrace(FSigEditor _editor) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dCloud.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dCloud.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dCloud.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.Arrays; +import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ebli.calque.BCalque; import org.fudaa.ebli.calque.BCalquePersistenceInterface; import org.fudaa.ebli.calque.BGroupeCalque; @@ -40,8 +41,8 @@ super(_model,_editor); setName(getExtName()); setIconModel(0, new TraceIconModel(TraceIcon.CARRE_PLEIN, 2, new Color(0,190,0))); - setTitle(MdlResource.MDL.getString("Semis de points")); + setAttributForLabels(GISAttributeConstants.BATHY); } public MdlLayer2dCloud(FSigEditor _editor) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dConstraintLine.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dConstraintLine.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dConstraintLine.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -9,6 +9,7 @@ import java.awt.Color; +import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ebli.calque.BCalquePersistenceInterface; import org.fudaa.ebli.calque.dessin.DeForme; import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; @@ -36,6 +37,7 @@ setLineModelOuvert(getLineModel(0)); setName(getExtName()); setTitle(MdlResource.MDL.getString("Lignes de contraintes")); + setAttributForLabels(GISAttributeConstants.BATHY); } public MdlLayer2dConstraintLine(FSigEditor _editor) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dContour.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dContour.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dContour.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -9,6 +9,7 @@ import java.awt.Color; +import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ebli.calque.BCalquePersistenceInterface; import org.fudaa.ebli.calque.dessin.DeForme; import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; @@ -40,6 +41,7 @@ setIconModel(1, new TraceIconModel(getIconModel(0))); setName(getExtName()); setTitle(MdlResource.MDL.getString("Contours d'\xE9tude")); + setAttributForLabels(GISAttributeConstants.BATHY); } public MdlLayer2dContour(FSigEditor _editor) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dDirectionLine.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dDirectionLine.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dDirectionLine.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -9,6 +9,7 @@ import java.awt.Color; +import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ebli.calque.BCalquePersistenceInterface; import org.fudaa.ebli.calque.dessin.DeForme; import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; @@ -37,6 +38,7 @@ // _model.addListener(this); A implementer. setName(getExtName()); setTitle(MdlResource.MDL.getString("Lignes directrices")); + setAttributForLabels(GISAttributeConstants.LABEL); } public MdlLayer2dDirectionLine(FSigEditor _editor) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dLevel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dLevel.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dLevel.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -9,6 +9,7 @@ import java.awt.Color; +import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ebli.calque.BCalquePersistenceInterface; import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; import org.fudaa.ebli.trace.TraceLigne; @@ -37,6 +38,7 @@ setLineModelOuvert(getLineModel(0)); setTitle(MdlResource.MDL.getString("Lignes de niveau")); + setAttributForLabels(GISAttributeConstants.BATHY); } public MdlLayer2dLevel(FSigEditor _editor) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dProfile.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dProfile.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dProfile.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.Arrays; +import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ebli.calque.BCalquePersistenceInterface; import org.fudaa.ebli.calque.dessin.DeForme; import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; @@ -43,6 +44,7 @@ // _model.addListener(this); A implementer. setName(getExtName()); setTitle(MdlResource.MDL.getString("Profils")); + setAttributForLabels(GISAttributeConstants.LABEL); } public MdlLayer2dProfile(FSigEditor _editor) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dZone.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dZone.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlLayer2dZone.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -9,6 +9,7 @@ import java.awt.Color; +import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ebli.calque.BCalquePersistenceInterface; import org.fudaa.ebli.calque.dessin.DeForme; import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; @@ -40,6 +41,7 @@ setIconModel(1, new TraceIconModel(getIconModel(0))); setName(getExtName()); setTitle(MdlResource.MDL.getString("Zones")); + setAttributForLabels(GISAttributeConstants.BATHY); } public MdlLayer2dZone(FSigEditor _editor) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dAxe.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dAxe.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dAxe.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -28,7 +28,8 @@ GISAttributeConstants.ETAT_GEOM, GISAttributeConstants.TITRE, GISAttributeConstants.NATURE, - GISAttributeConstants.VISIBILITE + GISAttributeConstants.VISIBILITE, + GISAttributeConstants.LABEL }; // Pas de container de commande pour cette op\xE9ration, sinon conserv\xE9 en undo/redo. getGeomData().setAttributes(attrs, null); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dTrace.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dTrace.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel1dTrace.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -30,7 +30,8 @@ GISAttributeConstants.TITRE, GISAttributeConstants.ETAT_GEOM, GISAttributeConstants.NATURE, - GISAttributeConstants.VISIBILITE + GISAttributeConstants.VISIBILITE, + GISAttributeConstants.LABEL }; // Pas de container de commande pour cette op\xE9ration, sinon conserv\xE9 en undo/redo. getGeomData().setAttributes(attrs, null); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dCloud.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dCloud.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dCloud.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -19,7 +19,7 @@ * @version $Id$ */ public class MdlModel2dCloud extends MdlModel2dMultiPoint { - + /** * Construction d'un modele de profil avec pile de commandes. * @param _cmd La pile de commandes pour le undo/redo. @@ -34,7 +34,8 @@ GISAttributeConstants.ETAT_GEOM, GISAttributeConstants.TITRE, GISAttributeConstants.NATURE, - GISAttributeConstants.VISIBILITE + GISAttributeConstants.VISIBILITE, + GISAttributeConstants.LABEL }; // Pas de container de commande pour cette op\xE9ration, sinon conserv\xE9 en undo/redo. getGeomData().setAttributes(attrs, null); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dConstraintLine.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dConstraintLine.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dConstraintLine.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -32,7 +32,8 @@ GISAttributeConstants.ETAT_GEOM, GISAttributeConstants.TITRE, GISAttributeConstants.NATURE, - GISAttributeConstants.VISIBILITE + GISAttributeConstants.VISIBILITE, + GISAttributeConstants.LABEL }; // Pas de container de commande pour cette op\xE9ration, sinon conserv\xE9 en undo/redo. getGeomData().setAttributes(attrs, null); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dContour.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dContour.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dContour.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -31,7 +31,8 @@ GISAttributeConstants.TITRE, GISAttributeConstants.ETAT_GEOM, GISAttributeConstants.NATURE, - GISAttributeConstants.VISIBILITE + GISAttributeConstants.VISIBILITE, + GISAttributeConstants.LABEL }; // Pas de container de commande pour cette op\xE9ration, sinon conserv\xE9 en undo/redo. getGeomData().setAttributes(attrs, null); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dDirectionLine.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dDirectionLine.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dDirectionLine.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -32,7 +32,8 @@ GISAttributeConstants.ETAT_GEOM, GISAttributeConstants.TITRE, GISAttributeConstants.NATURE, - GISAttributeConstants.VISIBILITE + GISAttributeConstants.VISIBILITE, + GISAttributeConstants.LABEL }; // Pas de container de commande pour cette op\xE9ration, sinon conserv\xE9 en undo/redo. getGeomData().setAttributes(attrs, null); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLevel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLevel.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLevel.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -35,7 +35,8 @@ GISAttributeConstants.ETAT_GEOM, GISAttributeConstants.TITRE, GISAttributeConstants.NATURE, - GISAttributeConstants.VISIBILITE + GISAttributeConstants.VISIBILITE, + GISAttributeConstants.LABEL }; // Pas de container de commande pour cette op\xE9ration, sinon conserv\xE9 en undo/redo. getGeomData().setAttributes(attrs, null); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dProfile.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dProfile.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dProfile.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -26,13 +26,15 @@ */ public MdlModel2dProfile(final ZModelGeometryListener _listener, final CtuluCommandContainer _cmd) { super(_listener); + GISAttribute[] attrs=new GISAttribute[]{ GISAttributeConstants.BATHY, GISAttributeConstants.ETAT_GEOM, GISAttributeConstants.TITRE, GISAttributeConstants.NATURE, GISAttributeConstants.COMMENTAIRE_HYDRO, - GISAttributeConstants.VISIBILITE + GISAttributeConstants.VISIBILITE, + GISAttributeConstants.LABEL }; // Pas de container de commande pour cette op\xE9ration, sinon conserv\xE9 en undo/redo. getGeomData().setAttributes(attrs, null); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dZone.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dZone.java 2009-02-09 18:36:49 UTC (rev 4449) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dZone.java 2009-02-10 09:33:45 UTC (rev 4450) @@ -31,7 +31,8 @@ GISAttributeConstants.TITRE, GISAttributeConstants.ETAT_GEOM, GISAttributeConstants.NATURE, - GISAttributeConstants.VISIBILITE + GISAttributeConstants.VISIBILITE, + GISAttributeConstants.LABEL }; // Pas de container de commande pour cette op\xE9ration, sinon conserv\xE9 en undo/redo. getGeomData().setAttributes(attrs, null); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2009-02-13 13:56:37
|
Revision: 4465 http://fudaa.svn.sourceforge.net/fudaa/?rev=4465&view=rev Author: emmanuel_martin Date: 2009-02-13 13:56:30 +0000 (Fri, 13 Feb 2009) Log Message: ----------- Modeleur 1d : lors de l'export un message indique le nombre de profil non export?\195?\169. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java 2009-02-13 13:45:11 UTC (rev 4464) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java 2009-02-13 13:56:30 UTC (rev 4465) @@ -24,6 +24,7 @@ import org.fudaa.ctulu.gis.GISPoint; import org.fudaa.ctulu.gis.GISPolyligne; import org.fudaa.ctulu.gis.GISZoneCollection; +import org.fudaa.dodico.commun.DodicoLib; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateSequence; @@ -174,15 +175,21 @@ // Recherche des profils \\ List<GISZoneCollection> profils=new ArrayList<GISZoneCollection>(); List<Integer> indexProfils=new ArrayList<Integer>(); + int nbProfilNotKeep=0; for (int i=0; i<_zones.length; i++) { int idxAttNature=_zones[i].getIndiceOf(GISAttributeConstants.NATURE); if (idxAttNature!=-1) for (int j=0; j<_zones[i].getNbGeometries(); j++) - if (_zones[i].getValue(idxAttNature, j)==GISAttributeConstants.ATT_NATURE_PF&&_selectorProfil.exportProfil(_zones[i], i)) { - profils.add(_zones[i]); - indexProfils.add(j); + if (_zones[i].getValue(idxAttNature, j)==GISAttributeConstants.ATT_NATURE_PF) { + if(_selectorProfil.exportProfil(_zones[i], j)) { + profils.add(_zones[i]); + indexProfils.add(j); + } + else + nbProfilNotKeep++; } } + analyze_.addWarn(DodicoLib.getS(nbProfilNotKeep+" profils sur "+(indexProfils.size()+nbProfilNotKeep)+" non \xE9crit car non conformes."), -1); // G\xE9n\xE9ration des MascaretProfilAbstractRepresentations \\ profils_=new MascaretProfilAbstractRepresentation[profils.size()]; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java 2009-02-13 13:45:11 UTC (rev 4464) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java 2009-02-13 13:56:30 UTC (rev 4465) @@ -395,9 +395,12 @@ appli_.error(message); } if (result.containsMessages()) { - for (int i=0; i<result.getAnalyze().getInfos().length; i++) - message+=result.getAnalyze().getInfos()[i].getMessage()+'\n'; - + if(result.getAnalyze().containsInfos()) + for (int i=0; i<result.getAnalyze().getInfos().length; i++) + message+=result.getAnalyze().getInfos()[i].getMessage()+'\n'; + if(result.getAnalyze().containsWarnings()) + for (int i=0; i<result.getAnalyze().getWarnings().length; i++) + message+=result.getAnalyze().getWarnings()[i].getMessage()+'\n'; } if(result.containsFatalError()) appli_.error(FudaaLib.getS("Exportation"), message); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |