コード例 #1
0
ファイル: ConnectionParts_Method.cpp プロジェクト: SEDS/GAME
//
// evaluate
//
Value * ConnectionParts_Method::evaluate (Ocl_Context &res, GAME::Mga::Object caller)
{
  GAME::Mga::Model mod = GAME::Mga::Model::_narrow (caller);

  std::vector <GAME::Mga::Connection> parts;
  std::vector <std::string> rolenames;
  bool flag = false;

  // Verifying if role_ is a valid containment role
  std::vector <GAME::Mga::Meta::Role> all;
  mod->meta ()->roles (all);
  std::vector <GAME::Mga::Meta::Role>::iterator
    it = all.begin (), ite = all.end ();

  for (; it != ite; ++it)
    rolenames.push_back ((*it)->name ());

  std::vector <std::string>::iterator
    st = rolenames.begin (), ste = rolenames.end ();

  for (; st != ste; ++st)
  {
    if ((*st) == this->role_)
      flag = true;
  }

  // Continue if the role is valid
  if (flag)
  {
    GAME::Mga::Meta::Role target_metarole = mod->meta ()->role (this->role_);

    // Setting the target metarole in the model intelligence context
    // only if it doesn't already exist in the list
    std::vector <GAME::Mga::Meta::Role>::iterator
      roleit = res.target_metaroles.begin (), roleit_end = res.target_metaroles.end ();

    bool exists = false;

    for (; roleit != roleit_end; ++ roleit)
    {
      if ((*roleit)->name () == target_metarole->name ())
        exists = true;
    }

    if (!exists)
      res.target_metaroles.push_back (target_metarole);
  
    GAME::Mga::Meta::FCO temp = target_metarole->kind ();

    // Collecting children only if the type of element is Connection
    if (temp->type () == OBJTYPE_CONNECTION)
      mod->children (temp->name (), parts);
  }

  return new Collection_Value_T <GAME::Mga::Connection> (parts);


}
コード例 #2
0
ファイル: Lesser_Expr.cpp プロジェクト: SEDS/GAME
//
// list delete
//
bool Lesser_Expr::list_delete (GAME::Mga::Model & obj, 
                               size_t count, 
                               GAME::Mga::Meta::FCO & metatype, 
                               GAME::Mga::Meta::Role & metarole)
{
    std::vector <GAME::Mga::FCO> elements;
  GAME::Mga::FCO select;
  obj->children (elements);

   std::vector <GAME::Mga::FCO> qual_fcos;

  std::vector <GAME::Mga::FCO>::iterator
    it = elements.begin (), it_end = elements.end ();

  for (; it != it_end; ++it)
  {
    if ((*it)->meta ()->name () == metatype->name ())
      qual_fcos.push_back ((*it));
  }

  for (size_t i = 0; i < count; ++i)
  {
    AFX_MANAGE_STATE (::AfxGetStaticModuleState ());
    // Create the dialog and pass in the data
    using GAME::Dialogs::Selection_List_Dialog_T;
    Selection_List_Dialog_T <GAME::Mga::FCO> dlg (0, ::AfxGetMainWnd (), 0);
    dlg.title ("Please select the Model/Atom for deletion");
    dlg.directions ("Target evaluator");
    dlg.insert (qual_fcos);

    if (IDOK != dlg.DoModal ())
      return false;

    select = dlg.selection ();

    if (!select.is_nil ())
    {
      select->destroy ();
    }
  }
  return true;
}
コード例 #3
0
//
// create
//
BOOL PICML_Enum_Data_Value_Control::
Create (DWORD style, const RECT & rect, CWnd * parent, UINT id)
{
  // Calculate the size of the control to compensate the list.
  LOGFONT logfont;
  parent->GetFont ()->GetLogFont (&logfont);
  size_t font_height = abs (logfont.lfHeight);

  CRect combo_rect (rect.left,
                    rect.top,
                    rect.right,
                    rect.bottom + font_height * 5);

  // Update the style.
  style |= CBS_DROPDOWNLIST | CBS_SORT;

  if (PICML_Simple_Data_Value_Control <CComboBox>::Create (style, combo_rect, parent, id) == FALSE)
    return FALSE;

  // Populate the control with the enumeration values.
  GAME::Mga::Reference ref = GAME::Mga::Reference::_narrow (this->value_);
  GAME::Mga::Model e = GAME::Mga::Model::_narrow (ref->refers_to ());
  std::vector <GAME::Mga::Atom> values;

  if (e->children ("EnumValue", values))
    std::for_each (values.begin (),
                   values.end (),
                   boost::bind (&PICML_Enum_Data_Value_Control::visit_enum_value,
                                this,
                                _1));

  // Select the current value.
  const std::string selection =
    this->value_->attribute (attr::Value)->string_value ();

  if (!selection.empty ())
    this->SelectString (-1, selection.c_str ());

  return TRUE;
}
コード例 #4
0
//
// initialize_ports
//
int Component_Decorator_Impl::
initialize_ports (const std::string & aspect_name,
                  const GAME::Mga::FCO_in fco,
                  GAME::Mga::graphics::Image_Resolver * resolver)
{
  GAME::Mga::Model model = GAME::Mga::Model::_narrow (fco);
  GAME::Mga::Meta::Model metamodel = model->meta ();

  // Get the target aspect.
  GAME::Mga::Meta::Aspect aspect = metamodel->aspect (aspect_name);

  if (aspect.is_nil ())
    return 0;

  // Select all the FCO elements in the specified aspect.
  std::vector <GAME::Mga::FCO> ports;

  if (model->children (aspect, ports) == 0)
    return 0;

  std::vector <GAME::Mga::FCO>::iterator
    iter = ports.begin (), iter_end = ports.end ();

  GAME::Mga::Part part;
  std::string icon_filename, filename;
  Gdiplus::Image * image = 0;

  for (; iter != iter_end; ++ iter)
  {
    // First, let's determine if the element is indeed a port. If
    // it is not a port, let's just continue to the next iteration.
    part = (*iter)->part (aspect);

    if (!part.meta ()->is_linked ())
      continue;

    // Load the icon for the specified element.
    icon_filename = (*iter)->meta ()->registry_value ("icon");

    if (resolver->lookup_icon (icon_filename, filename))
      this->port_bitmaps_.associate_image (*iter, filename, image);

    // Determine what side of the model this port should
    // be displayed.
    long x, y;
    part.get_location (x, y);


    // Allocate a new port for the FCO.
    GAME::Mga::Point location (x, y);

    using GAME::Mga::Port_Decorator;
    Port_Decorator * port = new Port_Decorator (*iter,
                                                image,
                                                (*iter)->name (),
                                                location);

    if (x < 200)
    {
      this->l_ports_.push_back (port);
      port->alignment (Port_Decorator::ALIGNMENT_LEFT);
    }
    else
    {
      this->r_ports_.push_back (port);
      port->alignment (Port_Decorator::ALINGMENT_RIGHT);
    }
  }

  // We need to get all the ports that we inherit.
  std::vector <GAME::Mga::Reference> inherits;

  if (model->children ("ComponentInherits", inherits))
  {
    GAME::Mga::FCO refers_to = inherits.front ()->refers_to ();

    if (!refers_to.is_nil ())
      this->initialize_ports ("InterfaceDefinition", refers_to, resolver);
  }

  return 0;
}