+/*!
+ * This class stores properties in loading state mode (pvsm) when the MED file has not been read yet.
+ * The file is not read beacause FileName has not been informed yet ! So this class stores properties of vtkMEDReader instance that
+ * owns it and wait the vtkMEDReader::SetFileName to apply properties afterwards.
+ */
+class PropertyKeeper
+{
+public:
+ PropertyKeeper(vtkMEDReader *master):_master(master),IsGVActivated(false),GVValue(0),IsCMActivated(false),CMValue(0) { }
+ void assignPropertiesIfNeeded();
+ bool arePropertiesOnTreeToSetAfter() const;
+ //
+ void pushFieldStatusEntry(const char* name, int status);
+ void pushGenerateVectorsValue(int value);
+ void pushChangeModeValue(int value);
+ void pushTimesFlagsStatusEntry(const char* name, int status);
+protected:
+ // pool of pairs to assign in SetFieldsStatus if needed. The use case is the load using pvsm.
+ std::vector< std::pair<std::string,int> > SetFieldsStatusPairs;
+ // generate vector
+ bool IsGVActivated;
+ int GVValue;
+ // change mode
+ bool IsCMActivated;
+ int CMValue;
+ //
+ std::vector< std::pair<std::string,int> > TimesFlagsStatusPairs;
+ vtkMEDReader *_master;
+};
+
+void PropertyKeeper::assignPropertiesIfNeeded()
+{
+ if(!this->SetFieldsStatusPairs.empty())
+ {
+ for(std::vector< std::pair<std::string,int> >::const_iterator it=this->SetFieldsStatusPairs.begin();it!=this->SetFieldsStatusPairs.end();it++)
+ _master->SetFieldsStatus((*it).first.c_str(),(*it).second);
+ this->SetFieldsStatusPairs.clear();
+ }
+ if(!this->TimesFlagsStatusPairs.empty())
+ {
+ for(std::vector< std::pair<std::string,int> >::const_iterator it=this->TimesFlagsStatusPairs.begin();it!=this->TimesFlagsStatusPairs.end();it++)
+ _master->SetTimesFlagsStatus((*it).first.c_str(),(*it).second);
+ this->TimesFlagsStatusPairs.clear();
+ }
+ if(this->IsGVActivated)
+ {
+ _master->GenerateVectors(this->GVValue);
+ this->IsGVActivated=false;
+ }
+ if(this->IsCMActivated)
+ {
+ _master->ChangeMode(this->CMValue);
+ this->IsCMActivated=false;
+ }
+}
+
+void PropertyKeeper::pushFieldStatusEntry(const char* name, int status)
+{
+ bool found(false);
+ for(std::vector< std::pair<std::string,int> >::const_iterator it=this->SetFieldsStatusPairs.begin();it!=this->SetFieldsStatusPairs.end() && !found;it++)
+ found=(*it).first==name;
+ if(!found)
+ this->SetFieldsStatusPairs.push_back(std::pair<std::string,int>(name,status));
+}
+
+void PropertyKeeper::pushTimesFlagsStatusEntry(const char* name, int status)
+{
+ bool found(false);
+ for(std::vector< std::pair<std::string,int> >::const_iterator it=this->TimesFlagsStatusPairs.begin();it!=this->TimesFlagsStatusPairs.end() && !found;it++)
+ found=(*it).first==name;
+ if(!found)
+ this->TimesFlagsStatusPairs.push_back(std::pair<std::string,int>(name,status));
+}
+
+void PropertyKeeper::pushGenerateVectorsValue(int value)
+{
+ this->IsGVActivated=true;
+ this->GVValue=value;
+}
+
+void PropertyKeeper::pushChangeModeValue(int value)
+{
+ this->IsCMActivated=true;
+ this->CMValue=value;
+}
+
+bool PropertyKeeper::arePropertiesOnTreeToSetAfter() const
+{
+ return !SetFieldsStatusPairs.empty();
+}
+