Skip to content

Commit e2401b7

Browse files
committed
fix json progressbar value (now reaches 100%), #BUILD beta
1 parent 02e6023 commit e2401b7

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

MainWindow.xaml.cs

+20-12
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ static void StartProgressTimer()
527527
//Log.Write("Starting progress timer..*-*************************");
528528
progressTimerThread = new DispatcherTimer(DispatcherPriority.Background, Application.Current.Dispatcher);
529529
progressTimerThread.Tick += ProgressTick;
530-
progressTimerThread.Interval = TimeSpan.FromSeconds(0.1);
530+
progressTimerThread.Interval = TimeSpan.FromSeconds(1);
531531
progressTimerThread.Start();
532532

533533
Application.Current.Dispatcher.Invoke(new Action(() =>
@@ -625,7 +625,7 @@ static void ProgressTick(object sender, EventArgs e)
625625
{
626626
progressBar.Maximum = maxValue;
627627
progressBar.Value = currentValue;
628-
progressBar.Foreground = (currentValue + 1 >= maxValue ? Brushes.Lime : Brushes.Red); //+1 hack fix
628+
progressBar.Foreground = ((currentValue + 1 >= maxValue) ? Brushes.Lime : Brushes.Red); //+1 hack fix
629629
//progressBar.ToolTip = $"Thread {index} - {currentValue} / {maxValue}"; // not visible, because modal dialog
630630
//Log.Write("ProgressTick: " + index + " " + currentValue + " / " + maxValue);
631631

@@ -637,7 +637,7 @@ static void ProgressTick(object sender, EventArgs e)
637637
"\"thread\": " + index + "," +
638638
"\"currentPoint\": " + currentValue + "," +
639639
"\"totalPoints\": " + maxValue + "," +
640-
"\"percentage\": " + (int)((currentValue / (float)maxValue) * 100) + "," +
640+
"\"percentage\": " + (int)((currentValue / (float)maxValue) * 100.0) + "," +
641641
"\"file\": " + System.Text.Json.JsonSerializer.Serialize(progressInfo.FilePath) +
642642
"}";
643643
Log.Write(jsonString, LogEvent.Progress);
@@ -686,7 +686,7 @@ static void ProgressTick(object sender, EventArgs e)
686686
// process single file
687687
static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId, CancellationToken cancellationToken)
688688
{
689-
progressTotalPoints = 1; // FIXME dummy for progress bar
689+
progressTotalPoints = 0;
690690

691691
Log.Write("Started processing file: " + importSettings.inputFiles[fileIndex]);
692692

@@ -697,7 +697,7 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
697697
IReader taskReader = importSettings.GetOrCreateReader(taskId);
698698

699699
ProgressInfo progressInfo = null;
700-
lock (lockObject)
700+
//lock (lockObject)
701701
{
702702
//Log.Write(progressInfos.Count + " : " + fileIndex, LogEvent.Info);
703703
progressInfo = progressInfos[fileIndex % progressInfos.Count];
@@ -800,8 +800,6 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
800800
//progressPoint = 0;
801801
progressInfo.CurrentValue = 0;
802802
progressInfo.MaxValue = importSettings.useLimit ? pointCount : fullPointCount;
803-
//progressTotalPoints = importSettings.useLimit ? pointCount : fullPointCount;
804-
805803
progressInfo.FilePath = importSettings.inputFiles[fileIndex];
806804

807805
lastStatusMessage = "Processing points..";
@@ -816,14 +814,19 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
816814

817815
Log.Write(jsonString, LogEvent.File);
818816

819-
int checkCancelEvery = fullPointCount / 100;
817+
int checkCancelEvery = fullPointCount / 128;
820818

821819
// Loop all points
822-
for (int i = 0; i < fullPointCount; i++)
820+
821+
int maxPointIterations = importSettings.useLimit ? pointCount : fullPointCount;
822+
823+
//for (int i = 0; i < fullPointCount; i++)
824+
for (int i = 0; i < maxPointIterations; i++)
823825
//for (int i = 0; i < 1000; i++)
824826
{
827+
825828
// stop at limit count
826-
if (importSettings.useLimit == true && i > pointCount) break;
829+
//if (importSettings.useLimit == true && i > pointCount) break;
827830

828831
// check for cancel every 1% of points
829832
if (i % checkCancelEvery == 0)
@@ -839,7 +842,7 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
839842

840843
// get point XYZ
841844
Float3 point = taskReader.GetXYZ();
842-
if (point.hasError == true) break;
845+
if (point.hasError == true) break; // TODO display errors
843846

844847
// add offsets (its 0 if not used)
845848
point.x -= importSettings.offsetX;
@@ -915,8 +918,12 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
915918
taskWriter.AddPoint(i, (float)point.x, (float)point.y, (float)point.z, rgb.r, rgb.g, rgb.b, importSettings.importIntensity, intensity.r, importSettings.averageTimestamp, time);
916919
//progressPoint = i;
917920
progressInfo.CurrentValue = i;
921+
918922
} // for all points
919923

924+
// hack for missing 100% progress
925+
progressInfo.CurrentValue = maxPointIterations;
926+
920927
lastStatusMessage = "Saving files..";
921928
//importSettings.writer.Save(fileIndex);
922929
taskWriter.Save(fileIndex);
@@ -1446,7 +1453,7 @@ void SaveSettings()
14461453
Properties.Settings.Default.customintensityrange = (bool)chkCustomIntensityRange.IsChecked;
14471454
Properties.Settings.Default.openOutputFolder = (bool)chkOpenOutputFolder.IsChecked;
14481455
Properties.Settings.Default.useManualOffset = (bool)chkManualOffset.IsChecked;
1449-
float.TryParse(txtOffsetX.Text.Replace(",","."), NumberStyles.Float, CultureInfo.InvariantCulture, out float offsetX);
1456+
float.TryParse(txtOffsetX.Text.Replace(",", "."), NumberStyles.Float, CultureInfo.InvariantCulture, out float offsetX);
14501457
Properties.Settings.Default.manualOffsetX = offsetX;
14511458
float.TryParse(txtOffsetY.Text.Replace(",", "."), NumberStyles.Float, CultureInfo.InvariantCulture, out float offsetY);
14521459
Properties.Settings.Default.manualOffsetY = offsetY;
@@ -1642,6 +1649,7 @@ private void btnImportSettings_Click(object sender, RoutedEventArgs e)
16421649
var dialog = new OpenFileDialog();
16431650
dialog.Title = "Select settings file";
16441651
dialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
1652+
//dialog.DefaultDirectory = "configs/";
16451653

16461654
if (dialog.ShowDialog() == true)
16471655
{

Writers/PCROOT.cs

+5
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ void IWriter.Close()
231231
for (int i = 0, len = nodeBounds.Count; i < len; i++)
232232
{
233233
var tilerow = nodeBounds[i].fileName + sep + nodeBounds[i].totalPoints + sep + nodeBounds[i].minX + sep + nodeBounds[i].minY + sep + nodeBounds[i].minZ + sep + nodeBounds[i].maxX + sep + nodeBounds[i].maxY + sep + nodeBounds[i].maxZ + sep + nodeBounds[i].cellX + sep + nodeBounds[i].cellY + sep + nodeBounds[i].cellZ + sep + nodeBounds[i].averageTimeStamp + sep + nodeBounds[i].overlapRatio;
234+
// force dot as decimal separator
235+
tilerow = tilerow.Replace(",", ".");
234236
tilerootdata.Add(tilerow);
235237
totalPointCount += nodeBounds[i].totalPoints;
236238
}
@@ -266,6 +268,9 @@ void IWriter.Close()
266268
string globalData = versionID + sep + importSettings.gridSize.ToString() + sep + totalPointCount + sep + cloudMinX + sep + cloudMinY + sep + cloudMinZ + sep + cloudMaxX + sep + cloudMaxY + sep + cloudMaxZ;
267269
// autoOffsetX, globalOffsetY, globalOffsetZ, packMagic
268270
globalData += sep + importSettings.offsetX + sep + importSettings.offsetY + sep + importSettings.offsetZ + sep + importSettings.packMagicValue;
271+
// force dot as decimal separator
272+
globalData = globalData.Replace(",", ".");
273+
269274
if (addComments)
270275
{
271276
tilerootdata.Insert(2, globalData);

0 commit comments

Comments
 (0)