Skip to content

Commit

Permalink
Structure Matches shown in Minimap
Browse files Browse the repository at this point in the history
  • Loading branch information
ckitsanelis committed Dec 2, 2023
1 parent 7f8774d commit aaf6443
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/viewer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export default class App extends React.Component<Props, State> {
if (isClose === true)
this.setState({
rules: newRules,
logFile: this.state.logFile.updateRules(newRules),
logFile: this.state.logFile.updateLogFile(newRules, []),
showStatesDialog: false,
showFlagsDialog: false,
});
Expand Down Expand Up @@ -352,11 +352,14 @@ export default class App extends React.Component<Props, State> {
currentStructureMatch = [];
}

console.log(structureMatches)

this.setState({
rowProperties,
structureMatches,
currentStructureMatch,
currentStructureMatchIndex,
logFile: this.state.logFile.updateLogFile(this.state.rules, structureMatches)
});
}

Expand Down
40 changes: 34 additions & 6 deletions src/viewer/LogFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,39 @@ export default class LogFile {
return logFile;
}

updateRules(rules: Rule[]): LogFile {
// Slower solution
updateLogFile(rules: Rule[], structureMatches: number[][]): LogFile {
const [updatedSelected, updatedSelectedMini] = this.updateSelectedColumns(rules)
const headers = LogFile.getHeaders(this.contentHeaders, rules);
const logFile = new LogFile(this.contentHeaders, headers, this.rows);

let rows = this.rows;
if (this.rows[0].length === headers.length + 1)
rows = this.rows.map(r => r.slice(0,-1))

if (structureMatches.length > 0) {
updatedSelected.push(false);
updatedSelectedMini.push(true);
const name = "Structure"
const type = DEFAULT_HEADER_TYPE;
headers.push({name, type});
let currentStructureIndex = 0;
for (let i = 0; i < rows.length; i++) {
rows[i].push("");
if (currentStructureIndex < structureMatches.length) {
if (i > structureMatches[currentStructureIndex].at(-1)!) {
currentStructureIndex++;
if (currentStructureIndex === structureMatches.length)
break;
}

if (structureMatches[currentStructureIndex].includes(i)) {
rows[i].pop();
rows[i].push((currentStructureIndex + 1).toString());
}
}
}
}

const logFile = new LogFile(this.contentHeaders, headers, rows);
logFile.copyDefaultColumnColors(this.columnsColors);
logFile.computeRulesValuesAndColors(rules);
return logFile.setSelectedColumns(updatedSelected, updatedSelectedMini);
Expand Down Expand Up @@ -138,16 +166,16 @@ export default class LogFile {

private computeRulesValuesAndColors(rules: Rule[]) {
// Compute rules values
const startIndex = this.headers.length - rules.length;
const firstRuleIndex = this.contentHeaders.length;
const rulesValues = rules.map((r) => r.computeValues(this));
for (let row = 0; row < this.rows.length; row++) {
for (let column = 0; column < rulesValues.length; column++) {
this.rows[row][column + startIndex] = rulesValues[column][row];
this.rows[row][column + firstRuleIndex] = rulesValues[column][row];
}
}

// Compute colors
for (let i = startIndex; i < this.headers.length; i++) {
for (let i = firstRuleIndex; i < this.headers.length; i++) {
const values = this.rows.map((r) => r[i]);
this.columnsColors[i] = LogFile.computeColors(this.headers[i], values);
}
Expand Down

0 comments on commit aaf6443

Please sign in to comment.