1
13693261870
2024-04-03 412022ac7410aa48a675d08c9e0fa2f57e74dab7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<html>
    <head>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
        <title>Image Comparison Tool</title>
<script type="text/javascript" src="range.js"></script>
<script type="text/javascript" src="timer.js"></script>
<script type="text/javascript" src="slider.js"></script>     
 
<link type="text/css" rel="StyleSheet" href="slider.css" />  
<link rel="StyleSheet" href="../Style.css" type="text/css">
<style>
</style> 
    </head>
        <body leftmargin="0px" topmargin="0px" marginwidth="0" marginheight="0" style="border: 0px;overflow:hidden; background-color: #151515" id="Body"  class="hideUntillTranslated" onload="Init()" onunload="exitTool();">
        <table  cellpadding ="5" cellspacing = "0" border="0" width="100%" >
        <tr >
        <td>
            &nbsp;<span class="i18n s8w">Text_ModelName</span>
            &nbsp;<b><span id="modelNameID" class="s8w"></span></b>
        </td>
        </tr>
 
    </table>
 
    <table  cellpadding ="3" cellspacing = "0" border="0" width="100%"  >
        <tr>
                
            <td style="width:215px;" align="center">
                    <select id="Layer1Mode"  class="SelectDark"   style="width:210px; " onchange="SetLayerRenderMode(1,-1);">
                        <option class="i18n" value=0 selected="selected">Text_Texture</option>
                        <option class="i18n" value=32768 >Text_TextureWire</option>
                        <option class="i18n" value=3 >Text_Solid</option>
                        <option class="i18n" value=32771 >Text_SolidWire</option>
                        <option class="i18n" value=2 >Text_Xray</option>
                        <option class="i18n" value=-1 >Text_None</option>
                        
                    </select>
            </td>
            <td style="width:50px;" align="center">
                <img style="margin-left:5px;" src=".\images\swipeicon.png" alt="" />
            </td>
            <td style="width:215px;" align="center">
                <select id="Layer2Mode"  class="SelectDark"   style="width:210px; " onchange="SetLayerRenderMode(2,-1);">
                        <option class="i18n" value=0 >Text_Texture</option>
                        <option class="i18n" value=32768 >Text_TextureWire</option>
                        <option class="i18n" value=3 >Text_Solid</option>
                        <option class="i18n" value=32771 >Text_SolidWire</option>
                        <option class="i18n" value=2 selected="selected">Text_Xray</option>
                        <option class="i18n" value=-1 >Text_None</option>
                    </select>
            </td>  
    </tr>
    <tr style="height: 10px;"><td></td></tr>
     </table>
                                
    <table  cellpadding ="3" cellspacing = "0" border="0" width="100%" >
    <tr >
        <td style=" width:80px;" align="center"><button id="DirectionID" style="width: 100%;" class="MenuButtonSmallWhite MenuButtonLast" onclick="ChangeDirection();" ><span class="i18n">Text_UpDown</span></button></td>
        <td style=" width:300px;" align="left">
            <div id="SliderID">
                <span id="gSliderClip" style="display:inline-block; width: 300px;"><input type="text" id="gSliderClipID" /></span></td>
            </div>
        <td style="width:35px;" align="left"> <span id="clipSpan"  class="s8w">100%</span></td>
        <td  style="width:35px;" align="center"  class="SectionText"  onclick="autoPlay(true);" style="cursor:pointer;"><img id="clipIcon" src="Images/autoOff.png" alt="" align="absmiddle"/> </td>
    </tr>
    </table>
    
 
<script src="../jquery/jquery-1.10.2.js"  type="text/javascript"></script>
<script language="javascript" src="../ToolsCommon71.js"></script>
<script language="jscript">
 
var SGWorld = new ActiveXObject("TerraExplorerX.SGWorld71");
 
var gDebug = false;
var gLayer1ID;
var gLayer2ID;
var gLayer1Obj;
var gLayer2Obj;
var gLayer1Visibility = true;
var gLayer1RenderMode;
var gStartSwipe = false;
var gLastLevel = 100;
var gAutoOnOff = false;
var gCliptimeout;
var gClipUpdatetimeout;
var gClipPosition;
var gSliderClip;
var gSwipeDirection=1;
var gDirection = 1;
var gCameraPos;
 
//--------------
//  Init
function Init() {
    //debugger
   try {
        gLayer1ID  = GetParamValue("ID", "");
        if (gLayer1ID=="")
        {
            gLayer1ID = SGWorld.ProjectTree.GetNextItem (SGWorld.ProjectTree.RootID,10); 
            gLayer1Obj = SGWorld.Creator.GetObject(gLayer1ID);
            if (gLayer1Obj.ObjectType == 39){ // feature layer under 3DML - get the parent 3DML
                gLayer1ID = SGWorld.ProjectTree.GetNextItem (gLayer1ID,15);
                gLayer1Obj = SGWorld.Creator.GetObject(gLayer1ID);
            }
            if (gLayer1Obj.ObjectType != 38){
                TEAlert (SGLang.i18n("Text_AlertCaption"), SGLang.i18n("Text_BIMNotFound"));
                return;
            }
        }
        $("#modelNameID").text(SGWorld.ProjectTree.GetItemName(gLayer1ID));
        gLayer1Obj= SGWorld.Creator.GetObject(gLayer1ID);
    }
   catch (e) {  TEAlert (SGLang.i18n("Text_AlertCaption"),SGLang.i18n("Text_BIMNotFound") ); exitTool();return;}
 
        try {
 
        // Create temporary layer
        var Path = gLayer1Obj.Path;
        var questionmark = Path.indexOf("?");
        if (checkUrl(Path))
            gLayer2Obj=SGWorld.Creator.CreateMeshLayerFromSGS(Path.substring(0,questionmark),Path.substring(questionmark+7,Path.length),SGWorld.ProjectTree.HiddenGroupID);
        else
            gLayer2Obj=SGWorld.Creator.CreateMeshLayerFromFile(Path,SGWorld.ProjectTree.HiddenGroupID);
 
        gLayer2ID = gLayer2Obj.ID;
        gLayer2Obj.Position = gLayer1Obj.Position.Copy();
        gLayer2Obj.Position.Pitch = 0; // This is to overcome a TE bug
        gLayer2Obj.ScaleX = gLayer1Obj.ScaleX;
        gLayer2Obj.ScaleX = gLayer1Obj.ScaleX;
        gLayer2Obj.ScaleY = gLayer1Obj.ScaleY;
        gLayer2Obj.ScaleZ = gLayer1Obj.ScaleZ;
        //gLayer2Obj.SaveInFlyFile = 0;
 
        
        SetLayerRenderMode(1,-1);
        SetLayerRenderMode(2,-1);
 
        SGWorld.AttachEvent("OnProjectTreeAction", OnProjectTreeAction);
 
   }
   catch (e) {  TEAlert (SGLang.i18n("Text_AlertCaption"),SGLang.i18n("Text_BIMNotFound") + e.message); return;}
 
   StartSwipe();
}
 
//--------------
//  checkUrl
function ChangeDirection(){
    if (gDirection==1){
        gDirection=0;
        $("#DirectionID").text(SGLang.i18n("Text_Sides"));
    }
    else {
 
        gDirection=1;
        $("#DirectionID").text(SGLang.i18n("Text_UpDown"));
    }
    SetClipTrans(gSliderClip.getValue(), true);
 
}
//--------------
//  checkUrl
function checkUrl(s) {
     var regexp = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/
     return regexp.test(s); 
}
//--------------
//  StartSwipe
function StartSwipe(){
    try {
 
        gStartSwipe = true;
        gLayer1Visibility = SGWorld.ProjectTree.GetVisibility (gLayer1ID);
        gLayer1RenderMode = gLayer1Obj.DisplayStyle;
        SetLayerRenderMode (1,gLayer1RenderMode);
        gCameraPos = SGWorld.Navigate.GetPosition ();
        SGWorld.ProjectTree.SetVisibility (gLayer1ID,true);
        SGWorld.ProjectTree.SetVisibility (gLayer2ID,true);
        setTimeout ("relocateCamera();",100);  // We need it to overcomae a problem of camera "jump" when we turn on layers
 
        SGWorld.Analysis.SetCompareGroup(gLayer1ID, 1);
        SGWorld.Analysis.SetCompareGroup(gLayer2ID, 2);
 
        gSliderClip = new Slider(document.getElementById("gSliderClip"), document.getElementById("gSliderClipID"));
        gSliderClip.setValue(50);
        gSliderClip.setMinimum(0);
        gSliderClip.setMaximum(99);
        gSliderClip.onchange = function () {
            SetClipTrans(gSliderClip.getValue(), false);
        };
        SetClipTrans(gSliderClip.getValue(), true);
        SGWorld.SetParam(450, 1);
        
    }
        catch (e) { if (gDebug) alert(SGLang.i18n("Text_MeshError") + e.message); }
}
 
//--------------
// relocateCamera
// We need it to overcomae a problem of camera "jump" when we turn on layers
function relocateCamera() {
    SGWorld.Navigate.SetPosition (gCameraPos);
}
 
//--------------
// 
function SetClipTrans(level, force) {
    if (level == gLastLevel && force == false )
        return;
    gLastLevel = level;
 
    // Clipping
    try {
        document.getElementById("clipSpan").innerHTML = level + "%";
        
        var vertices = [];
 
        switch (gDirection){
        case 0:  // Sides
            var boxWidth = Math.max(500, SGWorld.Navigate.GetPosition(0).Altitude*20); //  1000;//LeftPos.DistanceTo(RightPos)*10;
            var Pos = SGWorld.Window.PixelToWorld(SGWorld.Window.Rect.Width* (level) / 100.0, (SGWorld.Window.Rect.Height)-10, 0).Position;
            var Pos1 = SGWorld.Window.PixelToWorld(SGWorld.Window.Rect.Width* (level) / 100.0, (SGWorld.Window.Rect.Height)-50, 0).Position;
            var boxYaw = Pos.AimTo(Pos1).Yaw;
            Pos = Pos.Move (boxWidth,boxYaw ,0);
            Pos = Pos.Move (boxWidth/4,0,-90);
            vertices[0] = Pos;
            Pos = Pos.Move(boxWidth, boxYaw+90 , 0);
            vertices[1] = Pos;
            Pos = Pos.Move(boxWidth*2, boxYaw + 180, 0);
            vertices[2] = Pos;
            Pos = Pos.Move(boxWidth, boxYaw+270, 0);
            vertices[3] = Pos;
            vertices[4] = vertices[0].Move(boxWidth, 0, 90);
            vertices[5] = vertices[1].Move(boxWidth, 0, 90);
            vertices[6] = vertices[2].Move(boxWidth, 0, 90);
            vertices[7] = vertices[3].Move(boxWidth, 0, 90);
            break;
 
            case 1:   // Up-Down
            var MinX = gLayer1Obj.BBox.MinX;
            var MinY = gLayer1Obj.BBox.MinY;
            var MaxX = gLayer1Obj.BBox.MaxX;
            var MaxY = gLayer1Obj.BBox.MaxY;
            var MinHeight = gLayer1Obj.BBox.MinHeight + (gLayer1Obj.BBox.MaxHeight-gLayer1Obj.BBox.MinHeight)* (level / 100.0)*1.05;
            var MaxHeight = gLayer1Obj.BBox.MaxHeight*1.05;
         
            vertices[0] = SGWorld.Creator.CreatePosition(MinX,MinY,MinHeight,3,0,0,0,1);
            vertices[1] = SGWorld.Creator.CreatePosition(MinX,MaxY,MinHeight,3,0,0,0,1);
            vertices[2] = SGWorld.Creator.CreatePosition(MaxX,MaxY,MinHeight,3,0,0,0,1);
            vertices[3] = SGWorld.Creator.CreatePosition(MaxX,MinY,MinHeight,3,0,0,0,1);
            vertices[4] = SGWorld.Creator.CreatePosition(MinX,MinY,MaxHeight,3,0,0,0,1);
            vertices[5] = SGWorld.Creator.CreatePosition(MinX,MaxY,MaxHeight,3,0,0,0,1);
            vertices[6] = SGWorld.Creator.CreatePosition(MaxX,MaxY,MaxHeight,3,0,0,0,1);
            vertices[7] = SGWorld.Creator.CreatePosition(MaxX,MinY,MaxHeight,3,0,0,0,1);
            break;
 
            // case 3:   // depth
            // var boxWidth = Math.max(50, SGWorld.Navigate.GetPosition(0).Altitude)*10; //  1000;//LeftPos.DistanceTo(RightPos)*10;
            // var Pos = SGWorld.Window.PixelToWorld(5, (SGWorld.Window.Rect.Height)-5, 0).Position;
            // var boxYaw = SGWorld.Navigate.GetPosition(0).Yaw;
            
            // Pos = Pos.Move (boxWidth*level/ 100.0,boxYaw ,0);
            // Pos = Pos.Move (boxWidth/4,0,-90);
            // vertices[0] = Pos;
            // Pos = Pos.Move(boxWidth, boxYaw+90 , 0);
            // vertices[1] = Pos;
            // Pos = Pos.Move(boxWidth, boxYaw+180 , 0);
            // vertices[2] = Pos;
            // Pos = Pos.Move(boxWidth, boxYaw+270, 0);
            // vertices[3] = Pos;
            // vertices[4] = vertices[0].Move(boxWidth, 0, 90);
            // vertices[5] = vertices[1].Move(boxWidth, 0, 90);
            // vertices[6] = vertices[2].Move(boxWidth, 0, 90);
            // vertices[7] = vertices[3].Move(boxWidth, 0, 90);
            // break;
        }
        var BoxGeometry = SGWorld.Creator.GeometryCreator.CreateLineStringGeometry(vertices);
        SGWorld.Analysis.ShowCompareBox(BoxGeometry, false, "#ffffffff");
        //SGWorld.Creator.CreatePolyline (BoxGeometry,542346, 3);
 
        gClipPosition = SGWorld.Navigate.GetPosition();
        clearTimeout(gClipUpdatetimeout);
        gClipUpdatetimeout = setTimeout("checkClipUpdate()", 100);
    }
    catch (e) { if (gDebug) alert(SGLang.i18n("Text3") + e.message); }
}
//--------------
// 
function checkClipUpdate() {
    var currPosition = SGWorld.Navigate.GetPosition()
    if (currPosition.IsEqual(gClipPosition) == false) {
        SetClipTrans(gLastLevel, true);
    }
    else {
        clearTimeout(gClipUpdatetimeout);
        gClipUpdatetimeout = setTimeout("checkClipUpdate()", 100);
    }
}
//--------------
// 
function autoPlay(fromClick) {
    //debugger
    if (fromClick) {
        gAutoOnOff = !gAutoOnOff;
    }
 
    if (gAutoOnOff) {
        document.getElementById("clipIcon").src = "Images/autoOn.png";
        var a = gSliderClip.getValue();
        a = (a + 2) % 101;
        gSliderClip.setValue(a);
 
        gCliptimeout = setTimeout("autoPlay(false)", 20);
 
    }
    else {
        document.getElementById("clipIcon").src = "Images/autoOff.png";
        clearTimeout(gCliptimeout);
    }
}
 
//--------------
//  SetLayerRenderMode
function SetLayerRenderMode (layerIndex,forceValue){
    var LayerID = (layerIndex==1)?gLayer1ID:gLayer2ID;
    var modeID = (layerIndex==1)?$("#Layer1Mode"):$("#Layer2Mode");
    var obj = (layerIndex==1)?gLayer1Obj:gLayer2Obj;
    var renderMode ;
    if (forceValue==-1)
        renderMode = (layerIndex==1)?$("#Layer1Mode").val():$("#Layer2Mode").val();
    else{
        renderMode=forceValue;
        modeID.val(renderMode).change();
    }
    if (renderMode != -1){
        obj.Visibility.Show = true;
        obj.DisplayStyle=renderMode;
    }
    else {
        obj.Visibility.Show = false;
    }
}
//--------------
//  OnProjectTreeAction
function OnProjectTreeAction(ID,Action) {
    try{
        if (Action.Code == 15 && ID ==gLayer1ID)
            exitTool ();
    }
    catch (e) { if (gDebug) alert(SGLang.i18n("Text3") + e.message);}
}
 
//--------------
//  exitTool
function exitTool() {
    try {
            SGWorld.ProjectTree.DeleteItem(gLayer2ID);
            if (gStartSwipe){
 
                if (gLayer1ID != -1) {
                    SGWorld.ProjectTree.SetVisibility (gLayer1ID,gLayer1Visibility);
                    SetLayerRenderMode (1,gLayer1RenderMode);
                    SGWorld.Analysis.SetCompareGroup(gLayer1ID, 0);
                }
                SGWorld.Analysis.HideCompareBox();
                SGWorld.SetParam(450, 0);
            }
            SGWorld.Window.RemovePopupByCaption(SGLang.i18n("Text9"));
    }
    catch (e) { if (gDebug) alert(SGLang.i18n("Text3") + e.message);}
}
      
    </script>
 
</body>
</html>
 
 
 
 
<!--Sig:0000004014cB.cwfFPB6gOBTJYSuqR5uTzWVzBz5YczGqPtTrGGV.6bCmfp5bqxQObmf7WgJwnYv1gW2WiSdDjr28LS9JZJJ-->