370 lines
14 KiB
Plaintext
370 lines
14 KiB
Plaintext
<%@language = "javascript" %>
|
|
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: ins_change.asp
|
|
Description: Wijzig een ins_deel of prj_deel. We onderscheiden
|
|
INS_DEEL gewone ins-delen
|
|
INS_DEEL gekoppeld aan werkplekken
|
|
PRJ_DEEL project ins-delen
|
|
PRJ_DEEL gekoppeld aan prj-werkplekken
|
|
Parameters: deel_key: te wijzigen ins_deel
|
|
wpdeel (optioneel): is het een werkplek gebonden deel?
|
|
floor: op welke verdieping staat hij (of locatie_key)
|
|
Rot
|
|
DeltaRot
|
|
Scale
|
|
clearXY
|
|
autoAlign
|
|
delete
|
|
NewX, NewY, orgX, orgY
|
|
Context: default.asp/Ajax.Updater
|
|
Result: JSON object
|
|
Note: - een nieuwe locatie (XY) (Eventueel wordt hij ook in een andere ALG_RUIMTE geplaatst.)
|
|
- Wissen locatie (XY)
|
|
- Rotatie vaste hoek
|
|
- Rotatie/ snappen op muur
|
|
- Schaal
|
|
*/
|
|
var JSON_Result = true;
|
|
%>
|
|
|
|
<!-- #include file="../Shared/common.inc" -->
|
|
<!-- #include file="../SlnkDWF/SLNK2IMG.inc" -->
|
|
<!-- #include file="../INS/ins.inc"-->
|
|
<!-- #include file="FGII.inc" -->
|
|
<!-- #include file="symbols.inc" -->
|
|
<!-- #include file="../Shared/save2db.inc" -->
|
|
|
|
<%
|
|
protectRequest.validateToken();
|
|
var deel_key = getQParamInt("deel_key");
|
|
var scenario_key = getQParamInt("scenario_key"); // current scenario.
|
|
var wpdeel = getQParamInt("wpdeel", 0);
|
|
|
|
var autfunction_arr = [];
|
|
if (scenario_key == 0)
|
|
{
|
|
var this_ins = ins.func_enabled_deel(deel_key);
|
|
for (var func_code in this_ins._funcodes)
|
|
{
|
|
autfunction_arr.push(func_code);
|
|
}
|
|
}
|
|
else
|
|
autfunction_arr.push("WEB_PRJBOF");
|
|
|
|
var authparams = user.checkAutorisation(autfunction_arr);
|
|
|
|
if (wpdeel) // Het symbool is getekend relatief aan de werkplek. Voor veel
|
|
{ // situaties hebben we die info nodig dus haal die maar vast op
|
|
if (scenario_key == 0)
|
|
var sql = "SELECT prs_werkplek_dwgx dwgx, prs_werkplek_dwgy dwgy,"
|
|
+ " prs_werkplek_dwgrotatie rot, prs_werkplek_dwgschaal scl"
|
|
+ " FROM ins_deel id, prs_werkplek pw"
|
|
+ " WHERE id.ins_alg_ruimte_key = pw.prs_werkplek_key"
|
|
+ " AND id.ins_deel_key = " + deel_key
|
|
else
|
|
var sql = "SELECT prj_werkplek_dwgx dwgx, prj_werkplek_dwgy dwgy,"
|
|
+ " prj_werkplek_dwgrotatie rot, prj_werkplek_dwgschaal scl"
|
|
+ " FROM prj_deel id, prj_werkplek pw"
|
|
+ " WHERE id.prj_werkplek_key = pw.prj_werkplek_key"
|
|
+ " AND id.prj_deel_key = " + deel_key
|
|
var oRs = Oracle.Execute(sql);
|
|
var wpX = oRs("dwgX").value;
|
|
var wpY = oRs("dwgY").value;
|
|
var wpRot = oRs("rot").value;
|
|
var wpScale = oRs("scl").value;
|
|
oRs.Close();
|
|
if (wpX == null)
|
|
{
|
|
Response.Write(JSON.stringify({ success: false, message: L("lcl_fg_place_wp_first") }));
|
|
Response.End;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
wpX = 0;wpY = 0;wpRot = 0;wpScale = 1.0;
|
|
}
|
|
dwRot = -wpRot * 3.1415926 / 180;
|
|
|
|
var vKey = getQParamInt("floor");
|
|
|
|
if (!canWriteInsDeel(deel_key, vKey, scenario_key))
|
|
{
|
|
Response.Write(JSON.stringify({ success: false, message: L("lcl_fg_obj_noedit") }));
|
|
Response.End;
|
|
}
|
|
|
|
var pContmode = getQParam("contmode", "");
|
|
function myMiniContourProcessor(cHandle)
|
|
{
|
|
var pDiscs_arr = getQParamIntArray("discs", []);
|
|
cHandle.SetFilterLayers(myFilterLayer(pDiscs_arr));
|
|
}
|
|
|
|
var sql = null; // Hierin gaan we het updatestatement bouwen.
|
|
|
|
var tracktekst = null;
|
|
if (getQParamInt("clearXY", 0) == 1)
|
|
{ // Geen nieuwe positie, XY wissen
|
|
if (scenario_key == 0)
|
|
{
|
|
sql = "UPDATE INS_DEEL"
|
|
+ " SET ins_deel_dwgx = NULL,"
|
|
+ " ins_deel_dwgy = NULL,"
|
|
+ " ins_deel_dwgz = NULL,"
|
|
+ " ins_deel_dwgrotatie = 0,"
|
|
+ " ins_deel_dwgschaal = 1.0"
|
|
+ " WHERE ins_deel_key = " + deel_key
|
|
tracktekst = L("lcl_ins_cad_cleared");
|
|
}
|
|
else
|
|
{
|
|
sql = "UPDATE PRJ_DEEL"
|
|
+ " SET prj_deel_dwgx = NULL,"
|
|
+ " prj_deel_dwgy = NULL,"
|
|
+ " prj_deel_dwgrotatie = 0,"
|
|
+ " prj_deel_dwgschaal = 1.0"
|
|
+ " WHERE prj_deel_key = " + deel_key
|
|
}
|
|
}
|
|
else if (getQParamInt("delete", 0) == 1)
|
|
{ // Symbool wissen
|
|
if (scenario_key == 0)
|
|
{
|
|
sql = "UPDATE INS_DEEL"
|
|
+ " SET ins_deel_verwijder=SYSDATE"
|
|
+ " WHERE ins_deel_key = " + deel_key;
|
|
}
|
|
else
|
|
{ // Objecten binnen het project aangemaakt verwijderen we echt.
|
|
Oracle.Execute("DELETE FROM prj_deel WHERE ins_deel_key IS NULL AND prj_deel_key = " + deel_key);
|
|
sql = "UPDATE PRJ_DEEL"
|
|
+ " SET prj_deel_verwijder = SYSDATE"
|
|
+ " WHERE prj_deel_key = " + deel_key;
|
|
}
|
|
}
|
|
else if (Request.QueryString("newX").Count > 0)
|
|
{
|
|
var newX = getQParamFloat("newX");
|
|
var newY = getQParamFloat("newY");
|
|
var orgX = getQParamFloat("orgX");
|
|
var orgY = getQParamFloat("orgY");
|
|
var lblContour = getQParam("Contour", ""); // R:12345
|
|
var vKey = getQParamInt("floor");
|
|
|
|
var ruimte_key = -1;
|
|
if (lblContour.match(/^R:/))
|
|
ruimte_key = lblContour.substr(2);
|
|
|
|
// Eventueel correctie voor werkplekgebonden.
|
|
var inswpX = (Math.cos(dwRot) * (newX - orgX) - Math.sin(dwRot) * (newY - orgY)) / wpScale;
|
|
var inswpY = (Math.cos(dwRot) * (newY - orgY) + Math.sin(dwRot) * (newX - orgX)) / wpScale;
|
|
if (wpdeel)
|
|
{
|
|
newX = inswpX;
|
|
newY = inswpY;
|
|
}
|
|
// Als XY nog niet was ingevuld nemen we newX, newY
|
|
// Anders nemen we 'verplaatsing' wat nauwkeuriger is
|
|
var sql = "SELECT " + (scenario_key == 0 ? "ins_alg" : "prj") + "_ruimte_key alg_ruimte_key"
|
|
+ " , " + (scenario_key == 0 ? "ins" : "prj") + "_deel_dwgx deel_dwgx"
|
|
+ " , " + (scenario_key == 0 ? "ins" : "prj") + "_deel_dwgy deel_dwgy"
|
|
+ " , " + (scenario_key == 0 ? "ins" : "prj") + "_deel_dwgrotatie deel_rot"
|
|
+ " FROM " + (scenario_key == 0 ? "ins" : "prj") + "_deel"
|
|
+ " WHERE " + (scenario_key == 0 ? "ins" : "prj") + "_deel_key = " + deel_key;
|
|
var oRs = Oracle.Execute(sql);
|
|
var old_ruimte_key = oRs("alg_ruimte_key").Value;
|
|
var dwgX = (oRs("deel_dwgx").Value ? oRs("deel_dwgx").Value + inswpX: newX);
|
|
var dwgY = (oRs("deel_dwgy").Value ? oRs("deel_dwgy").Value + inswpY: newY);
|
|
var dwgR = oRs("deel_rot").Value || 0;
|
|
oRs.Close();
|
|
|
|
if (S("cad_symbols_snap") >= 1 && inArray(dwgR, [0,90,180,270]))
|
|
{
|
|
dwgX = Math.round(dwgX / S("cad_symbols_snap")) * S("cad_symbols_snap");
|
|
dwgY = Math.round(dwgY / S("cad_symbols_snap")) * S("cad_symbols_snap");
|
|
newX = Math.round(newX / S("cad_symbols_snap")) * S("cad_symbols_snap");
|
|
newY = Math.round(newY / S("cad_symbols_snap")) * S("cad_symbols_snap");
|
|
}
|
|
|
|
if (scenario_key == 0)
|
|
{
|
|
sql = "UPDATE INS_DEEL"
|
|
+ " SET ins_deel_dwgx = " + dwgX
|
|
+ " , ins_deel_dwgy = " + dwgY
|
|
+ " , ins_deel_dwgz = "
|
|
+ " COALESCE(ins_deel_dwgz, (SELECT alg_verdieping_dwgz FROM alg_verdieping WHERE alg_verdieping_key = " + vKey + "))" // Vul de verdieping z-coordinaat in indien leeg
|
|
+ " , ins_deel_dwgrotatie = COALESCE(ins_deel_dwgrotatie, 0)"
|
|
+ " , ins_deel_dwgschaal = COALESCE(ins_deel_dwgschaal, 1.0)"
|
|
tracktekst = L("lcl_ins_cad_moved");
|
|
|
|
if (ruimte_key > 0 && !wpdeel)
|
|
{
|
|
sql += " ,ins_alg_ruimte_key = " + ruimte_key
|
|
|
|
var newtxt = ins.getBindingItemString("R", ruimte_key, null);
|
|
var oldtxt = ins.getBindingItemString("R", old_ruimte_key, null); // parent_key kan niet gewijzigd worden.
|
|
if (oldtxt != newtxt)
|
|
tracktekst = L("lcl_ins_cad_moved") + ": " + buildTrackText("varchar", oldtxt, newtxt, { nodiff: true });
|
|
}
|
|
sql += " WHERE ins_deel_key = " + deel_key
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
sql = "UPDATE PRJ_DEEL"
|
|
+ " SET prj_deel_dwgx = coalesce(" + dwgX + ", " + newX + ")"
|
|
+ " , prj_deel_dwgy = coalesce(" + dwgY + ", " + newY + ")"
|
|
+ " , prj_deel_dwgrotatie = coalesce(prj_deel_dwgrotatie, 0)"
|
|
+ " , prj_deel_dwgschaal = coalesce(prj_deel_dwgschaal, 1.0)"
|
|
if (ruimte_key > 0 && !wpdeel)
|
|
sql += " ,prj_ruimte_key = " + ruimte_key
|
|
sql += " WHERE prj_deel_key = " + deel_key
|
|
}
|
|
}
|
|
else if (Request.QueryString("DeltaRot").Count > 0)
|
|
{ // Rechtsom of linksom
|
|
var angle = getQParamFloat("DeltaRot");
|
|
if (angle == 0)
|
|
{
|
|
if (scenario_key == 0)
|
|
var sql = "UPDATE INS_DEEL"
|
|
+ " SET ins_deel_dwgrotatie = " + angle
|
|
+ " WHERE ins_deel_key = " + deel_key
|
|
else
|
|
var sql = "UPDATE PRJ_DEEL"
|
|
+ " SET prj_deel_dwgrotatie = " + angle
|
|
+ " WHERE prj_deel_key = " + deel_key
|
|
}
|
|
else
|
|
{
|
|
if (scenario_key == 0)
|
|
var sql = "UPDATE INS_DEEL"
|
|
+ " SET ins_deel_dwgrotatie = mod(coalesce(ins_deel_dwgrotatie + " + angle + ", " + angle + ")+360, 360)"
|
|
+ " WHERE ins_deel_key = " + deel_key
|
|
else
|
|
var sql = "UPDATE PRJ_DEEL"
|
|
+ " SET prj_deel_dwgrotatie = mod(coalesce(prj_deel_dwgrotatie + " + angle + ", " + angle + ")+360, 360)"
|
|
+ " WHERE prj_deel_key = " + deel_key
|
|
}
|
|
}
|
|
else if (Request.QueryString("Rot").Count > 0)
|
|
{ // Gespecificeerde rotatie
|
|
var angle = getQParamFloat("rot");
|
|
if (scenario_key == 0)
|
|
var sql = "UPDATE ins_deel"
|
|
+ " SET ins_deel_dwgrotatie = " + angle
|
|
+ " WHERE ins_deel_key = " + deel_key;
|
|
else
|
|
var sql = "UPDATE prj_deel"
|
|
+ " SET prj_deel_dwgrotatie = " + angle
|
|
+ " WHERE prj_deel_key = " + deel_key;
|
|
}
|
|
else if (getQParamInt("AutoAlign", 0) == 1)
|
|
{
|
|
inoutMode = getQParamInt("mode" , MODE_IN);
|
|
pvKey = getQParamInt("vKey" , -1);
|
|
dwfPath = SetVerdPlanDWF(pvKey, inoutMode, scenario_key);
|
|
if (dwfPath)
|
|
{ // Als we ook op symbolen (hun contour!) zouden willen snappen
|
|
// moeten we myContourProcessor meegeven
|
|
var mySLNKDWF = new SLNKDWF({ dwfFile : dwfPath,
|
|
dwfProcessor : myMiniContourProcessor,
|
|
imgProcessor : null,
|
|
contourLayers: S("fg_contourlayers"),
|
|
labelLayers : S("fg_labellayers"),
|
|
maximize : S("fg_maximize"),
|
|
minArea : S("fg_contour_minArea"),
|
|
minmergedistance: S("fg_minmergedistance"),
|
|
flags : S("fg_slnkdwf_flags"),
|
|
tempFolder : shared.tempFolder()
|
|
});
|
|
|
|
//SlnkSetContourProcessor(new Function("x", ";"));
|
|
var SLNKEvent = mySLNKDWF.Find(); // Werkt op Querystring parameters findX en findY
|
|
// beter zou zijn DWF(!) coordinaten van INS_DEEL
|
|
|
|
if (SlnkEvent.ContourKey != "")
|
|
{
|
|
if (scenario_key == 0)
|
|
var sql = "SELECT ins_deel_dwgrotatie rot"
|
|
+ " FROM ins_deel"
|
|
+ " WHERE ins_deel_key = " + deel_key
|
|
else
|
|
var sql = "SELECT prj_deel_dwgrotatie rot"
|
|
+ " FROM prj_deel"
|
|
+ " WHERE prj_deel_key = " + deel_key
|
|
oRs = Oracle.Execute(sql);
|
|
if (!oRs.Eof)
|
|
{
|
|
var oldAngle = (wpRot + oRs("rot").value + 360) % 360;
|
|
// newangle wordt SLNKEvent.EdgeAngle, SLNKEvent.EdgeAngle+90, SLNKEvent.EdgeAngle+180
|
|
// of SLNKEvent.EdgeAngle+270, wat maar het dichtst bij oldAngle zit
|
|
var newAngle = SLNKEvent.EdgeAngle; // Eerste gok
|
|
var dist = Math.abs(oldAngle - newAngle);
|
|
__Log("oa: " + oldAngle + " na: " + newAngle + " d: " + dist);
|
|
for (var deg = 0; deg <= 360; deg += 90)
|
|
{
|
|
var dist2 = Math.min(Math.abs(oldAngle - (SLNKEvent.EdgeAngle + deg)),
|
|
Math.abs(oldAngle - (SLNKEvent.EdgeAngle + deg - 360)));
|
|
if (Math.abs(dist2) < dist)
|
|
{
|
|
dist = dist2;
|
|
newAngle = (SLNKEvent.EdgeAngle + deg + 360) % 360;
|
|
}
|
|
__Log(" na: " + newAngle + " d: " + dist);
|
|
}
|
|
newAngle=(newAngle - wpRot + 360) % 360
|
|
if (scenario_key == 0)
|
|
sql = "UPDATE INS_DEEL"
|
|
+ " SET ins_deel_dwgrotatie = " + newAngle
|
|
+ " WHERE ins_deel_key = " + deel_key
|
|
else
|
|
sql = "UPDATE PRJ_DEEL"
|
|
+ " SET prj_deel_dwgrotatie = " + newAngle
|
|
+ " WHERE prj_deel_key = " + deel_key
|
|
}
|
|
oRs.Close();
|
|
}
|
|
else
|
|
{ // Moet in ruimte
|
|
Response.Write(JSON.stringify({ success: false, message: L("lcl_fg_place_wp_in_room") }));
|
|
Response.End;
|
|
}
|
|
|
|
}
|
|
}
|
|
else if (Request.QueryString("Scale").Count > 0)
|
|
{
|
|
var scl = getQParamFloat("scale");
|
|
if (scenario_key == 0)
|
|
var sql = "UPDATE INS_DEEL"
|
|
+ " SET ins_deel_dwgschaal = " + scl
|
|
+ " WHERE ins_deel_key = " + deel_key
|
|
else
|
|
var sql = "UPDATE PRJ_DEEL"
|
|
+ " SET prj_deel_dwgschaal = " + scl
|
|
+ " WHERE prj_deel_key = " + deel_key
|
|
}
|
|
else
|
|
{
|
|
Response.Write(JSON.stringify({ success: false, message: "ins_change.asp: invalid parameter" }));
|
|
Response.End;
|
|
}
|
|
if (sql)
|
|
{
|
|
var err = Oracle.Execute(sql, true);
|
|
if (err.friendlyMsg)
|
|
abort_with_warning(err.friendlyMsg);
|
|
if (tracktekst)
|
|
shared.trackaction("INSUPD", deel_key, tracktekst);
|
|
}
|
|
|
|
Response.Write(JSON.stringify({ success: true }));
|
|
%>
|
|
<% ASPPAGE_END(); %>
|