Ejemplo n.º 1
0
void ViewItemSet::findItemSet(ItemSet &its,bool reb){
	if(reb)
		this->reBuildTree(its);
	getLeave(getGlMainWidget()->getGraph(),leave);
	Graph *graph=getGlMainWidget()->getGraph();
	BooleanProperty *select = graph->getLocalProperty<BooleanProperty>("viewSelection");
	DoubleProperty *frequent = graph->getLocalProperty<DoubleProperty>("viewFrequent");
    vector<node> temp;
    vector<edge> path;
    double fr=0.0;
  	graph->holdObservers();
	select->setAllNodeValue(false);
	select->setAllEdgeValue(false);
	 fr=0;
	for(int i=0;i<this->leave.size();i++){
    	if(checkItemSet(leave[i],temp,path,its)){
			for(int j=0;j<temp.size();j++)
    	         select->setNodeValue(temp[j],true);

			for(int k=0;k<path.size();k++)
			     select->setEdgeValue(path[k],true);

			fr=fr+frequent->getNodeValue(leave[i]);
		   }

		  temp.clear();
          path.clear();
	}

	emit freqItemSet(fr);
    leave.clear();
	graph->unholdObservers();
}
//=================================================================================
bool InducedSubGraphSelection::run() {
  result->setAllNodeValue(false);
  result->setAllEdgeValue(false);
  BooleanProperty *entrySelection = NULL;

  if (dataSet!=NULL)
    dataSet->get("Nodes", entrySelection);

  if (entrySelection == NULL)
    entrySelection = graph->getProperty<BooleanProperty>("viewSelection");

  Iterator<node> *itN = graph->getNodes();

  while (itN->hasNext()) {
    node itn=itN->next() ;

    if (entrySelection->getNodeValue(itn)) {
      result->setNodeValue(itn, true);
      Iterator<edge> *itE = graph->getOutEdges(itn);

      while (itE->hasNext()) {
        edge e = itE->next();
        node target = graph->target(e);

        if (entrySelection->getNodeValue(target))
          result->setEdgeValue(e, true);
      }

      delete itE;
    }
  }

  delete itN;
  return true;
}
Ejemplo n.º 3
0
GraphTableWidget::SelectionStatus GraphTableWidget::selectionStatus(const QModelIndexList& elementsIndexes)const {
  BooleanProperty* selectionProperty = _graph->getProperty<BooleanProperty>("viewSelection");
  set<unsigned int> elements = indexListToIds(elementsIndexes);
  bool allSelected = true;
  bool allUnselected = true;

  for(set<unsigned int>::iterator it = elements.begin(); it != elements.end(); ++it) {
    if(_type == NODE) {
      if(selectionProperty->getNodeValue(node(*it))) {
        allUnselected = false;
      }
      else {
        allSelected = false;
      }
    }
    else {
      if(selectionProperty->getEdgeValue(edge(*it))) {
        allUnselected = false;
      }
      else {
        allSelected = false;

      }
    }
  }

  return allSelected?Selected:(allUnselected?Unselected:PartiallySelected);
}
Ejemplo n.º 4
0
bool getNodeEnclosingCircle(Circlef &circle, GlGraphInputData *inputData, node n) {
    BooleanProperty *selection = new BooleanProperty(inputData->getGraph());
    selection->setAllNodeValue(false);
    selection->setNodeValue(n, true);
    circle = getEnclosingCircle(inputData, selection);
    return true;
}
Ejemplo n.º 5
0
Iterator<unsigned int> *ParallelCoordinatesGraphProxy::getUnselectedDataIterator() {
  BooleanProperty *viewSelection = static_cast<BooleanProperty *>(getProperty("viewSelection"));

  if (getDataLocation() == NODE) {
    return new ParallelCoordinatesDataIterator<node>(viewSelection->getNodesEqualTo(false));
  } else {
    return new ParallelCoordinatesDataIterator<edge>(viewSelection->getEdgesEqualTo(false));
  }
}
Ejemplo n.º 6
0
bool getEdgeEnclosingCircle(Circlef &circle, GlGraphInputData *inputData, edge e) {
    BooleanProperty *selection = new BooleanProperty(inputData->getGraph());
    selection->setAllEdgeValue(false);
    selection->setEdgeValue(e, true);

    if (inputData->getElementLayout()->getEdgeValue(e).size() == 0)
        return false;

    circle = getEnclosingCircle(inputData, selection);
    return true;
}
Ejemplo n.º 7
0
void ParallelCoordinatesGraphProxy::selectHighlightedElements() {
  // initialize selection
  BooleanProperty *selectionProp = getProperty<BooleanProperty>("viewSelection");
  selectionProp->setAllNodeValue(false);
  selectionProp->setAllEdgeValue(false);

  set<unsigned int>::iterator it;

  for (it = highlightedElts.begin(); it != highlightedElts.end(); ++it) {
    setDataSelected(*it, true);
  }
}
Ejemplo n.º 8
0
//-----------------------------------------------------------------------------
std::string RootHistCnv::RConverter::convertId(const std::string& id ) const
//-----------------------------------------------------------------------------
{
  bool forced = false;
  if ( id.size() > 0 && isdigit(id[0]) ) {
    try {
      BooleanProperty tmp;
      tmp.assign(SmartIF<IProperty>(conversionSvc())->getProperty( "ForceAlphaIds"));
      forced = (bool)tmp;
    }
    catch ( ... ) { }
  }
  if (forced )  return std::string("h") + id;
  else          return id;
}
Ejemplo n.º 9
0
map<int, MyNode *> *
convertGraph2Map(Graph *graph)
{
  Graph *grille = graph->getSubGraph(2);
  if(!grille)
    grille = graph;
  LayoutProperty *layout = graph->getLocalProperty<LayoutProperty>("viewLayout");
  BooleanProperty *fixed = graph->getProperty<BooleanProperty>("fixed nodes");
  BooleanProperty *bordure = graph->getProperty<BooleanProperty>("viewSelection");

  map<int,MyNode *> all_nodes;

  // Boucle sur tous les noeuds
  Iterator<node> *itNodes = grille->getNodes();
  while(itNodes->hasNext()) 
    {
      node n = itNodes->next();

      if(all_nodes[n.id] == NULL)
	{
	  Coord c = layout->getNodeValue(n);
	  bool res = !(fixed->getNodeValue(n)) && !(bordure->getNodeValue(n));
	  all_nodes[n.id] = new MyNode(n, res, c); 
	}

      MyNode *pn = all_nodes[n.id];

      // Boucle sur tous les voisins du noeud courant
      Iterator<node> *itN = grille->getInOutNodes(n);
      while(itN->hasNext())
	{
	  node n = itN->next();
	  if(all_nodes[n.id] == NULL)
	    {
	      Coord c = layout->getNodeValue(n);
	      bool res = !(fixed->getNodeValue(n)) && !(bordure->getNodeValue(n));
	      all_nodes[n.id] = new MyNode(n, res, c); 
	    }
	  pn->getVoisin()->push_back(all_nodes[n.id]);
	}
      delete itN;
    }
  delete itNodes;

  Iterator <edge> *itE = grille->getEdges();
  while (itE->hasNext()) 
    {
      edge current_edge = itE->next();
      if (bordure->getEdgeValue(current_edge)) 
	{
	  pair<node, node> nodes = grille->ends(current_edge);
	  all_nodes[nodes.first.id]->setMobile(false);
	  all_nodes[nodes.second.id]->setMobile(false);  
	}
    }
  delete itE;

  return new map<int, MyNode *>(all_nodes);
}
bool ReverseEdges::run() {
  BooleanProperty* selection = NULL;

  if (dataSet)
    dataSet->get<BooleanProperty*>("selection", selection);

  Iterator<edge>* ite =
    selection ? selection->getEdgesEqualTo(true) : graph->getEdges();

  int step = 0, max_step = graph->numberOfEdges();
  edge e;
  forEach(e, ite) {
    if (pluginProgress && ((++step % 10) == 0)) {
      ProgressState state = pluginProgress->progress(step, max_step);

      if (state != TLP_CONTINUE)
        return state != TLP_CANCEL;
    }

    graph->reverse(e);
  }

  return true;
}
Ejemplo n.º 11
0
void ModelerUserInterface::ButtonCallback(Fl_Button* button, void* p) {
	BooleanProperty* prop = (BooleanProperty*) p;
	prop->setValue(button->value() ? true : false);
	ModelerUserInterface::getInstance()->m_modelerView->redraw();
}
Ejemplo n.º 12
0
void LabelsRenderer::renderGraphNodesLabels(Graph *graph, const Camera &camera, const Color &selectionColor) {

  initFont();

  BooleanProperty *viewSelection = graph->getProperty<BooleanProperty>("viewSelection");
  ColorProperty *viewLabelColor = graph->getProperty<ColorProperty>("viewLabelColor");
  StringProperty *viewLabel = graph->getProperty<StringProperty>("viewLabel");

  Vec4i viewport = camera.getViewport();

  vector<vector<Vec2f> > renderedLabelsScrRect;
  vector<BoundingBox> renderedLabelsScrBB;

  NVGcontext* vg = NanoVGManager::instance()->getNanoVGContext();

  nvgBeginFrame(vg, camera.getViewport()[0], camera.getViewport()[1], camera.getViewport()[2], camera.getViewport()[3], 1.0);

  for (vector<node>::iterator it = _labelsToRender[graph].begin() ; it != _labelsToRender[graph].end() ; ++it) {

    if (_nodeLabelAspectRatio[graph].find(*it) == _nodeLabelAspectRatio[graph].end()) {
      continue;
    }

    BoundingBox nodeBB = labelBoundingBoxForNode(graph, *it);

    BoundingBox textBB = getLabelRenderingBoxScaled(nodeBB, _nodeLabelAspectRatio[graph][*it]);

    if (!_labelsScaled) {

      adjustTextBoundingBox(textBB, camera, _minSize, _maxSize, _nodeLabelNbLines[graph][*it]);
    }

    bool canRender = true;

    if (_occlusionTest) {

      if (!camera.hasRotation()) {
        BoundingBox textScrBB;
        textScrBB.expand(Vec3f(computeScreenPos(camera.transformMatrixBillboard(), viewport, textBB[0]), 0));
        textScrBB.expand(Vec3f(computeScreenPos(camera.transformMatrixBillboard(), viewport, textBB[1]), 0));

        for (size_t i = 0 ; i < renderedLabelsScrBB.size() ; ++i) {
          if (textScrBB.intersect(renderedLabelsScrBB[i])) {
            canRender = false;
            break;
          }
        }

        if (canRender) {
          renderedLabelsScrBB.push_back(textScrBB);
        }

      } else {
        vector<Vec2f> textScrRect;
        textScrRect.push_back(computeScreenPos(camera.transformMatrix(), viewport, textBB[0]));
        textScrRect.push_back(computeScreenPos(camera.transformMatrix(), viewport, Vec3f(textBB[0][0]+textBB.width(), textBB[0][1], textBB[0][2])));
        textScrRect.push_back(computeScreenPos(camera.transformMatrix(), viewport, textBB[1]));
        textScrRect.push_back(computeScreenPos(camera.transformMatrix(), viewport, Vec3f(textBB[0][0], textBB[0][1]+textBB.height(), textBB[0][2])));

        for (size_t i = 0 ; i < renderedLabelsScrRect.size() ; ++i) {
          if (convexPolygonsIntersect(textScrRect, renderedLabelsScrRect[i])) {
            canRender = false;
            break;
          }
        }

        if (canRender) {
          renderedLabelsScrRect.push_back(textScrRect);
        }
      }
    }

    if (canRender) {

      Vec2f textBBMinScr = computeScreenPos(camera.transformMatrix(), viewport, textBB[0]);
      Vec2f textBBMaxScr = computeScreenPos(camera.transformMatrix(), viewport, textBB[1]);
      BoundingBox bb;
      bb.expand(Vec3f(textBBMinScr[0], viewport[3] - textBBMinScr[1]));
      bb.expand(Vec3f(textBBMaxScr[0], viewport[3] - textBBMaxScr[1]));

      renderText(vg, viewLabel->getNodeValue(*it), bb, viewSelection->getNodeValue(*it) ? selectionColor : viewLabelColor->getNodeValue(*it));

    }

  }

  nvgEndFrame(vg);
}
Ejemplo n.º 13
0
void HistogramStatistics::computeInteractor() {
  GlQuantitativeAxis *histoXAxis = histoView->getDetailedHistogram()->getXAxis();
  GlQuantitativeAxis *histoYAxis = histoView->getDetailedHistogram()->getYAxis();

  if (histoYAxis == nullptr) {
    return;
  }

  Graph *graph = histoView->graph();
  string selectedProperty(histoView->getDetailedHistogram()->getPropertyName());

  double sampleStep = histoStatsConfigWidget->getSampleStep();

  graphPropertyValueSet.clear();
  densityEstimationCurvePoints.clear();
  propertyMean = 0;
  propertyStandardDeviation = 0;

  cleanupAxis();

  string propertyType(graph->getProperty(selectedProperty)->getTypename());
  double min, max;

  if (propertyType == "double") {
    if (histoView->getDataLocation() == NODE) {
      min = graph->getProperty<DoubleProperty>(selectedProperty)->getNodeMin();
      max = graph->getProperty<DoubleProperty>(selectedProperty)->getNodeMax();
    } else {
      min = graph->getProperty<DoubleProperty>(selectedProperty)->getEdgeMin();
      max = graph->getProperty<DoubleProperty>(selectedProperty)->getEdgeMax();
    }
  } else {
    if (histoView->getDataLocation() == NODE) {
      min = graph->getProperty<IntegerProperty>(selectedProperty)->getNodeMin();
      max = graph->getProperty<IntegerProperty>(selectedProperty)->getNodeMax();
    } else {
      min = graph->getProperty<IntegerProperty>(selectedProperty)->getEdgeMin();
      max = graph->getProperty<IntegerProperty>(selectedProperty)->getEdgeMax();
    }
  }

  unsigned int nbElements = 0;

  if (histoView->getDataLocation() == NODE) {
    nbElements = graph->numberOfNodes();
    for (auto n : graph->nodes()) {
      double nodeVal;

      if (propertyType == "double") {
        nodeVal = graph->getProperty<DoubleProperty>(selectedProperty)->getNodeValue(n);
      } else {
        nodeVal = graph->getProperty<IntegerProperty>(selectedProperty)->getNodeValue(n);
      }

      graphPropertyValueSet[n.id] = nodeVal;
      propertyMean += nodeVal;
    }

  } else {
    nbElements = graph->numberOfEdges();
    for (auto e : graph->edges()) {
      double edgeVal;

      if (propertyType == "double") {
        edgeVal = graph->getProperty<DoubleProperty>(selectedProperty)->getEdgeValue(e);
      } else {
        edgeVal = graph->getProperty<IntegerProperty>(selectedProperty)->getEdgeValue(e);
      }

      graphPropertyValueSet[e.id] = edgeVal;
      propertyMean += edgeVal;
    }
  }

  propertyMean /= (nbElements);

  for (auto it = graphPropertyValueSet.begin(); it != graphPropertyValueSet.end(); ++it) {
    propertyStandardDeviation += square(it->second - propertyMean);
  }

  propertyStandardDeviation = sqrt(propertyStandardDeviation / (nbElements - 1));

  histoStatsConfigWidget->setMinMaxMeanAndSd(min, max, propertyMean, propertyStandardDeviation);

  if (histoStatsConfigWidget->densityEstimation()) {
    double bandwidth = histoStatsConfigWidget->getBandwidth();

    vector<double> estimatedDensity;
    float maxDensityValue = 0.;

    KernelFunction *kf = kernelFunctionsMap[histoStatsConfigWidget->getKernelFunctionName()];

    for (double val = min; val <= max; val += sampleStep) {
      float fx = 0;

      for (auto it = graphPropertyValueSet.begin(); it != graphPropertyValueSet.end(); ++it) {
        fx += float((*kf)((val - (it->second)) / (bandwidth / 2.)));
      }

      fx *= (1.f / float(graphPropertyValueSet.size() * (bandwidth / 2.)));
      estimatedDensity.push_back(fx);

      if (fx > maxDensityValue) {
        maxDensityValue = fx;
      }
    }

    double val;
    unsigned int i;

    for (val = min, i = 0; val <= max; val += sampleStep, ++i) {
      float x = histoXAxis->getAxisPointCoordForValue(val).getX();
      float y =
          histoYAxis
              ->getAxisPointCoordForValue(
                  (estimatedDensity[i] * (histoView->getDetailedHistogram()->getMaxBinSize())) /
                  maxDensityValue)
              .getY();
      densityEstimationCurvePoints.push_back(Coord(x, y, 0));
    }

    densityAxis = new GlQuantitativeAxis(
        "density", Coord(histoXAxis->getAxisBaseCoord().getX() + histoXAxis->getAxisLength(), 0, 0),
        histoYAxis->getAxisLength(), GlAxis::VERTICAL_AXIS, Color(255, 0, 0), true);
    densityAxis->setAxisParameters(0.0, double(maxDensityValue), 15, GlAxis::RIGHT_OR_ABOVE, true);
    densityAxis->updateAxis();
    densityAxis->addCaption(GlAxis::LEFT, densityAxis->getSpaceBetweenAxisGrads(), false);
  }

  if (histoStatsConfigWidget->displayMeanAndStandardDeviation()) {
    float axisExtension = 2 * histoXAxis->getAxisGradsWidth();
    float y = histoXAxis->getAxisBaseCoord().getY() - axisExtension;
    float axisLength = histoYAxis->getAxisLength() + axisExtension;
    float captionHeight = histoXAxis->getAxisGradsWidth();
    float x = histoXAxis->getAxisPointCoordForValue(propertyMean).getX();
    meanAxis = new GlAxis("m", Coord(x, y, 0), axisLength, GlAxis::VERTICAL_AXIS, Color(255, 0, 0));
    meanAxis->addCaption(GlAxis::LEFT, captionHeight, false);
    x = histoXAxis->getAxisPointCoordForValue(propertyMean + propertyStandardDeviation).getX();
    standardDeviationPosAxis =
        new GlAxis("+sd", Coord(x, y, 0), axisLength, GlAxis::VERTICAL_AXIS, Color(255, 0, 0));
    standardDeviationPosAxis->addCaption(GlAxis::LEFT, captionHeight, false);
    x = histoXAxis->getAxisPointCoordForValue(propertyMean - propertyStandardDeviation).getX();
    standardDeviationNegAxis =
        new GlAxis("-sd", Coord(x, y, 0), axisLength, GlAxis::VERTICAL_AXIS, Color(255, 0, 0));
    standardDeviationNegAxis->addCaption(GlAxis::LEFT, captionHeight, false);

    if (propertyMean - 2 * propertyStandardDeviation > min) {
      x = histoXAxis->getAxisPointCoordForValue(propertyMean + 2 * propertyStandardDeviation)
              .getX();
      standardDeviation2PosAxis =
          new GlAxis("+2sd", Coord(x, y, 0), axisLength, GlAxis::VERTICAL_AXIS, Color(255, 0, 0));
      standardDeviation2PosAxis->addCaption(GlAxis::LEFT, captionHeight, false);
      x = histoXAxis->getAxisPointCoordForValue(propertyMean - 2 * propertyStandardDeviation)
              .getX();
      standardDeviation2NegAxis =
          new GlAxis("-2sd", Coord(x, y, 0), axisLength, GlAxis::VERTICAL_AXIS, Color(255, 0, 0));
      standardDeviation2NegAxis->addCaption(GlAxis::LEFT, captionHeight, false);
    } else {
      standardDeviation2NegAxis = nullptr;
      standardDeviation2PosAxis = nullptr;
    }

    if (propertyMean - 3 * propertyStandardDeviation > min) {
      x = histoXAxis->getAxisPointCoordForValue(propertyMean + 3 * propertyStandardDeviation)
              .getX();
      standardDeviation3PosAxis =
          new GlAxis("+3sd", Coord(x, y, 0), axisLength, GlAxis::VERTICAL_AXIS, Color(255, 0, 0));
      standardDeviation3PosAxis->addCaption(GlAxis::LEFT, captionHeight, false);
      x = histoXAxis->getAxisPointCoordForValue(propertyMean - 3 * propertyStandardDeviation)
              .getX();
      standardDeviation3NegAxis =
          new GlAxis("-3sd", Coord(x, y, 0), axisLength, GlAxis::VERTICAL_AXIS, Color(255, 0, 0));
      standardDeviation3NegAxis->addCaption(GlAxis::LEFT, captionHeight, false);
    } else {
      standardDeviation3NegAxis = nullptr;
      standardDeviation3PosAxis = nullptr;
    }

    if (histoStatsConfigWidget->nodesSelection()) {
      Observable::holdObservers();
      BooleanProperty *viewSelection = graph->getProperty<BooleanProperty>("viewSelection");
      viewSelection->setAllNodeValue(false);
      viewSelection->setAllEdgeValue(false);
      double lowerBound = histoStatsConfigWidget->getSelectionLowerBound();
      double upperBound = histoStatsConfigWidget->getSelectionUpperBound();
      map<unsigned int, double>::iterator pos = find_if(
          graphPropertyValueSet.begin(), graphPropertyValueSet.end(),
          compose_fn(logical_and<bool>(), map_value_greater_equal<unsigned int, double>(lowerBound),
                     map_value_less_equal<unsigned int, double>(upperBound)));

      while (pos != graphPropertyValueSet.end()) {
        if (histoView->getDataLocation() == EDGE) {
          viewSelection->setNodeValue(node(pos->first), true);
        } else {
          viewSelection->setEdgeValue(edge(pos->first), true);
        }

        pos = find_if(++pos, graphPropertyValueSet.end(),
                      compose_fn(logical_and<bool>(),
                                 map_value_greater_equal<unsigned int, double>(lowerBound),
                                 map_value_less_equal<unsigned int, double>(upperBound)));
      }

      Observable::unholdObservers();
    }
  }
}