예제 #1
0
파일: List.c 프로젝트: chilininsd/bridge
ListPtr restoreList(char *saveFile)
{
	int size;
	FILE *fin;
	ListPtr list;
	NodePtr node;
	char errmsg[MAX_MSG_LENGTH];

	if (saveFile == NULL) return NULL;
	if (strlen(saveFile) == 0) return NULL;
	fin = fopen(saveFile, "r");
	if (!fin) {
		sprintf(errmsg, "restoreList: %s",saveFile);
		perror(errmsg);
		return NULL;
	}

	fread(&size, sizeof(int), 1, fin);
	if (size <= 0) return NULL;
	printf("restore: list size = %d\n", size);
	list = createList();

	while (size > 0) {
		node = restoreNode(fin);
		addAtFront(list, node);
		size--;
	}

	fclose(fin);
	return list;
}
예제 #2
0
파일: GraphView.cpp 프로젝트: tulip5/tulip
//----------------------------------------------------------------
void GraphView::addNode(const node n) {
  assert(getRoot()->isElement(n));

  if (!isElement(n)) {
    if (!getSuperGraph()->isElement(n))
      getSuperGraph()->addNode(n);

    restoreNode(n);
  }
}
예제 #3
0
void
FlowScene::
load()
{
  _connections.clear();
  _nodes.clear();

  //-------------

  QString fileName =
    QFileDialog::getOpenFileName(nullptr,
                                 tr("Open Flow Scene"),
                                 QDir::homePath(),
                                 tr("Flow Scene Files (*.flow)"));

  if (!QFileInfo::exists(fileName))
    return;

  QFile file(fileName);

  if (!file.open(QIODevice::ReadOnly))
    return;

  QDataStream in(&file);

  qint64 nNodes;
  in >> nNodes;

  for (unsigned int i = 0; i < nNodes; ++i)
  {
    Properties p;
    auto &values = p.values();
    in >> values;

    restoreNode(p);
  }

  qint64 nConnections;
  in >> nConnections;

  for (unsigned int i = 0; i < nConnections; ++i)
  {
    Properties p;
    auto &values = p.values();
    in >> values;

    restoreConnection(p);
  }
}
예제 #4
0
파일: GraphView.cpp 프로젝트: tulip5/tulip
//----------------------------------------------------------------
node GraphView::addNode() {
  node tmp = getSuperGraph()->addNode();
  restoreNode(tmp);
  return tmp;
}