Commit 13558d05680818e03afc43dfb9adb8852137663f

Authored by Edmar Moretti
1 parent 902e11b6

--no commit message

Showing 1 changed file with 122 additions and 97 deletions   Show diff stats
ferramentas/editorol/editorol.js
@@ -215,6 +215,8 @@ i3GEO.editorOL = @@ -215,6 +215,8 @@ i3GEO.editorOL =
215 mapa : "", 215 mapa : "",
216 //ids das features graficas selecionadas 216 //ids das features graficas selecionadas
217 idsSelecionados : [], 217 idsSelecionados : [],
  218 + //backup das features
  219 + featuresBackup : [],
218 //utilizado pelo mashup 220 //utilizado pelo mashup
219 inicia : function() { 221 inicia : function() {
220 // ativabotoes e boolean 222 // ativabotoes e boolean
@@ -1304,59 +1306,100 @@ i3GEO.editorOL = @@ -1304,59 +1306,100 @@ i3GEO.editorOL =
1304 i3GEOpanelEditor.appendChild(temp); 1306 i3GEOpanelEditor.appendChild(temp);
1305 } 1307 }
1306 1308
1307 - i3GEOpanelEditor.style.width = i3GEOpanelEditor.getElementsByTagName("div").length * 33 + "px";  
1308 - i3GEO.editorOL.mapa.getViewport().getElementsByClassName("ol-overlaycontainer-stopevent")[0].appendChild(i3GEOpanelEditor);  
1309 -  
1310 - /*  
1311 -  
1312 - // botao de selecionar tudo  
1313 if (botoes.selecaotudo === true) { 1309 if (botoes.selecaotudo === true) {
1314 -  
1315 - button = new OpenLayers.Control.Button({  
1316 - displayClass : "editorOLselecaoTudo",  
1317 - trigger : function() {  
1318 - var fs = i3GEO.desenho.layergrafico.features, n = fs.length, i;  
1319 - for (i = 0; i < n; i++) {  
1320 - i3GEO.editorOL.selbutton.select(fs[i]);  
1321 - }  
1322 - },  
1323 - title : $trad("studo"),  
1324 - type : OpenLayers.Control.TYPE_BUTTON  
1325 - });  
1326 - controles.push(button);  
1327 - adiciona = true;  
1328 - 1310 + temp = document.createElement("div");
  1311 + temp.className = "editorOLselecaoTudoItemInactive olButton";
  1312 + temp.title = $trad("studo");
  1313 + temp.onclick = function(){
  1314 + i3GEO.editorOL.marcaBotao();
  1315 + i3GEO.editorOL.selTodos();
  1316 + };
  1317 + i3GEOpanelEditor.appendChild(temp);
1329 } 1318 }
  1319 +
1330 if (botoes.apaga === true) { 1320 if (botoes.apaga === true) {
1331 -  
1332 - button = new OpenLayers.Control.Button({  
1333 - displayClass : "editorOLapaga",  
1334 - trigger : function() {  
1335 - if (i3GEO.desenho.layergrafico.selectedFeatures.length > 0) {  
1336 - var x = window.confirm($trad("excsel") + "?");  
1337 - if (x) {  
1338 - i3GEO.editorOL.guardaBackup();  
1339 - i3GEO.desenho.layergrafico.removeFeatures(i3GEO.desenho.layergrafico.selectedFeatures);  
1340 - if (document.getElementById("panellistagEditor")) {  
1341 - i3GEO.editorOL.listaGeometrias();  
1342 - }  
1343 - if (typeof i3geoOL !== "undefined") {  
1344 - i3GEO.janela.tempoMsg($trad("meneditor1")); 1321 + temp = document.createElement("div");
  1322 + temp.className = "editorOLapagaItemInactive olButton";
  1323 + temp.title = $trad("excsel");
  1324 + temp.onclick = function(){
  1325 + var x, i, s, nsel = i3GEO.editorOL.idsSelecionados.length;
  1326 + i3GEO.editorOL.featuresBackup = [];
  1327 + i3GEO.editorOL.marcaBotao();
  1328 + if(nsel > 0){
  1329 + x = window.confirm($trad("excsel") + "?");
  1330 + if(x){
  1331 + s = i3GEO.desenho.layergrafico.getSource();
  1332 + for(i=0; i<nsel; i++){
  1333 + f = s.getFeatureById(i3GEO.editorOL.idsSelecionados[i]);
  1334 + if(f){
  1335 + i3GEO.editorOL.featuresBackup.push(f.clone());
  1336 + s.removeFeature(f);
1345 } 1337 }
1346 } 1338 }
1347 - } else {  
1348 - i3GEO.janela.tempoMsg($trad("seluma")); 1339 + s.changed();
  1340 + i3GEO.editorOL.idsSelecionados = [];
1349 } 1341 }
1350 - },  
1351 - title : $trad("excsel"),  
1352 - type : OpenLayers.Control.TYPE_BUTTON  
1353 - });  
1354 - controles.push(button);  
1355 - adiciona = true;  
1356 - 1342 + }
  1343 + else{
  1344 + i3GEO.janela.tempoMsg($trad("selum"));
  1345 + }
  1346 + };
  1347 + i3GEOpanelEditor.appendChild(temp);
  1348 + }
  1349 +
  1350 + if (botoes.frente === true) {
  1351 + temp = document.createElement("div");
  1352 + temp.className = "editorOLfrenteItemInactive olButton";
  1353 + temp.title = $trad("frente");
  1354 + temp.onclick = function(){
  1355 + var nsel = i3GEO.editorOL.idsSelecionados.length;
  1356 + if(nsel > 0){
  1357 + i3GEO.editorOL.marcaBotao();
  1358 + i3GEO.editorOL.trazParaFrente();
  1359 + }
  1360 + else{
  1361 + i3GEO.janela.tempoMsg($trad("selum"));
  1362 + }
  1363 + };
  1364 + i3GEOpanelEditor.appendChild(temp);
1357 } 1365 }
  1366 + //TODO Translate nao funciona nessa versao do openlayers 3x precisa atualizar
  1367 + if (botoes.edita === true) {
  1368 + i3GEO.eventos.cliquePerm.desativa();
  1369 + temp = document.createElement("div");
  1370 + temp.className = "editorOLeditaItemInactive olButton";
  1371 + temp.title = $trad("dpol");
  1372 + temp.onclick = function(){
  1373 + i3GEO.editorOL.featuresBackup = [];
  1374 + var draw, nsel, f, c;
  1375 + nsel = i3GEO.editorOL.idsSelecionados.length;
  1376 + if(nsel > 0){
  1377 + i3GEO.editorOL.marcaBotao("editorOLedita");
  1378 + f = i3GEO.desenho.layergrafico.getSource().getFeatureById(i3GEO.editorOL.idsSelecionados[nsel - 1]);
  1379 + i3GEO.editorOL.featuresBackup.push(f.clone());
  1380 + c = new ol.Collection();
  1381 + c.push(f);
  1382 + draw = new ol.interaction.Modify({
  1383 + features: c
  1384 + });
  1385 + //adiciona a interacao para poder ser removida
  1386 + i3GEO.editorOL.interacoes.push(draw);
  1387 + i3GEO.Interface.openlayers.interacoes[0].setActive(false);
  1388 + i3geoOL.addInteraction(draw);
  1389 + }
  1390 + else{
  1391 + i3GEO.janela.tempoMsg($trad("selum"));
  1392 + }
  1393 + };
  1394 + i3GEOpanelEditor.appendChild(temp);
  1395 + }
  1396 +
  1397 + i3GEOpanelEditor.style.width = i3GEOpanelEditor.getElementsByTagName("div").length * 33 + "px";
  1398 + i3GEO.editorOL.mapa.getViewport().getElementsByClassName("ol-overlaycontainer-stopevent")[0].appendChild(i3GEOpanelEditor);
  1399 +
  1400 + /*
  1401 +
1358 if (botoes.edita === true && botoes.corta === true && i3GEO.php) { 1402 if (botoes.edita === true && botoes.corta === true && i3GEO.php) {
1359 -  
1360 i3GEO.editorOL.CortaFeature = new OpenLayers.Control.DrawFeature(i3GEO.desenho.layergrafico, OpenLayers.Handler.Polygon, { 1403 i3GEO.editorOL.CortaFeature = new OpenLayers.Control.DrawFeature(i3GEO.desenho.layergrafico, OpenLayers.Handler.Polygon, {
1361 displayClass : "editorOLcorta", 1404 displayClass : "editorOLcorta",
1362 title : $trad("cortaf"), 1405 title : $trad("cortaf"),
@@ -1389,24 +1432,6 @@ i3GEO.editorOL = @@ -1389,24 +1432,6 @@ i3GEO.editorOL =
1389 adiciona = true; 1432 adiciona = true;
1390 1433
1391 } 1434 }
1392 - if (botoes.edita === true) {  
1393 -  
1394 - i3GEO.editorOL.ModifyFeature = new OpenLayers.Control.ModifyFeature(i3GEO.desenho.layergrafico, {  
1395 - displayClass : "editorOLedita",  
1396 - title : $trad("modf"),  
1397 - type : OpenLayers.Control.TYPE_TOOL,  
1398 - clickout : true,  
1399 - toggle : true,  
1400 - mode : OpenLayers.Control.ModifyFeature.RESHAPE,  
1401 - standalone : false,  
1402 - createVertices : true,  
1403 - styleMap : "default",  
1404 - vertexRenderIntent : "vertex"  
1405 - });  
1406 - controles.push(i3GEO.editorOL.ModifyFeature);  
1407 - adiciona = true;  
1408 -  
1409 - }  
1410 if (botoes.edita === true && botoes.listag === true) { 1435 if (botoes.edita === true && botoes.listag === true) {
1411 1436
1412 button = new OpenLayers.Control.Button({ 1437 button = new OpenLayers.Control.Button({
@@ -1421,23 +1446,6 @@ i3GEO.editorOL = @@ -1421,23 +1446,6 @@ i3GEO.editorOL =
1421 adiciona = true; 1446 adiciona = true;
1422 1447
1423 } 1448 }
1424 - if (botoes.frente === true) {  
1425 -  
1426 - button = new OpenLayers.Control.Button({  
1427 - displayClass : "editorOLfrente",  
1428 - trigger : function() {  
1429 - i3GEO.editorOL.trazParaFrente();  
1430 - if (document.getElementById("panellistagEditor")) {  
1431 - i3GEO.editorOL.listaGeometrias();  
1432 - }  
1433 - },  
1434 - title : $trad("frente"),  
1435 - type : OpenLayers.Control.TYPE_BUTTON  
1436 - });  
1437 - controles.push(button);  
1438 - adiciona = true;  
1439 -  
1440 - }  
1441 if (botoes.tools === true && i3GEO.php) { 1449 if (botoes.tools === true && i3GEO.php) {
1442 1450
1443 button = new OpenLayers.Control.Button({ 1451 button = new OpenLayers.Control.Button({
@@ -1458,9 +1466,6 @@ i3GEO.editorOL = @@ -1458,9 +1466,6 @@ i3GEO.editorOL =
1458 adiciona = true; 1466 adiciona = true;
1459 1467
1460 } 1468 }
1461 - // botao de sele&ccedil;&atilde;o  
1462 -  
1463 - // n&atilde;o dispon&iacute;vel ainda  
1464 if (botoes.propriedades === true) { 1469 if (botoes.propriedades === true) {
1465 1470
1466 button = new OpenLayers.Control.Button({ 1471 button = new OpenLayers.Control.Button({
@@ -2172,6 +2177,28 @@ i3GEO.editorOL = @@ -2172,6 +2177,28 @@ i3GEO.editorOL =
2172 // {i3GEO.editorOL.backup.removeFeatures(i3GEO.editorOL.backup.features);} 2177 // {i3GEO.editorOL.backup.removeFeatures(i3GEO.editorOL.backup.features);}
2173 // i3GEO.editorOL.backup.addFeatures(i3GEO.desenho.layergrafico.features); 2178 // i3GEO.editorOL.backup.addFeatures(i3GEO.desenho.layergrafico.features);
2174 }, 2179 },
  2180 + selTodos : function() {
  2181 + i3GEO.editorOL.unselTodos();
  2182 + var features, n, f, i, id;
  2183 + features = i3GEO.desenho.layergrafico.getSource().getFeatures();
  2184 + n = features.length;
  2185 + for (i = 0; i < n; i++) {
  2186 + f = features[i];
  2187 + id = f.getId();
  2188 + if(!id){
  2189 + id = i3GEO.util.uid();
  2190 + f.setId(id);
  2191 + }
  2192 + i3GEO.editorOL.idsSelecionados.push(id);
  2193 + f.setProperties({
  2194 + fillColor: f.getStyle().getFill().getColor(),
  2195 + strokeColor: f.getStyle().getStroke().getColor()
  2196 + });
  2197 + f.getStyle().getFill().setColor('rgba(255, 255, 255, 0.5)');
  2198 + f.getStyle().getStroke().setColor('blue');
  2199 + }
  2200 + i3GEO.desenho.layergrafico.getSource().changed();
  2201 + },
2175 unselTodos : function() { 2202 unselTodos : function() {
2176 var i, n, f, s; 2203 var i, n, f, s;
2177 s = i3GEO.desenho.layergrafico.getSource(); 2204 s = i3GEO.desenho.layergrafico.getSource();
@@ -2298,22 +2325,20 @@ i3GEO.editorOL = @@ -2298,22 +2325,20 @@ i3GEO.editorOL =
2298 } 2325 }
2299 }, 2326 },
2300 trazParaFrente : function() { 2327 trazParaFrente : function() {
2301 - var features = i3GEO.desenho.layergrafico.selectedFeatures;  
2302 - if (features.length > 0) {  
2303 - i3GEO.editorOL.backup = new OpenLayers.Layer.Vector("Backup", {  
2304 - displayInLayerSwitcher : false,  
2305 - visibility : false  
2306 - });  
2307 - i3GEO.editorOL.backup.addFeatures(features);  
2308 - i3GEO.editorOL.unselTodosBackup();  
2309 - i3GEO.desenho.layergrafico.removeFeatures(features);  
2310 - i3GEO.desenho.layergrafico.addFeatures(i3GEO.editorOL.backup.features);  
2311 - if (document.getElementById("panellistagEditor")) {  
2312 - i3GEO.editorOL.listaGeometrias(); 2328 + var s, i, nsel, id, clone;
  2329 + s = i3GEO.desenho.layergrafico.getSource();
  2330 + nsel = i3GEO.editorOL.idsSelecionados.length;
  2331 + for(i=0; i<nsel; i++){
  2332 + f = s.getFeatureById(i3GEO.editorOL.idsSelecionados[i]);
  2333 + if(f){
  2334 + clone = f.clone();
  2335 + id = f.getId();
  2336 + s.removeFeature(f);
  2337 + clone.setId(id);
  2338 + s.addFeature(clone);
2313 } 2339 }
2314 - } else {  
2315 - i3GEO.janela.tempoMsg("Selecione pelo menos um elemento");  
2316 } 2340 }
  2341 + s.changed();
2317 }, 2342 },
2318 pegaControle : function(classe) { 2343 pegaControle : function(classe) {
2319 var n = i3GEO.editorOL.controles.length, i; 2344 var n = i3GEO.editorOL.controles.length, i;