File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export function ImportedCurves(curvesChanged) {
6
6
this . maxX = - Number . MAX_VALUE ;
7
7
this . minY = Number . MAX_VALUE ;
8
8
this . maxY = - Number . MAX_VALUE ;
9
-
9
+
10
10
this . curvesCount = function ( ) {
11
11
return this . _curvesData . length ;
12
12
} ;
@@ -64,6 +64,29 @@ export function ImportedCurves(curvesChanged) {
64
64
}
65
65
} ;
66
66
67
+ this . addCurve = function ( points , name ) {
68
+ this . _curvesData . push ( {
69
+ name : name ,
70
+ points : points ,
71
+ } ) ;
72
+ for ( const point of points ) {
73
+ this . minX = Math . min ( point . x , _that . minX ) ;
74
+ this . maxX = Math . max ( point . x , _that . maxX ) ;
75
+ this . minY = Math . min ( point . y , _that . minY ) ;
76
+ this . maxY = Math . max ( point . y , _that . maxY ) ;
77
+ }
78
+ curvesChanged ( ) ;
79
+ }
80
+
81
+ this . isNewCurve = function ( name ) {
82
+ for ( const curve of this . _curvesData ) {
83
+ if ( curve . name == name ) {
84
+ return false ;
85
+ }
86
+ }
87
+ return true ;
88
+ }
89
+
67
90
this . removeCurves = function ( ) {
68
91
this . _curvesData . length = 0 ;
69
92
this . minX = Number . MAX_VALUE ;
Original file line number Diff line number Diff line change @@ -1801,8 +1801,19 @@ GraphSpectrumPlot.removeImportedCurves = function() {
1801
1801
} ;
1802
1802
1803
1803
GraphSpectrumPlot . addCurrentSpectrumIntoImport = function ( ) {
1804
- if ( this . _spectrumType === SPECTRUM_TYPE . POWER_SPECTRAL_DENSITY ) {
1805
- alert ( "The PSD curve is added into import" ) ;
1804
+ if ( this . _spectrumType === SPECTRUM_TYPE . POWER_SPECTRAL_DENSITY &&
1805
+ this . _importedPSD . isNewCurve ( this . _fftData . fieldName ) ) {
1806
+ const fftLength = this . _fftData . fftLength ;
1807
+ const frequencyStep = 0.5 * this . _fftData . blackBoxRate / fftLength ;
1808
+ const points = [ ] ;
1809
+ for ( let index = 0 ; index < fftLength ; index ++ ) {
1810
+ const frequency = frequencyStep * index ;
1811
+ points . push ( {
1812
+ x : frequency ,
1813
+ y : this . _fftData . fftOutput [ index ] ,
1814
+ } ) ;
1815
+ }
1816
+ this . _importedPSD . addCurve ( points , this . _fftData . fieldName ) ;
1806
1817
}
1807
1818
} ;
1808
1819
You can’t perform that action at this time.
0 commit comments