コード例 #1
0
ファイル: step.cpp プロジェクト: christos-tsotskas/NETPLAN
// Given a 'Step', it determines the column position (for reading properties).
// It goes like this: 'const' 'y1' 'y1m1' 'y1m1h1' 'y1m1h2' ... 'y1m2' etc.
int Step2Pos(const Step& mystep) {
	int output = 0, temp_size;
	unsigned int j = 0;
	while ((j < mystep.size()) && (mystep[j] !=0)) {
		temp_size = 1;
		for (unsigned int k = mystep.size()-1; k > j; k--) {
			temp_size = temp_size * SLength[k] + 1;
		}
		output += (mystep[j]-1) * temp_size + 1;
		j++;
	}
	return output;
}
コード例 #2
0
ファイル: step.cpp プロジェクト: christos-tsotskas/NETPLAN
// Given a 'Step', it determines the column position (for writing output).
// It goes like this: 'y1' 'y2' ... 'y1m1' 'y1m2' ... 'y1m1h1' 'y1m1h2' etc.
int Step2Col(const Step& mystep) {
	int output = 1, temp, num = 0;
	for (int i = mystep.size()-2; i >= 0 ; --i) {
		if (mystep[i+1] != 0) {
			output = 1 + output * SLength[i];
			num++;
		}
	}
	output--;
	for (unsigned int i = 0; i <= num; ++i) {
		temp = 1;
		for (unsigned int k = i+1; k <= num; ++k) temp = temp * SLength[k];
		output += (mystep[i] - 1) * temp;
	}
	return output;
}
コード例 #3
0
QModelIndex MessageLogWindowModel::index(int row, int column, const QModelIndex &parent) const
{
   if (mpLog.get() == NULL)
   {
      return QModelIndex();
   }

   const Message* pMessage = NULL;
   if (parent.isValid())
   {
      Subject* pSubject = reinterpret_cast<Subject*>(parent.internalPointer());
      Message* pParent = dynamic_cast<Message*>(pSubject);
      Step* pParentStep = dynamic_cast<Step*>(pParent);

      // the parent is a step
      if (pParentStep != NULL)
      {
         if (row < static_cast<int>(pParentStep->size()))
         {
            pMessage = (*pParentStep)[row];
         }
         else
         {
            const DynamicObject* pProperties = pParent->getProperties();
            mPropertyCache.insert(pProperties, pParent);
            return createIndex(row, column,
                           const_cast<Subject*>(static_cast<const Subject*>(pProperties)));
         }
      }
      // the parent is a message
      else if (pParent != NULL)
      {
         const DynamicObject* pProperties = pParent->getProperties();
         mPropertyCache.insert(pProperties, pParent);
         return createIndex(row, column, const_cast<Subject*>(static_cast<const Subject*>(pProperties)));
      }
   }
   else if (row < static_cast<int>(mpLog->size()))
   {
      pMessage = (*(mpLog.get()))[row];
   }
   return createIndex(row, column, const_cast<Subject*>(static_cast<const Subject*>(pMessage)));
}