void IConnectionLoader::addConnection(
        VertexMap& vertices, SystemTypeGetter* info,
        int from, int to)
{
    TypeSet tags = TypeSet();
    addConnection(vertices, info, from, to, tags);
}
示例#2
0
TypeSet getGreatestCommonSubtypes(const TypeSet& set) {

    // handle the empty set
    if (set.empty()) return set;

    // handle the all set => empty set (since no common sub-type)
    if (set.isAll()) return TypeSet();

    TypeSet res;
    auto it = set.begin();
    res.insert(*it);
    ++it;

    // refine sub-set step by step
    for(;it != set.end(); ++it) {
        TypeSet tmp;
        for(const Type& cur : res) {
            tmp.insert(getGreatestCommonSubtypes(cur, *it));
        }
        res = tmp;
    }

    // done
    return res;
}
示例#3
0
std::vector<ArgKind> Registry::getAcceptedCompletionTypes(
    ArrayRef<std::pair<MatcherCtor, unsigned>> Context) {
  ASTNodeKind InitialTypes[] = {
      ASTNodeKind::getFromNodeKind<Decl>(),
      ASTNodeKind::getFromNodeKind<QualType>(),
      ASTNodeKind::getFromNodeKind<Type>(),
      ASTNodeKind::getFromNodeKind<Stmt>(),
      ASTNodeKind::getFromNodeKind<NestedNameSpecifier>(),
      ASTNodeKind::getFromNodeKind<NestedNameSpecifierLoc>(),
      ASTNodeKind::getFromNodeKind<TypeLoc>()};

  // Starting with the above seed of acceptable top-level matcher types, compute
  // the acceptable type set for the argument indicated by each context element.
  std::set<ArgKind> TypeSet(std::begin(InitialTypes), std::end(InitialTypes));
  for (const auto &CtxEntry : Context) {
    MatcherCtor Ctor = CtxEntry.first;
    unsigned ArgNumber = CtxEntry.second;
    std::vector<ArgKind> NextTypeSet;
    for (const ArgKind &Kind : TypeSet) {
      if (Kind.getArgKind() == Kind.AK_Matcher &&
          Ctor->isConvertibleTo(Kind.getMatcherKind()) &&
          (Ctor->isVariadic() || ArgNumber < Ctor->getNumArgs()))
        Ctor->getArgKinds(Kind.getMatcherKind(), ArgNumber, NextTypeSet);
    }
    TypeSet.clear();
    TypeSet.insert(NextTypeSet.begin(), NextTypeSet.end());
  }
  return std::vector<ArgKind>(TypeSet.begin(), TypeSet.end());
}
示例#4
0
TypeSet getGreatestCommonSubtypes(const Type& a, const Type& b) {

    // make sure they are in the same type environment
    assert(a.getTypeEnvironment().isType(a) && a.getTypeEnvironment().isType(b));

    // if they are equal it is easy
    if (a == b) {
        return TypeSet(a);
    }

    // equally simple - check whether one is a sub-type of the other
    if (isSubtypeOf(a,b)) {
        return TypeSet(a);
    }
    if (isSubtypeOf(b,a)) {
        return TypeSet(b);
    }

    // last option: if both are unions with common sub-types
    TypeSet res;
    if (isUnion(a) && isUnion(b)) {
        // collect common sub-types of union types

        struct collector : public TypeVisitor<void> {
            const Type& b;
            TypeSet& res;
            collector(const Type& b, TypeSet& res) : b(b), res(res) {}
            void visit(const Type& type) const {
                if (isSubtypeOf(type, b)) {
                    res.insert(type);
                } else {
                    TypeVisitor<void>::visit(type);
                }
            }
            void visitUnionType(const UnionType& type) const {
                for(const auto& cur : type.getElementTypes()) visit(*cur);
            }
        };

        // collect all common sub-types
        collector(b,res).visit(a);
    }

    // otherwise there is no common super type
    return res;
}
示例#5
0
TypeSet getLeastCommonSupertypes(const Type& a, const Type& b) {

    // make sure they are in the same type environment
    assert(a.getTypeEnvironment().isType(a) && a.getTypeEnvironment().isType(b));

    // if they are equal it is easy
    if (a == b) {
        return TypeSet(a);
    }

    // equally simple - check whether one is a sub-type of the other
    if (isSubtypeOf(a,b)) {
        return TypeSet(b);
    }
    if (isSubtypeOf(b,a)) {
        return TypeSet(a);
    }

    // harder: no obvious relation => hard way
    TypeSet superTypes;
    TypeSet all = a.getTypeEnvironment().getAllTypes();
    for(const Type& cur : all) {
        if (isSubtypeOf(a, cur) && isSubtypeOf(b, cur)) {
            superTypes.insert(cur);
        }
    }

    // filter out non-least super types
    TypeSet res;
    for(const Type& cur : superTypes) {
        bool least = !any_of(superTypes, [&](const Type& t) {
                return t != cur && isSubtypeOf(t, cur);
                });
        if (least) res.insert(cur);
    }

    return res;

}
示例#6
0
inline TypeSet TypeSetGenerator()
{
    return TypeSet({&typeid(T)...});
}
示例#7
0
GraphBox::GraphBox(GraphWindow3 *graphw, const wxString & title)
	//: ParamBox(NULL, title, wxDefaultPosition, wxSize(450, 450), "Axes", 0)
	: wxDialog(NULL, -1, title, wxDefaultPosition, wxSize(250, 600),
	wxFRAME_FLOAT_ON_PARENT | wxFRAME_TOOL_WINDOW | wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX | wxRESIZE_BORDER)
{
	int i;
	int labelwidth, numwidth;
	graphwin = graphw; 
	diagbox = graphwin->mainwin->diagbox;

	wxString text;

	ostype = GetSystem();

	buttonheight = 23;
	boxfont = wxFont(8, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma");
	confont = wxFont(8, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma");
	if(ostype == Mac) {
		buttonheight = 25;
		boxfont = wxFont(12, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma");
		confont = wxFont(10, wxFONTFAMILY_SWISS, wxNORMAL, wxNORMAL, false, "Tahoma");
	}
	column = 0;

	panel = new ToolPanel(this, wxDefaultPosition, wxDefaultSize);
	panel->SetFont(boxfont);
	mainbox = new wxBoxSizer(wxVERTICAL);
	panel->SetSizer(mainbox);

	paramset = new ParamSet(panel);
	boxout = new BoxOut(NULL, graphwin->mainwin->diagbox, "Axis Panel"); 
	parambox = new wxBoxSizer(wxHORIZONTAL);

	labelwidth = 40;
	numwidth = 50;
	if(ostype == Mac) labelwidth = 50;
	graph = graphwin->graphset[0]->plot[0];
	paramset->AddNum("xlabels", "X Ticks", (double)graph->xlabels, 0, labelwidth, numwidth);
	paramset->AddNum("xstep", "X Step", graph->xstep, 1, labelwidth, numwidth);
	paramset->AddNum("ylabels", "Y Ticks", (double)graph->ylabels, 0, labelwidth, numwidth);
	paramset->AddNum("ystep", "Y Step", graph->ystep, 1, labelwidth, numwidth);
	wxBoxSizer *tickparams = ParamLayout(2);

	wxStaticBoxSizer *xradbox = new wxStaticBoxSizer(wxVERTICAL, panel, "X Tick Mode");
	xrad[0] = new wxRadioButton(panel, 0, "Count", wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
	xrad[1] = new wxRadioButton(panel, 1, "Step");
	xradbox->Add(xrad[0], 1, wxTOP | wxBOTTOM, 3);
	xradbox->Add(xrad[1], 1, wxTOP | wxBOTTOM, 3);
	xrad[graph->xtickmode]->SetValue(true);

	wxStaticBoxSizer *yradbox = new wxStaticBoxSizer(wxVERTICAL, panel, "Y Tick Mode");
	yrad[0] = new wxRadioButton(panel, 2, "Count", wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
	yrad[1] = new wxRadioButton(panel, 3, "Step");
	yradbox->Add(yrad[0], 1, wxTOP | wxBOTTOM, 3);
	yradbox->Add(yrad[1], 1, wxTOP | wxBOTTOM, 3);
	yrad[graph->ytickmode]->SetValue(true);

	wxBoxSizer *radbox = new wxBoxSizer(wxHORIZONTAL);
	radbox->Add(xradbox, 1, wxALL, 5);
	radbox->Add(yradbox, 1, wxALL, 5);

	numwidth = 50;

	paramset->AddNum("xshift", "XShift", graph->xshift, 2, labelwidth, numwidth);
	paramset->AddNum("xsample", "Sample", graph->xsample, 0, labelwidth, numwidth);
	paramset->AddNum("xplot", "Width", graph->xplot, 0, labelwidth, numwidth);
	paramset->AddNum("xlabelgap", "X Gap", graph->xlabelgap, 0, labelwidth, numwidth);
	paramset->AddNum("xscale", "XScale", graph->xunitscale, 3, labelwidth, numwidth);
	paramset->AddNum("xdscale", "XDScale", graph->xunitdscale, 1, labelwidth, numwidth);
	paramset->AddNum("yplot", "Height", graph->yplot, 0, labelwidth, numwidth);
	paramset->AddNum("ylabelgap", "Y Gap", graph->ylabelgap, 0, labelwidth, numwidth);
	wxBoxSizer *plotparams = ParamLayout(2);

	paramset->AddNum("labelfontsize", "Font Size", graph->labelfontsize, 2, 50);
	clipcheck = new wxCheckBox(panel, ID_clipmode, "Clip");
	clipcheck->SetFont(confont);
	clipcheck->SetValue(graph->clipmode);
	wxBoxSizer *fontparams = new wxBoxSizer(wxHORIZONTAL);
	fontparams->Add(paramset->GetCon("labelfontsize"), 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL);
	fontparams->AddSpacer(5);
	fontparams->Add(clipcheck, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL);
	paramset->currlay++;

	linecheck = new wxCheckBox(panel, ID_line, "");
	linecheck->SetFont(confont);
	linecheck->SetValue(graph->linemode);

	scattercheck = new wxCheckBox(panel, ID_scatter, "");
	scattercheck->SetFont(confont);
	scattercheck->SetValue(graph->scattermode);

	//wxBoxSizer *checkbox = new wxBoxSizer(wxHORIZONTAL);
	//scatterparams->Add(paramset->GetCon("scattersize"), 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL);
	//scatterparams->AddSpacer(5);
	//checkbox->Add(linecheck, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL);
	//checkbox->Add(scattercheck, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL);
	//paramset->currlay++;

	//wxGridSizer *plotgrid = new wxFlexGridSizer(2, 5, 5);
	//plotgrid->Add(paramset->GetCon("labelfontsize"), 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxST_NO_AUTORESIZE);
	//plotgrid->Add(clipcheck, 0, wxALIGN_CENTRE_VERTICAL);
	//plotgrid->Add(paramset->GetCon("scattersize"), 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxST_NO_AUTORESIZE);
	//plotgrid->Add(scattercheck, 0, wxALIGN_CENTRE_VERTICAL);

	strokepicker = new wxColourPickerCtrl(panel, 0, graph->strokecolour, wxDefaultPosition, wxSize(70, 25), wxCLRP_USE_TEXTCTRL);
	paramset->AddNum("plotstroke", "Stroke", graph->plotstroke, 2, labelwidth);
	wxBoxSizer *strokebox = new wxBoxSizer(wxHORIZONTAL);
	//wxStaticText *label = new wxStaticText(panel, wxID_ANY, "Stroke");
	//label->SetFont(confont);
	//colourbox->Add(label, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 5);
	strokebox->Add(paramset->con[paramset->GetID("plotstroke")], wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 5);
	paramset->currlay++;
	strokebox->Add(linecheck, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 5);
	strokebox->Add(strokepicker);

	fillpicker = new wxColourPickerCtrl(panel, 0, graph->fillcolour, wxDefaultPosition, wxSize(70, 25), wxCLRP_USE_TEXTCTRL);
	paramset->AddNum("scattersize", "Scatter Size", graph->scattersize, 2, labelwidth);
	wxBoxSizer *fillbox = new wxBoxSizer(wxHORIZONTAL);
	fillbox->Add(paramset->con[paramset->GetID("scattersize")], wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 5);
	paramset->currlay++;
	fillbox->Add(scattercheck, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 5);
	fillbox->Add(fillpicker);

	typeset = TypeSet();
	typeset.Add("Line", 5);
	typeset.Add("Line with X data", 2);
	typeset.Add("Line with Sampling", 6);
	typeset.Add("Scatter with Sampling", 8);
	typeset.Add("Bar", 7);
	typeset.Add("Histogram", 1);
	typeset.Add("Spike Rate", 3);

	/*
	typestrings[0] = "Line";
	typestrings[1] = "Line with Sampling";
	typestrings[2] = "Scatter with Sampling";
	typestrings[3] = "Bar";
	typestrings[4] = "Histogram";
	typestrings[5] = "Spike Rate";*/

	typechoice = new wxChoice(panel, 0, wxDefaultPosition, wxSize(150, -1), typeset.numtypes, typeset.names);
	typechoice->SetSelection(typeset.GetIndex(graph->type));
	//typechoice->SetSelection(0);
	wxBoxSizer *typebox = new wxBoxSizer(wxHORIZONTAL);
	wxStaticText *label = new wxStaticText(panel, wxID_ANY, "Plot Type");
	label->SetFont(confont);
	typebox->Add(label, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 5);
	typebox->AddSpacer(5);
	typebox->Add(typechoice);
	

	paramset->AddText("gname", "Name", graph->gname, labelwidth);
	paramset->AddText("xtag", "X Label", graph->xtag, labelwidth);
	paramset->AddText("ytag", "Y Label", graph->ytag, labelwidth);
	wxBoxSizer *labelparams = ParamLayout(1);

	//wxBoxSizer *gapparams = ParamLayout(2);

	wxBoxSizer *buttonbox = new wxBoxSizer(wxHORIZONTAL);
	wxButton *okButton = new wxButton(panel, wxID_OK, "Ok", wxDefaultPosition, wxSize(65, 30));
	wxButton *printButton = new wxButton(panel, ID_Print, "Export EPS", wxDefaultPosition, wxSize(65, 30));
	wxButton *closeButton = new wxButton(panel, wxID_CANCEL, "Close", wxDefaultPosition, wxSize(65, 30));
	buttonbox->Add(okButton, 1);
	buttonbox->Add(printButton, 1, wxLEFT, 5);
	buttonbox->Add(closeButton, 1, wxLEFT, 5);

	//status = StatusBar();
	status = new wxStaticText(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE|wxBORDER_DOUBLE|wxST_NO_AUTORESIZE);
	status->SetFont(confont);
	wxBoxSizer *statusbox = new wxBoxSizer(wxHORIZONTAL);
	statusbox->Add(status, 1, wxEXPAND);

	mainbox->AddSpacer(5);
	mainbox->Add(tickparams, 1, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 0);
	mainbox->AddStretchSpacer();
	mainbox->Add(radbox, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 5);
	mainbox->AddStretchSpacer();
	mainbox->Add(plotparams, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 0);
	mainbox->AddStretchSpacer();
	mainbox->Add(fontparams, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 0);
	//mainbox->Add(scatterparams, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 0);
	//mainbox->Add(plotgrid, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 0);
	mainbox->AddStretchSpacer();
	mainbox->Add(strokebox, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 5);
	mainbox->Add(fillbox, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 5);
	mainbox->AddStretchSpacer();
	mainbox->Add(typebox, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 5);
	mainbox->AddStretchSpacer();
	mainbox->Add(labelparams, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 0);
	//mainbox->Add(gapparams, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxALL, 0);
	mainbox->AddStretchSpacer();
	mainbox->Add(buttonbox, 0, wxALIGN_CENTRE | wxTOP | wxBOTTOM, 5);
	mainbox->Add(statusbox, 0, wxEXPAND);

	panel->Layout();

	Connect(wxEVT_CHOICE, wxCommandEventHandler(GraphBox::OnChoice));
	Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(GraphBox::OnRadio));
	Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(GraphBox::OnOK));
	Connect(wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED, wxCloseEventHandler(GraphBox::OnClose));
	Connect(ID_Print, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(GraphBox::OnPrint));
	Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(GraphBox::OnOK));
	Connect(wxEVT_SIZE, wxSizeEventHandler(GraphBox::OnSize));
	Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(GraphBox::OnClose));

	//ShowModal();
	//Destroy(); 
	Show();
}