Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
XRF-App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fabio Proietti
XRF-App
Commits
68625749
Commit
68625749
authored
7 years ago
by
Francesco Giacomini
Browse files
Options
Downloads
Patches
Plain Diff
[wip] restructuring
parent
fa383717
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fs.ts
+122
-4
122 additions, 4 deletions
fs.ts
globals.ts
+10
-0
10 additions, 0 deletions
globals.ts
start.ts
+10
-9
10 additions, 9 deletions
start.ts
with
142 additions
and
13 deletions
fs.ts
+
122
−
4
View file @
68625749
...
...
@@ -123,18 +123,136 @@ function openFileFromServer(url)
{
if
(
txtFile
.
readyState
===
4
)
{
if
(
txtFile
.
status
===
200
)
{
read
Data
((
txtFile
.
responseText
));
read
Image
((
txtFile
.
responseText
));
}
}
}
txtFile
.
send
(
null
);
}
// La funzione readData() prende in ingresso il file di input memorizzato nella
export
function
get_metadata
(
lines
:
string
[]):
G
.
Metadata
{
let
metadata
=
new
G
.
Metadata
();
let
xMin
:
number
=
0
,
yMin
:
number
=
0
,
xMax
:
number
=
0
,
yMax
:
number
=
0
;
let
passo
:
number
=
0
;
//dimensione di un pixel in micorn
let
readMode
:
string
=
'
u
'
;
//direzione di lettura
//scorro l'array soffermandomi solo sulle righe "intestazione delle x". Devo
//determinare ascisse e cordinate minime e massime, il passo e la direzione di
//scansione
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
if
(
parseInt
(
lines
[
i
])
>
17000
&&
lines
[
i
][
0
]
==
'
5
'
)
{
if
(
xMin
==
0
)
{
//se sono alla prima intestazione salvo la x e la y
xMin
=
parseInt
(
lines
[
i
]);
yMin
=
parseInt
(
lines
[
i
+
1
]);
i
++
;
}
else
{
//definisco passo e direzione di scansione dalla seconda intestazione
if
(
parseInt
(
lines
[
i
])
==
xMin
)
{
readMode
=
'
c
'
;
passo
=
Math
.
abs
(
yMin
-
+
lines
[
i
+
1
]);
// the unary + converts to number
//se sto leggendo per colonne determino xMax leggendo dalla fine
for
(
let
j
:
number
=
lines
.
length
;
j
>
i
;
j
--
)
{
//se la riga è "intestazione x" memorizzo xMax e lo confronto con xMin
if
(
parseInt
(
lines
[
j
])
>
17000
&&
lines
[
j
][
0
]
==
'
5
'
)
{
xMax
=
parseInt
(
lines
[
j
]);
if
(
xMax
<
xMin
)
{
let
t
:
number
=
xMax
;
xMax
=
xMin
;
xMin
=
t
;
}
break
;
}
}
}
else
{
readMode
=
'
r
'
;
passo
=
Math
.
abs
(
xMin
-
+
lines
[
i
]);
// the unary + converts to number
//se sto leggendo per righe determino yMax leggendo dalla fine
for
(
let
j
:
number
=
lines
.
length
;
j
>
i
;
j
--
)
{
//se la riga è "intestazione y" memorizzo yMax e lo confronto con yMin
if
(
parseInt
(
lines
[
j
])
>
17000
&&
lines
[
j
][
0
]
==
'
6
'
)
{
yMax
=
parseInt
(
lines
[
j
]);
if
(
yMax
<
yMin
)
{
let
t
:
number
=
yMax
;
yMax
=
yMin
;
yMin
=
t
;
}
break
;
}
}
}
break
;
}
}
}
//alert(xMin + " " + xMax + " " + yMin + " " + yMax + " " + passo);
metadata
=
{
xMin
,
xMax
,
yMin
,
yMax
,
stepSize
:
passo
,
direction
:
readMode
};
return
metadata
;
}
// version working on an array of numbers, obtained from the array of string lines
export
function
get_metadata_num
(
lines
:
number
[]):
G
.
Metadata
{
let
metadata
=
new
G
.
Metadata
();
let
xMin
:
number
=
0
,
yMin
:
number
=
0
,
xMax
:
number
=
0
,
yMax
:
number
=
0
;
let
passo
:
number
=
0
;
//dimensione di un pixel in micorn
let
readMode
:
string
=
'
u
'
;
//direzione di lettura
//scorro l'array soffermandomi solo sulle righe "intestazione delle x". Devo
//determinare ascisse e cordinate minime e massime, il passo e la direzione di
//scansione
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
let
p
=
lines
[
i
];
if
(
lines
[
i
]
>
17000
&&
lines
[
i
].
toString
()[
0
]
==
'
5
'
)
{
if
(
xMin
==
0
)
{
//se sono alla prima intestazione salvo la x e la y
xMin
=
lines
[
i
];
yMin
=
lines
[
i
+
1
];
i
++
;
}
else
{
//definisco passo e direzione di scansione dalla seconda intestazione
if
(
lines
[
i
]
==
xMin
)
{
readMode
=
'
c
'
;
passo
=
Math
.
abs
(
yMin
-
lines
[
i
+
1
]);
// the unary + converts to number
//se sto leggendo per colonne determino xMax leggendo dalla fine
for
(
let
j
:
number
=
lines
.
length
;
j
>
i
;
j
--
)
{
//se la riga è "intestazione x" memorizzo xMax e lo confronto con xMin
if
(
lines
[
j
]
>
17000
&&
lines
[
j
].
toString
()[
0
]
==
'
5
'
)
{
xMax
=
lines
[
j
];
if
(
xMax
<
xMin
)
{
let
t
:
number
=
xMax
;
xMax
=
xMin
;
xMin
=
t
;
}
break
;
}
}
}
else
{
readMode
=
'
r
'
;
passo
=
Math
.
abs
(
xMin
-
lines
[
i
]);
// the unary + converts to number
//se sto leggendo per righe determino yMax leggendo dalla fine
for
(
let
j
:
number
=
lines
.
length
;
j
>
i
;
j
--
)
{
//se la riga è "intestazione y" memorizzo yMax e lo confronto con yMin
if
(
lines
[
j
]
>
17000
&&
lines
[
j
].
toString
()[
0
]
==
'
6
'
)
{
yMax
=
lines
[
j
];
if
(
yMax
<
yMin
)
{
let
t
:
number
=
yMax
;
yMax
=
yMin
;
yMin
=
t
;
}
break
;
}
}
}
break
;
}
}
}
//alert(xMin + " " + xMax + " " + yMin + " " + yMax + " " + passo);
metadata
=
{
xMin
,
xMax
,
yMin
,
yMax
,
stepSize
:
passo
,
direction
:
readMode
};
return
metadata
;
}
/* let metadata = get_metadata(lines);
let passo = metadata.stepSize; //dimensione di un pixel in micorn
let readMode = metadata.direction; //direzione di lettura
//coordinate minime e massime in entrambe le dimensioni
let xMin = metadata.xMin;
let yMin = metadata.yMin;
let xMax = metadata.xMax;
let yMax = metadata.yMax;
*/
// La funzione readImage() prende in ingresso il file di input memorizzato nella
// stringa "fileString". La funzione riempie la matrice "DataMatrix" con i dati
// in modo che essi siano memorizzati in un formato più leggibile. Sono ricavate
// anche altre variabili necessarie per il resto del codice.
export
function
read
Data
(
content
:
string
):
G
.
Image
export
function
read
Image
(
content
:
string
):
G
.
Image
{
let
newOrigin
=
{
xp
:
0
,
yp
:
0
};
//origine nel caso di zoom
let
passo
:
number
=
0
;
//dimensione di un pixel in micorn
...
...
@@ -230,7 +348,7 @@ export function readData(content: string): G.Image
fileStringArray
[
i
]
=
(
parseInt
(
fileStringArray
[
i
])
+
passo
).
toString
();
}
}
//Definisco le dimensioni della matrice DataMatrix e la inizializzo
let
xDim
:
number
;
let
yDim
:
number
;
...
...
This diff is collapsed.
Click to expand it.
globals.ts
+
10
−
0
View file @
68625749
...
...
@@ -10,6 +10,16 @@ export class Calibration
b
:
number
;
}
export
class
Metadata
{
xMin
:
number
;
xMax
:
number
;
yMin
:
number
;
yMax
:
number
;
stepSize
:
number
;
direction
:
string
;
}
export
class
Image
{
DataMatrix
:
number
[][][];
...
...
This diff is collapsed.
Click to expand it.
start.ts
+
10
−
9
View file @
68625749
...
...
@@ -72,10 +72,10 @@ export function setImportFile()
readerObject
.
onload
=
function
()
{
let
content
:
string
=
readerObject
.
result
;
let
image
=
fs
.
read
Data
(
content
);
console
.
log
(
image
.
xDim
);
img
.
drawImg
(
image
,
{
x
:
0
,
y
:
0
},
{
x
:
image
.
xDim
-
1
,
y
:
image
.
yDim
-
1
},
0
,
G
.
channelDepth
);
img
.
drawChart
(
image
,
{
x
:
0
,
y
:
0
},
{
x
:
image
.
xDim
-
1
,
y
:
image
.
yDim
-
1
},
0
,
G
.
channelDepth
);
let
image
=
fs
.
read
Image
(
content
);
console
.
log
(
image
.
width
);
img
.
drawImg
(
image
,
{
x
:
0
,
y
:
0
},
{
x
:
image
.
width
-
1
,
y
:
image
.
height
-
1
},
0
,
G
.
channelDepth
);
img
.
drawChart
(
image
,
{
x
:
0
,
y
:
0
},
{
x
:
image
.
width
-
1
,
y
:
image
.
height
-
1
},
0
,
G
.
channelDepth
);
// install callbacks for the canvas and chart?
}
readerObject
.
readAsText
(
file
);
...
...
@@ -155,14 +155,15 @@ function callback(files)
{
$
(
"
#load-spinner
"
).
css
(
"
display
"
,
"
inline
"
);
console
.
log
(
"
Try to open
"
+
files
[
files
.
length
-
1
]
.
name
+
"
...
"
)
;
let
readerObject
:
any
=
new
FileReader
(
);
readerObject
.
readAsBinaryString
(
files
[
files
.
length
-
1
]
);
let
file
:
File
=
files
[
files
.
length
-
1
];
console
.
log
(
"
Try to open
"
+
file
.
name
+
"
...
"
);
let
readerObject
=
new
FileReader
(
);
readerObject
.
onload
=
function
()
{
let
fileString
:
string
=
readerObject
.
result
;
fs
.
read
Data
(
fileString
);
let
content
:
string
=
readerObject
.
result
;
fs
.
read
Image
(
content
);
}
readerObject
.
readAsText
(
file
);
}
//la funzione findPosition definisce la posizione del cursore del mouse
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment