Skip to content

Commit c416a4c

Browse files
committed
add progress bar status test info, add invertX option, fix progress point bar for limited point count
1 parent d052de0 commit c416a4c

File tree

7 files changed

+59
-3
lines changed

7 files changed

+59
-3
lines changed

App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100
<setting name="invertZ" serializeAs="String">
101101
<value>False</value>
102102
</setting>
103+
<setting name="invertX" serializeAs="String">
104+
<value>False</value>
105+
</setting>
103106
</PointCloudConverter.Properties.Settings>
104107
</userSettings>
105108
</configuration>

MainWindow.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<TextBox x:Name="txtScale" HorizontalAlignment="Left" Margin="0" TextWrapping="Wrap" VerticalAlignment="Top" Width="40" Text="0.1"/>
3333
</StackPanel>
3434
<CheckBox x:Name="chkSwapYZ" Content="Swap Y and Z" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" IsChecked="True" ToolTip="Swaps Z and Y values, since unity Y is up"/>
35+
<CheckBox x:Name="chkInvertX" Content="Invert X" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" ToolTip="Inverts X value (x=-x)"/>
3536
<CheckBox x:Name="chkInvertZ" Content="Invert Z" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource MainText}" ToolTip="Inverts Z value (z=-z)"/>
3637

3738
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal">
@@ -61,7 +62,10 @@
6162
<ProgressBar x:Name="progressBarFiles" Height="10" Width="190" Background="{x:Null}" HorizontalAlignment="Left" Maximum="1" Foreground="Lime" ToolTip="Files to process"/>
6263
</StatusBarItem>
6364
<StatusBarItem>
64-
<ProgressBar x:Name="progressBarPoints" Height="10" Width="690" Background="{x:Null}" HorizontalAlignment="Left" Maximum="1" Foreground="Lime" ToolTip="Points to process (in current file)"/>
65+
<ProgressBar x:Name="progressBarPoints" Height="10" Width="490" Background="{x:Null}" HorizontalAlignment="Left" Maximum="1" Foreground="Lime" ToolTip="Points to process (in current file)"/>
66+
</StatusBarItem>
67+
<StatusBarItem>
68+
<Label x:Name="lblStatus" Foreground="{DynamicResource MainText}">Status</Label>
6569
</StatusBarItem>
6670
</StatusBar>
6771
<TextBox x:Name="txtConsole" HorizontalAlignment="Left" Height="53" Margin="10,526,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="877" IsReadOnly="True" UndoLimit="1" Background="#FF404040" BorderBrush="{x:Null}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"/>

MainWindow.xaml.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private static void ProcessAllFiles(System.Object importSettingsObject)
103103

104104
// loop input files
105105
progressFile = 0;
106-
progressTotalFiles = importSettings.maxFiles-1;
106+
progressTotalFiles = importSettings.maxFiles - 1;
107107
for (int i = 0, len = importSettings.maxFiles; i < len; i++)
108108
{
109109
progressFile = i;
@@ -123,6 +123,8 @@ private static void ProcessAllFiles(System.Object importSettingsObject)
123123
Application.Current.Dispatcher.Invoke(new Action(() =>
124124
{
125125
mainWindowStatic.HideProcessingPanel();
126+
// call update one more time
127+
ProgressTick(null, null);
126128
// clear timer
127129
progressTimerThread.Stop();
128130
mainWindowStatic.progressBarFiles.Foreground = Brushes.Green;
@@ -141,6 +143,7 @@ void HideProcessingPanel()
141143
static int progressFile = 0;
142144
static int progressTotalFiles = 0;
143145
static DispatcherTimer progressTimerThread;
146+
public static string lastStatusMessage = "";
144147

145148
static void StartProgressTimer()
146149
{
@@ -153,6 +156,7 @@ static void StartProgressTimer()
153156
{
154157
mainWindowStatic.progressBarFiles.Foreground = Brushes.Red;
155158
mainWindowStatic.progressBarPoints.Foreground = Brushes.Red;
159+
mainWindowStatic.lblStatus.Content = "";
156160
}));
157161
}
158162

@@ -162,6 +166,7 @@ static void ProgressTick(object sender, EventArgs e)
162166
{
163167
mainWindowStatic.progressBarFiles.Value = progressFile / (float)progressTotalFiles;
164168
mainWindowStatic.progressBarPoints.Value = progressPoint / (float)progressTotalPoints;
169+
mainWindowStatic.lblStatus.Content = lastStatusMessage;
165170
}
166171
}
167172

@@ -239,7 +244,9 @@ static void ParseFile(ImportSettings importSettings, int fileIndex)
239244
}
240245

241246
progressPoint = 0;
242-
progressTotalPoints = pointCount;
247+
progressTotalPoints = importSettings.useLimit ? pointCount : fullPointCount;
248+
249+
lastStatusMessage = "Processing points..";
243250

244251
// Loop all points
245252
for (int i = 0; i < fullPointCount; i++)
@@ -275,6 +282,12 @@ static void ParseFile(ImportSettings importSettings, int fileIndex)
275282
point.z = -point.z;
276283
}
277284

285+
// flip X if enabled
286+
if (importSettings.invertX == true)
287+
{
288+
point.x = -point.x;
289+
}
290+
278291
// get point color
279292
Color rgb = importSettings.reader.GetRGB();
280293

@@ -283,12 +296,15 @@ static void ParseFile(ImportSettings importSettings, int fileIndex)
283296
progressPoint = i;
284297
}
285298

299+
lastStatusMessage = "Saving files..";
286300
importSettings.writer.Save(fileIndex);
301+
lastStatusMessage = "Finished saving..";
287302
importSettings.reader.Close();
288303

289304
// if this was last file
290305
if (fileIndex == (importSettings.maxFiles - 1))
291306
{
307+
lastStatusMessage = "Done!";
292308
Console.ForegroundColor = ConsoleColor.Green;
293309
Console.WriteLine("Finished!");
294310
Console.ForegroundColor = ConsoleColor.White;
@@ -329,6 +345,7 @@ void StartProcess(bool doProcess = true)
329345
if ((bool)chkUseMinPointCount.IsChecked) args.Add("-minpoints=" + txtMinPointCount.Text);
330346
if ((bool)chkUseScale.IsChecked) args.Add("-scale=" + txtScale.Text);
331347
args.Add("-swap=" + (bool)chkSwapYZ.IsChecked);
348+
if ((bool)chkInvertX.IsChecked) args.Add("-invertX=" + (bool)chkInvertX.IsChecked);
332349
if ((bool)chkInvertZ.IsChecked) args.Add("-invertZ=" + (bool)chkInvertZ.IsChecked);
333350
if ((bool)chkPackColors.IsChecked) args.Add("-pack=" + (bool)chkPackColors.IsChecked);
334351
if ((bool)chkUsePackMagic.IsChecked) args.Add("-packmagic=" + txtPackMagic.Text);
@@ -505,6 +522,7 @@ private void LoadSettings()
505522
chkUseScale.IsChecked = Properties.Settings.Default.useScale;
506523
txtScale.Text = Properties.Settings.Default.scale.ToString();
507524
chkSwapYZ.IsChecked = Properties.Settings.Default.swapYZ;
525+
chkInvertX.IsChecked = Properties.Settings.Default.invertX;
508526
chkInvertZ.IsChecked = Properties.Settings.Default.invertZ;
509527
chkPackColors.IsChecked = Properties.Settings.Default.packColors;
510528
chkUsePackMagic.IsChecked = Properties.Settings.Default.usePackMagic;
@@ -535,6 +553,7 @@ void SaveSettings()
535553
Properties.Settings.Default.useScale = (bool)chkUseScale.IsChecked;
536554
Properties.Settings.Default.scale = Tools.ParseFloat(txtScale.Text);
537555
Properties.Settings.Default.swapYZ = (bool)chkSwapYZ.IsChecked;
556+
Properties.Settings.Default.invertX = (bool)chkInvertX.IsChecked;
538557
Properties.Settings.Default.invertZ = (bool)chkInvertZ.IsChecked;
539558
Properties.Settings.Default.packColors = (bool)chkPackColors.IsChecked;
540559
Properties.Settings.Default.usePackMagic = (bool)chkUsePackMagic.IsChecked;

Properties/Settings.Designer.cs

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Properties/Settings.settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,8 @@
9292
<Setting Name="invertZ" Type="System.Boolean" Scope="User">
9393
<Value Profile="(Default)">False</Value>
9494
</Setting>
95+
<Setting Name="invertX" Type="System.Boolean" Scope="User">
96+
<Value Profile="(Default)">False</Value>
97+
</Setting>
9598
</Settings>
9699
</SettingsFile>

Structs/ImportSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class ImportSettings
3030
// TODO these should be export settings..
3131

3232
public bool swapYZ = true;
33+
public bool invertX = false;
3334
public bool invertZ = false;
3435
public bool importRGB = true; // this or intensity must be on
3536
public bool importIntensity = false;
@@ -63,6 +64,7 @@ public override string ToString()
6364
t += "\n inputFiles=" + inputFiles;
6465
t += "\n outputFile=" + outputFile;
6566
t += "\n swapYZ=" + swapYZ;
67+
t += "\n invertX=" + invertX;
6668
t += "\n invertZ=" + invertZ;
6769
t += "\n readRGB=" + importRGB;
6870
t += "\n readIntensity=" + importIntensity;

Tools/ArgParser.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,19 @@ public static ImportSettings Parse(string[] args, string rootFolder)
332332
}
333333
break;
334334

335+
case "-invertx":
336+
Console.WriteLine("invertx = " + param);
337+
338+
if (param != "true" && param != "false")
339+
{
340+
errors.Add("Invalid invertx parameter: " + param);
341+
}
342+
else
343+
{
344+
importSettings.invertX = param == "true";
345+
}
346+
break;
347+
335348
case "-invertz":
336349
Console.WriteLine("invertz = " + param);
337350

0 commit comments

Comments
 (0)