@@ -527,7 +527,7 @@ static void StartProgressTimer()
527
527
//Log.Write("Starting progress timer..*-*************************");
528
528
progressTimerThread = new DispatcherTimer ( DispatcherPriority . Background , Application . Current . Dispatcher ) ;
529
529
progressTimerThread . Tick += ProgressTick ;
530
- progressTimerThread . Interval = TimeSpan . FromSeconds ( 0. 1) ;
530
+ progressTimerThread . Interval = TimeSpan . FromSeconds ( 1 ) ;
531
531
progressTimerThread . Start ( ) ;
532
532
533
533
Application . Current . Dispatcher . Invoke ( new Action ( ( ) =>
@@ -625,7 +625,7 @@ static void ProgressTick(object sender, EventArgs e)
625
625
{
626
626
progressBar . Maximum = maxValue ;
627
627
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
629
629
//progressBar.ToolTip = $"Thread {index} - {currentValue} / {maxValue}"; // not visible, because modal dialog
630
630
//Log.Write("ProgressTick: " + index + " " + currentValue + " / " + maxValue);
631
631
@@ -637,7 +637,7 @@ static void ProgressTick(object sender, EventArgs e)
637
637
"\" thread\" : " + index + "," +
638
638
"\" currentPoint\" : " + currentValue + "," +
639
639
"\" totalPoints\" : " + maxValue + "," +
640
- "\" percentage\" : " + ( int ) ( ( currentValue / ( float ) maxValue ) * 100 ) + "," +
640
+ "\" percentage\" : " + ( int ) ( ( currentValue / ( float ) maxValue ) * 100.0 ) + "," +
641
641
"\" file\" : " + System . Text . Json . JsonSerializer . Serialize ( progressInfo . FilePath ) +
642
642
"}" ;
643
643
Log . Write ( jsonString , LogEvent . Progress ) ;
@@ -686,7 +686,7 @@ static void ProgressTick(object sender, EventArgs e)
686
686
// process single file
687
687
static bool ParseFile ( ImportSettings importSettings , int fileIndex , int ? taskId , CancellationToken cancellationToken )
688
688
{
689
- progressTotalPoints = 1 ; // FIXME dummy for progress bar
689
+ progressTotalPoints = 0 ;
690
690
691
691
Log . Write ( "Started processing file: " + importSettings . inputFiles [ fileIndex ] ) ;
692
692
@@ -697,7 +697,7 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
697
697
IReader taskReader = importSettings . GetOrCreateReader ( taskId ) ;
698
698
699
699
ProgressInfo progressInfo = null ;
700
- lock ( lockObject )
700
+ // lock (lockObject)
701
701
{
702
702
//Log.Write(progressInfos.Count + " : " + fileIndex, LogEvent.Info);
703
703
progressInfo = progressInfos [ fileIndex % progressInfos . Count ] ;
@@ -800,8 +800,6 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
800
800
//progressPoint = 0;
801
801
progressInfo . CurrentValue = 0 ;
802
802
progressInfo . MaxValue = importSettings . useLimit ? pointCount : fullPointCount ;
803
- //progressTotalPoints = importSettings.useLimit ? pointCount : fullPointCount;
804
-
805
803
progressInfo . FilePath = importSettings . inputFiles [ fileIndex ] ;
806
804
807
805
lastStatusMessage = "Processing points.." ;
@@ -816,14 +814,19 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
816
814
817
815
Log . Write ( jsonString , LogEvent . File ) ;
818
816
819
- int checkCancelEvery = fullPointCount / 100 ;
817
+ int checkCancelEvery = fullPointCount / 128 ;
820
818
821
819
// 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 ++ )
823
825
//for (int i = 0; i < 1000; i++)
824
826
{
827
+
825
828
// stop at limit count
826
- if ( importSettings . useLimit == true && i > pointCount ) break ;
829
+ // if (importSettings.useLimit == true && i > pointCount) break;
827
830
828
831
// check for cancel every 1% of points
829
832
if ( i % checkCancelEvery == 0 )
@@ -839,7 +842,7 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
839
842
840
843
// get point XYZ
841
844
Float3 point = taskReader . GetXYZ ( ) ;
842
- if ( point . hasError == true ) break ;
845
+ if ( point . hasError == true ) break ; // TODO display errors
843
846
844
847
// add offsets (its 0 if not used)
845
848
point . x -= importSettings . offsetX ;
@@ -915,8 +918,12 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
915
918
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 ) ;
916
919
//progressPoint = i;
917
920
progressInfo . CurrentValue = i ;
921
+
918
922
} // for all points
919
923
924
+ // hack for missing 100% progress
925
+ progressInfo . CurrentValue = maxPointIterations ;
926
+
920
927
lastStatusMessage = "Saving files.." ;
921
928
//importSettings.writer.Save(fileIndex);
922
929
taskWriter . Save ( fileIndex ) ;
@@ -1446,7 +1453,7 @@ void SaveSettings()
1446
1453
Properties . Settings . Default . customintensityrange = ( bool ) chkCustomIntensityRange . IsChecked ;
1447
1454
Properties . Settings . Default . openOutputFolder = ( bool ) chkOpenOutputFolder . IsChecked ;
1448
1455
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 ) ;
1450
1457
Properties . Settings . Default . manualOffsetX = offsetX ;
1451
1458
float . TryParse ( txtOffsetY . Text . Replace ( "," , "." ) , NumberStyles . Float , CultureInfo . InvariantCulture , out float offsetY ) ;
1452
1459
Properties . Settings . Default . manualOffsetY = offsetY ;
@@ -1642,6 +1649,7 @@ private void btnImportSettings_Click(object sender, RoutedEventArgs e)
1642
1649
var dialog = new OpenFileDialog ( ) ;
1643
1650
dialog . Title = "Select settings file" ;
1644
1651
dialog . Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*" ;
1652
+ //dialog.DefaultDirectory = "configs/";
1645
1653
1646
1654
if ( dialog . ShowDialog ( ) == true )
1647
1655
{
0 commit comments