Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tfxattributes.h"
Toshihiro Shimizu 890ddd
#include "tconst.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFxAttributes::TFxAttributes()
Shinya Kitaoka 120a6e
    : m_id(0)
Shinya Kitaoka 120a6e
    , m_dagNodePos(TConst::nowhere)
Shinya Kitaoka 120a6e
    , m_enabled(true)
Shinya Kitaoka 120a6e
    , m_speedAware(false)
Shinya Kitaoka 120a6e
    , m_isOpened(false)
Shinya Kitaoka 120a6e
    , m_speed()
Shinya Kitaoka 120a6e
    , m_groupSelector(-1)
Shinya Kitaoka 120a6e
    , m_passiveCacheDataIdx(-1) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TFxAttributes::~TFxAttributes() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TFxAttributes::setDagNodePos(const TPointD &pos) { m_dagNodePos = pos; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int TFxAttributes::setGroupId(int value) {
Shinya Kitaoka 120a6e
  m_groupSelector++;
Shinya Kitaoka 120a6e
  m_groupId.insert(m_groupSelector, value);
Shinya Kitaoka 120a6e
  return m_groupSelector;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TFxAttributes::setGroupId(int value, int position) {
Shinya Kitaoka 120a6e
  assert(position >= 0 && position <= m_groupId.size());
Shinya Kitaoka 120a6e
  m_groupId.insert(position, value);
Shinya Kitaoka 120a6e
  if (m_groupSelector + 1 >= position) m_groupSelector++;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int TFxAttributes::getGroupId() {
Shinya Kitaoka 120a6e
  return m_groupId.isEmpty() || m_groupSelector < 0 ||
Shinya Kitaoka 120a6e
                 m_groupSelector >= m_groupId.size()
Shinya Kitaoka 120a6e
             ? 0
Shinya Kitaoka 120a6e
             : m_groupId[m_groupSelector];
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
QStack<int> TFxAttributes::getGroupIdStack() { return m_groupId; }</int>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TFxAttributes::removeGroupId(int position) {
Shinya Kitaoka 120a6e
  if (!isGrouped()) return;
Shinya Kitaoka 120a6e
  assert(position >= 0 && position <= m_groupId.size());
Shinya Kitaoka 120a6e
  m_groupId.remove(position);
Shinya Kitaoka 120a6e
  if (m_groupSelector + 1 >= position && m_groupSelector > -1)
Shinya Kitaoka 120a6e
    m_groupSelector--;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int TFxAttributes::removeGroupId() {
Shinya Kitaoka 120a6e
  m_groupId.remove(m_groupSelector);
Shinya Kitaoka 120a6e
  if (m_groupSelector > -1) m_groupSelector--;
Shinya Kitaoka 120a6e
  return m_groupSelector + 1;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool TFxAttributes::isGrouped() { return !m_groupId.isEmpty(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool TFxAttributes::isContainedInGroup(int groupId) {
Shinya Kitaoka 120a6e
  return m_groupId.contains(groupId);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TFxAttributes::setGroupName(const std::wstring &name, int position) {
Shinya Kitaoka 120a6e
  int groupSelector = position < 0 ? m_groupSelector : position;
Shinya Kitaoka 120a6e
  assert(groupSelector >= 0 && groupSelector <= m_groupName.size());
Shinya Kitaoka 120a6e
  m_groupName.insert(groupSelector, name);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::wstring TFxAttributes::getGroupName(bool fromEditor) {
Shinya Kitaoka 120a6e
  int groupSelector = fromEditor ? m_groupSelector + 1 : m_groupSelector;
Shinya Kitaoka 120a6e
  return m_groupName.isEmpty() || groupSelector < 0 ||
Shinya Kitaoka 120a6e
                 groupSelector >= m_groupName.size()
Shinya Kitaoka 120a6e
             ? L""
Shinya Kitaoka 120a6e
             : m_groupName[groupSelector];
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
QStack<std::wstring> TFxAttributes::getGroupNameStack() { return m_groupName; }</std::wstring>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int TFxAttributes::removeGroupName(bool fromEditor) {
Shinya Kitaoka 120a6e
  int groupSelector = fromEditor ? m_groupSelector + 1 : m_groupSelector;
Shinya Kitaoka 120a6e
  if (!isGrouped()) return -1;
Shinya Kitaoka 120a6e
  assert(groupSelector >= 0 && groupSelector <= m_groupName.size());
Shinya Kitaoka 120a6e
  m_groupName.remove(groupSelector);
Shinya Kitaoka 120a6e
  return groupSelector;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TFxAttributes::removeGroupName(int position) {
Shinya Kitaoka 120a6e
  int groupSelector = position < 0 ? m_groupSelector : position;
Shinya Kitaoka 120a6e
  assert(groupSelector >= 0 && groupSelector <= m_groupName.size());
Shinya Kitaoka 120a6e
  m_groupName.remove(groupSelector);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool TFxAttributes::editGroup() {
Shinya Kitaoka 120a6e
  return (m_groupSelector < 0) ? false : (--m_groupSelector, true);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool TFxAttributes::isGroupEditing() {
Shinya Kitaoka 120a6e
  return isGrouped() && (m_groupSelector == -1);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TFxAttributes::closeEditingGroup(int groupId) {
Shinya Kitaoka 120a6e
  if (!m_groupId.contains(groupId)) return;
Shinya Kitaoka 120a6e
  m_groupSelector = 0;
Shinya Kitaoka 120a6e
  while (m_groupId[m_groupSelector] != groupId &&
Shinya Kitaoka 120a6e
         m_groupSelector < m_groupId.size())
Shinya Kitaoka 120a6e
    m_groupSelector++;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int TFxAttributes::getEditingGroupId() {
Shinya Kitaoka 120a6e
  if (!isGrouped() || m_groupSelector + 1 >= m_groupId.size()) return -1;
Shinya Kitaoka 120a6e
  return m_groupId[m_groupSelector + 1];
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::wstring TFxAttributes::getEditingGroupName() {
Shinya Kitaoka 120a6e
  if (!isGrouped() || m_groupSelector + 1 >= m_groupName.size()) return L"";
Shinya Kitaoka 120a6e
  return m_groupName[m_groupSelector + 1];
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TFxAttributes::removeFromAllGroup() {
Shinya Kitaoka 120a6e
  m_groupId.clear();
Shinya Kitaoka 120a6e
  m_groupName.clear();
Shinya Kitaoka 120a6e
  m_groupSelector = -1;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TFxAttributes::closeAllGroups() {
Shinya Kitaoka 120a6e
  if (isGroupEditing()) m_groupSelector = m_groupId.size() - 1;
Toshihiro Shimizu 890ddd
}