Reset GUI and progress bar on different file selected

This commit is contained in:
Jonathan Grangien
2018-07-03 14:24:33 -04:00
committed by Matthias Berg
parent 9910c1e4f4
commit d6d576cd9c
5 changed files with 18 additions and 20 deletions

View File

@@ -95,7 +95,7 @@ Loader::Loader()
, _volumeConversionProgress(VolumeConversionProgressInfo)
{
_uploadDataTrigger.onChange([this](){
uploadData();
selectData();
});
addProperty(_filePaths);
@@ -103,16 +103,15 @@ Loader::Loader()
addProperty(_volumeConversionProgress);
}
// Rename select data
void Loader::uploadData() {
void Loader::selectData() {
{
std::thread t([&](){
nfdchar_t *outPath = NULL;
nfdresult_t result = NFD_OpenDialog( "cdf", NULL, &outPath ); //TODO: handle different data types
if ( outPath && result == NFD_OKAY ) {
LINFO("selected a file.");
_filePaths = outPath;
_volumeConversionProgress = 0.0f;
free(outPath);
}
else if ( result == NFD_CANCEL ) {
@@ -120,7 +119,7 @@ void Loader::uploadData() {
}
else {
std::string error = NFD_GetError();
LINFO("Error: \n" + error );
LINFO("Error: \n" + error);
}
});

View File

@@ -48,7 +48,7 @@ class Loader : public PropertyOwner, public Operator {
Loader();
// Select file data path
void uploadData();
void selectData();
/**
* Creates and adds trigger properties for data items in the internal directory

View File

@@ -149,7 +149,7 @@ std::unique_ptr<volume::RawVolume<float>> KameleonVolumeReader::readFloatVolume(
float* data = volume->data();
size_t progressUpdateStep = volume->nCells() / 20;
size_t progressUpdateStep = volume->nCells() / 10;
for (size_t index = 0; index < volume->nCells(); ++index) {
const glm::vec3 coords = volume->indexToCoords(index);
@@ -324,6 +324,8 @@ std::string KameleonVolumeReader::getVisUnit(const std::string& variable) const
std::string KameleonVolumeReader::time() const {
double start =
ccmc::Time(simulationStart()).getEpoch();
// std::cout << "time = " + std::to_string(start) << std::endl;
// Get elapsed time in seconds and convert to milliseconds.
double elapsed = elapsedTime() * 1000;
return ccmc::Time(start + elapsed).toString();

View File

@@ -24,7 +24,7 @@ class PrepareUploadedData extends Component {
this.state = {
volumeProgress: 0,
uploadButtonClicked: false,
uploadButtonIsClicked: false,
activated: false,
dimensions: { x: 100, y: 100, z: 128 },
@@ -48,7 +48,10 @@ class PrepareUploadedData extends Component {
const { filePaths } = this.props;
if( filePaths !== prevProps.filePaths && filePaths !== undefined ) {
this.setState({ activated: true });
this.setState({
activated: true,
uploadButtonIsClicked: false
});
}
this.subscribeToVolumeConversionProgress();
@@ -98,7 +101,7 @@ class PrepareUploadedData extends Component {
}
upload() {
this.setState({uploadButtonClicked: true});
this.setState({uploadButtonIsClicked: true});
const { dimensions, variable, lowerDomainBounds, upperDomainBounds, rSquared } = this.state;
let data = `\'
@@ -143,11 +146,7 @@ class PrepareUploadedData extends Component {
<Window type="small"
title="Prepare Data"
size={windowSize}
<<<<<<< HEAD
position={{ x: 300, y: 300 }}
=======
position={{ x: 100, y: 200 }}
>>>>>>> Run file dialog on separate thread and connect chosen file to GUI
closeCallback={() => this.setState({ activated: false })}>
<div className={styles.content}>
<CenteredLabel>{getDirectoryLeaf(this.props.filePaths)}</CenteredLabel>
@@ -165,7 +164,7 @@ class PrepareUploadedData extends Component {
<Checkbox label='Factor r^2?'
onChange={this.changeRSquared}/>
<Button onClick={() => this.upload()}> Convert </Button>
{this.state.uploadButtonClicked && (
{this.state.uploadButtonIsClicked && (
<Row>
<ProgressBar label='Volume conversion progress'
initializingMsg='Reading'

View File

@@ -41,9 +41,9 @@ class ProgressBar extends React.Component {
}
initializeDots() {
this.intervalHandle = setInterval(() => {
const { dots } = this.state;
if (dots.length < 3) {
this.setState({dots: dots + '.'});
} else {
@@ -85,16 +85,14 @@ class ProgressBar extends React.Component {
};
ProgressBar.propTypes = {
label: PropTypes.string,
label: PropTypes.string.isRequired,
initializingMsg: PropTypes.string,
progressPercent: PropTypes.number,
progressPercent: PropTypes.number.isRequired,
colorFill: PropTypes.string,
};
ProgressBar.defaultProps = {
label: '',
initializingMsg: 'Working',
progressPercent: 0,
colorFill: '#aff7c0',
}