Esempio n. 1
0
Foam::OFstream::OFstream
(
    const fileName& pathname,
    streamFormat format,
    versionNumber version,
    compressionType compression
)
    :
    OFstreamAllocator(pathname, compression),
    OSstream(*ofPtr_, "OFstream.sinkFile_", format, version, compression),
    pathname_(pathname)
{
    setClosed();
    setState(ofPtr_->rdstate());

    if (!good())
    {
        if (debug)
        {
            Info<< "IFstream::IFstream(const fileName&,"
                "streamFormat format=ASCII,"
                "versionNumber version=currentVersion) : "
                "could not open file for input\n"
                "in stream " << info() << Foam::endl;
        }

        setBad();
    }
    else
    {
        setOpened();
    }

    lineNumber_ = 1;
}
Esempio n. 2
0
//----------------------------------------
void ofxBox2dEdge::updateShape() {
    if(body==NULL) return;
    const b2Transform& xf = body->GetTransform();
    ofPolyline::clear();
    mesh.clear();
    mesh.setUsage(body->GetType()==b2_staticBody?GL_STATIC_DRAW:GL_DYNAMIC_DRAW);
    mesh.setMode(OF_PRIMITIVE_LINE_STRIP);
   
    for (b2Fixture * f = body->GetFixtureList(); f; f = f->GetNext()) {
        b2EdgeShape * edge = (b2EdgeShape*)f->GetShape();
        
        if(edge) {
            ofPolyline::addVertex(worldPtToscreenPt(edge->m_vertex2));
            ofPolyline::addVertex(worldPtToscreenPt(edge->m_vertex1));
            
            mesh.addVertex(ofVec3f(worldPtToscreenPt(edge->m_vertex2)));
            mesh.addVertex(ofVec3f(worldPtToscreenPt(edge->m_vertex1)));
        }
    }
    
    bFlagShapeUpdate = true;
    // Temporary hack to ensure it's flagged as changed, until we
    // switch to OF 0.8.0.
    setClosed(isClosed());
}
Esempio n. 3
0
//----------------------------------------
void ofxBox2dPolygon::triangulate(float resampleAmt, int nPointsInside) {
	
	triangles.clear();
	
	if(size() > 0) {
		
		// copy over the points into a polyline
		ofPolyline polyOutline;
		ofPolyline newPoly;
		
		// make sure to close the polyline and then
		// simplify and resample by spacing...
		setClosed(true);
		if(!bIsSimplified) simplify();
		newPoly = getResampledBySpacing(resampleAmt);
		
		// save the outline...
		polyOutline = newPoly;
		
		// add some random points inside then
		// triangulate the polyline...
		if(nPointsInside!=-1) addRandomPointsInside(newPoly, nPointsInside);
		triangles = triangulatePolygonWithOutline(newPoly, polyOutline);
			
		clear();
		
		// now add back into polyshape
		for (int i=0; i<newPoly.size(); i++) {
			addVertex(newPoly[i]);
		}
	}
	
	bIsTriangulated = true;
}
Esempio n. 4
0
void
IsoMonitor_c::close()
{
  isoaglib_assert (initialized());

  isoaglib_assert( m_arrClientC1.empty() );
  isoaglib_assert( mvec_saClaimHandler.empty() );

  getSchedulerInstance().deregisterTask( *this );

  // We can clear the list of remote nodes.
  /// NOTE: We do currently NOT call "internalIsoItemErase",
  ///       because the list of SaClaimHandlers is empty anyway.
  ///       But if the erase does some more stuff, it may be needed
  ///       to call "internalIsoItemErase" for each item instead
  ///       of just clearing the container of isoMembers.
  mvec_isoMember.clear();

  getIsoRequestPgnInstance4Comm().unregisterPGN (mt_handler, ADDRESS_CLAIM_PGN);
#ifdef USE_WORKING_SET
  getIsoRequestPgnInstance4Comm().unregisterPGN (mt_handler, WORKING_SET_MASTER_PGN);
  getIsoRequestPgnInstance4Comm().unregisterPGN (mt_handler, WORKING_SET_MEMBER_PGN);
#endif

  getIsoBusInstance4Comm().deleteFilter( mt_customer, IsoAgLib::iMaskFilter_c( 0x3FFFF00UL, ((ADDRESS_CLAIM_PGN+0xFF) << 8) ) );
#ifdef USE_WORKING_SET
  getIsoBusInstance4Comm().deleteFilter( mt_customer, IsoAgLib::iMaskFilter_c( 0x3FFFF00UL, ((WORKING_SET_MASTER_PGN) << 8) ) );
  getIsoBusInstance4Comm().deleteFilter( mt_customer, IsoAgLib::iMaskFilter_c( 0x3FFFF00UL, ((WORKING_SET_MEMBER_PGN) << 8) ) );
#endif

  setClosed();
}
Esempio n. 5
0
 void InputCell::mouseDoubleClickEvent(QMouseEvent *)
 {
   // PORT >>if(treeView()->hasMouse())
   if(treeView()->testAttribute(Qt::WA_UnderMouse))
   {
     setClosed(!closed_);
   }
 }
Esempio n. 6
0
//----------------------------------------
void ofxBox2dEdge::addVertexes(vector <ofVec2f> &pts) {
	for (int i=0; i<pts.size(); i++) {
        ofPolyline::addVertex(pts[i].x, pts[i].y);
	}
    // Temporary hack to ensure it's flagged as changed, until we
    // switch to OF 0.8.0.
    setClosed(isClosed());
}
Esempio n. 7
0
//----------------------------------------
void ofxBox2dEdge::addVertexes(ofPolyline &polyline) {
	for (int i=0; i<polyline.size(); i++) {
		ofPolyline::addVertex(polyline[i].x, polyline[i].y);
	}
    // Temporary hack to ensure it's flagged as changed, until we
    // switch to OF 0.8.0.
    setClosed(isClosed());
}
Esempio n. 8
0
RSolidData::RSolidData(const RVector& p1, const RVector& p2, const RVector& p3) :
    RPolyline() {

    appendVertex(p1);
    appendVertex(p2);
    appendVertex(p3);
    setClosed(true);
}
Esempio n. 9
0
RSolidData::RSolidData(const RTriangle& triangle) :
    RPolyline() {

    appendVertex(triangle.corner[0]);
    appendVertex(triangle.corner[1]);
    appendVertex(triangle.corner[2]);
    setClosed(true);
}
Esempio n. 10
0
//RLZ: rewrite this:
void RS_Polyline::setClosed(bool cl, double bulge) {
    Q_UNUSED(bulge);
    setClosed(cl);
    if (isClosed()) {
        endPolyline();
    } else {
        removeLastVertex();
    }
}
void LocalSocketPrivate_Unix::close()
{
	if(m_socketDescriptor && ::close(m_socketDescriptor) != 0)
	{
		m_socketDescriptor	=	0;
    setError(QStringLiteral("Could not close socket correctly: %1").arg(strerror(errno)));
	}

	setClosed();
}
Esempio n. 12
0
bool ccPolyline::initWith(ccPointCloud*& vertices, const ccPolyline& poly)
{
	bool success = true;
	if (!vertices)
	{
		ccPointCloud* cloud = dynamic_cast<ccPointCloud*>(poly.m_theAssociatedCloud);
		ccPointCloud* clone = cloud ? cloud->partialClone(&poly) : ccPointCloud::From(&poly);
		if (clone)
		{
			if (cloud)
				clone->setName(cloud->getName()); //as 'partialClone' adds the '.extract' suffix by default
			else
				clone->setGLTransformationHistory(poly.getGLTransformationHistory());
		}
		else
		{
			//not enough memory?
			ccLog::Warning("[ccPolyline::initWith] Not enough memory to duplicate vertices!");
			success = false;
		}

		vertices = clone;
	}

	if (vertices)
	{
		setAssociatedCloud(vertices);
		addChild(vertices);
		//vertices->setEnabled(false);
		assert(m_theAssociatedCloud);
		if (m_theAssociatedCloud)
			addPointIndex(0,m_theAssociatedCloud->size());
	}

	setClosed(poly.m_isClosed);
	set2DMode(poly.m_mode2D);
	setForeground(poly.m_foreground);
	setVisible(poly.isVisible());
	lockVisibility(poly.isVisiblityLocked());
	setColor(poly.m_rgbColor);
	setWidth(poly.m_width);
	showColors(poly.colorsShown());
	showVertices(poly.verticesShown());
	setVertexMarkerWidth(poly.getVertexMarkerWidth());
	setVisible(poly.isVisible());
	showArrow(m_showArrow,m_arrowIndex,m_arrowLength);
	setGlobalScale(poly.getGlobalScale());
	setGlobalShift(poly.getGlobalShift());
	setGLTransformationHistory(poly.getGLTransformationHistory());
	setMetaData(poly.metaData());
	
	return success;
}
void UBEditableGraphicsPolygonItem::addPoint(const QPointF & point)
{
    QPainterPath painterPath = path();

    if (painterPath.elementCount() == 0)
    {
        painterPath.moveTo(point); // For the first point added, we must use moveTo().
        setPath(painterPath);

        mStartEndPoint[0] = point;
    }
    else
    {
        // If clic on first point, close the polygon
        // TODO à terme : utiliser la surface de la première poignée.
        QPointF pointDepart(painterPath.elementAt(0).x, painterPath.elementAt(0).y);
        QPointF pointFin(painterPath.elementAt(painterPath.elementCount()-1).x, painterPath.elementAt(painterPath.elementCount()-1).y);


        QGraphicsEllipseItem poigneeDepart(pointDepart.x()-10, pointDepart.y()-10, 20, 20);
        QGraphicsEllipseItem poigneeFin(pointFin.x()-10, pointFin.y()-10, 20, 20);

        if (poigneeDepart.contains(point))
        {
            setClosed(true);
        }
        else
        {
            if(poigneeFin.contains(point)){
                mIsInCreationMode = false;
                mOpened = true;
            }else{
                painterPath.lineTo(point);
                setPath(painterPath);
            }
        }

        mStartEndPoint[1] = point;
    }

    if(!mClosed && !mOpened){
        UBFreeHandle *handle = new UBFreeHandle();

        addHandle(handle);

        handle->setParentItem(this);
        handle->setEditableObject(this);
        handle->setPos(point);
        handle->setId(path().elementCount()-1);
        handle->hide();
    }
}
void LocalSocketPrivate::setError(const QString& errorString)
{
// 	qDebug("[%p] LocalSocketPrivate::setError() - %s", this, qPrintable(errorString));
	
	{
		QWriteLocker		controlLock(&m_controlLock);
		m_errorString	=	errorString;
	}
	
	emit(error(errorString));
	
	setClosed();
}
Esempio n. 15
0
void BezierSpline::read_text(std::istream &is, int num_points)
{

    for (int j = 0; j < num_points; ++j)
    {
        Point point;
        is >> point[0] >> point[1] >> point[2];

        if (j == num_points-1 && (point-getControlPoint(0)).norm() < FLT_EPSILON)
            setClosed(true);
        else
            addControlPoint(point);
    }
}
bool GenericPipe<FB>::close() {
   if(isClosed()) return true;
   bool ret = true;
   if(!mCtrlData.ctrl.close()) {
      LOGE("GenericPipe failed to close ctrl");
      ret = false;
   }
   if (!mCtrlData.data.close()) {
      LOGE("GenericPipe failed to close data");
      ret = false;
   }
   setClosed();
   return ret;
}
Esempio n. 17
0
void
BaseCommon_c::close( )
{
  isoaglib_assert (initialized());
  isoaglib_assert( mvec_msgEventHandlers.empty() );

  close_specialized();
  getSchedulerInstance().deregisterTask(mt_task);

  // actually the filters aren't getting removed, but this is just a quick workaround until the Trac-classes-redesign!
  clearFilterCreated();

  setClosed();
};
bool GenericPipe::close() {
    bool ret = true;

    if(!mCtrlData.ctrl.close()) {
        ALOGE("GenericPipe failed to close ctrl");
        ret = false;
    }
    if (!mCtrlData.data.close()) {
        ALOGE("GenericPipe failed to close data");
        ret = false;
    }

    setClosed();
    return ret;
}
Esempio n. 19
0
void BezierSpline::convertFromPolyline(const Polyline &polyline, int smooth_coefficient)
{
    float scale = 1.0/smooth_coefficient;
    int n = polyline.numPoints();

    assert(n >= 2);

    for (int i = 0; i < n; ++i)
        addControlPoint(polyline.getPoint(i));

//    for (int i = 0; i < n; ++i)
//    {
//        if (i == 0) // is first
//        {
//            Eigen::Vector3f p1 = polyline.getPoint(i);
//            Eigen::Vector3f p2 = polyline.getPoint(i+1);

//            Eigen::Vector3f tangent = (p2 - p1);
//            Eigen::Vector3f q1 = p1 + scale * tangent;

//            addControlPoint(p1);
//            addControlPoint(q1);
//        } else if (i == n - 1)
//        {
//            Eigen::Vector3f p0 = polyline.getPoint(i-1);
//            Eigen::Vector3f p1 = polyline.getPoint(i);
//            Eigen::Vector3f tangent = (p1 - p0);
//            Eigen::Vector3f q0 = p1 - scale * tangent;

//            addControlPoint(q0);
//            addControlPoint(p1);
//        } else
//        {
//            Eigen::Vector3f p0 = polyline.getPoint(i-1);
//            Eigen::Vector3f p1 = polyline.getPoint(i);
//            Eigen::Vector3f p2 = polyline.getPoint(i+1);
//            Eigen::Vector3f tangent = (p2 - p0).normalized();
//            Eigen::Vector3f q0 = p1 - scale * tangent * (p1 - p0).norm();
//            Eigen::Vector3f q1 = p1 + scale * tangent * (p2 - p1).norm();

//            addControlPoint(q0);
//            addControlPoint(p1);
//            addControlPoint(q1);
//        }
//    }

    setClosed(polyline.closed());
}
Esempio n. 20
0
  /*! \brief resets the input cell. Removes all output data and
  *  restores the initial state.
  */
  void InputCell::clear()
  {
    if(evaluated_)
    {
      output_->clear();
      evaluated_ = false;
      // PORT >> layout_->remove(output_);
      layout_->removeWidget(output_);
    }

    //input_->setReadOnly(false);
    input_->setReadOnly(true);
    input_->clear();
    treeView()->setClosed(false); //Notis this
    setClosed(true);
  }
Esempio n. 21
0
void ccPolyline::importParametersFrom(const ccPolyline& poly)
{
	setClosed(poly.m_isClosed);
	set2DMode(poly.m_mode2D);
	setForeground(poly.m_foreground);
	setVisible(poly.isVisible());
	lockVisibility(poly.isVisiblityLocked());
	setColor(poly.m_rgbColor);
	setWidth(poly.m_width);
	showColors(poly.colorsShown());
	showVertices(poly.verticesShown());
	setVertexMarkerWidth(poly.getVertexMarkerWidth());
	setVisible(poly.isVisible());
	showArrow(m_showArrow,m_arrowIndex,m_arrowLength);
	setGlobalScale(poly.getGlobalScale());
	setGlobalShift(poly.getGlobalShift());
	setGLTransformationHistory(poly.getGLTransformationHistory());
	setMetaData(poly.metaData());
}
Esempio n. 22
0
Foam::IFstream::IFstream
(
    const fileName& pathname,
    streamFormat format,
    versionNumber version
)
:
    IFstreamAllocator(pathname),
    ISstream
    (
        *ifPtr_,
        "IFstream.sourceFile_",
        format,
        version,
        IFstreamAllocator::compression_
    ),
    pathname_(pathname)
{
    setClosed();

    setState(ifPtr_->rdstate());

    if (!good())
    {
        if (debug)
        {
            Info<< "IFstream::IFstream(const fileName&,"
                   "streamFormat=ASCII,"
                   "versionNumber=currentVersion) : "
                   "could not open file for input"
                << endl << info() << endl;
        }

        setBad();
    }
    else
    {
        setOpened();
    }

    lineNumber_ = 1;
}
Esempio n. 23
0
void
FsManager_c::close()
{
  isoaglib_assert (initialized());

  m_commands.close();

  getIsoMonitorInstance4Comm().deregisterControlFunctionStateHandler (mc_saClaimHandler);
  getSchedulerInstance().deregisterTask(*this);

  STL_NAMESPACE::for_each( m_commands.ml_initializingCommands.begin(), m_commands.ml_initializingCommands.end(), delete_object());
  m_commands.ml_initializingCommands.clear();

  STL_NAMESPACE::for_each( mv_communications.begin(), mv_communications.end(), delete_object());
  mv_communications.clear();

  STL_NAMESPACE::for_each( m_servers.m_serverInstances.begin(), m_servers.m_serverInstances.end(), delete_object());
  m_servers.m_serverInstances.clear();

  setClosed();
}
Esempio n. 24
0
void SessionState::removeUser(Client *user)
{
	Q_ASSERT(_clients.contains(user));

	if(user->isUploadingSnapshot()) {
		abandonSnapshotPoint();
	}

	_clients.removeOne(user);
	_userids.release(user->id());

	if(!_drawingctx[user->id()].penup)
		addToCommandStream(MessagePtr(new protocol::PenUp(user->id())));
	addToCommandStream(MessagePtr(new protocol::UserLeave(user->id())));

	// Make sure there is at least one operator in the session
	bool hasOp=false;
	foreach(const Client *c, _clients) {
		if(c->isOperator()) {
			hasOp=true;
			break;
		}
	}

	if(!hasOp && !_clients.isEmpty())
		_clients.first()->grantOp();

	// Reopen the session when the last user leaves
	if(_clients.isEmpty()) {
		setClosed(false);
	}

	user->deleteLater();

	_lastEventTime = QDateTime::currentDateTime();

	emit userDisconnected(this);
}
Esempio n. 25
0
//----------------------------------------
void ofxBox2dEdge::create(b2World * b2dworld) {
   
    bFlagShapeUpdate = false;
    
    if(size() < 2) {
		printf("need at least 3 points\n");
		return;
	}
	
	if (body != NULL) {
		b2dworld->DestroyBody(body);
		body = NULL;
	}
	
	// create the body from the world (1)
	b2BodyDef		bd;
	bd.type			= density <= 0.0 ? b2_staticBody : b2_dynamicBody;
	body			= b2dworld->CreateBody(&bd);
    
    vector<ofPoint>&pts = ofPolyline::getVertices();
	for(int i=1; i<(int)size(); i++) {
        b2EdgeShape edge;
        edge.Set(screenPtToWorldPt(pts[i-1]), screenPtToWorldPt(pts[i]));
        body->CreateFixture(&edge, density);
    }
    mesh.clear();
    mesh.setUsage(body->GetType()==b2_staticBody?GL_STATIC_DRAW:GL_DYNAMIC_DRAW);
    mesh.setMode(OF_PRIMITIVE_LINE_STRIP);
    for(int i=0; i<(int)size(); i++) {
        mesh.addVertex(ofVec3f(pts[i].x, pts[i].y));
    }
    
    // Temporary hack to ensure it's flagged as changed, until we
    // switch to OF 0.8.0.
    setClosed(isClosed());
    alive = true;
}
Esempio n. 26
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    connect(ui->actionBackground, SIGNAL(triggered()), this, SLOT(background_file_open()));
    connect(ui->actionClosed_Aperature, SIGNAL(triggered()), this, SLOT(closedapp_file_open()));
    connect(ui->actionImage_Stack, SIGNAL(triggered()), this, SLOT(imagelist_file_open()));
    connect(ui->actionRun_Experiment, SIGNAL(triggered()), this, SLOT(run_experiment()));

    set_background = false;
    set_closed = false;
    set_image_list = false;

    ui->actionClosed_Aperature->setDisabled(true);
    ui->actionImage_Stack->setDisabled(true);
    ui->actionRun_Experiment->setDisabled(true);
    ui->actionShow_Graph->setDisabled(true);

    frapmodel = new FrapModel(0);

    connect(this,SIGNAL(primaset(QString)),frapmodel,SLOT(setPrima(QString)));
    connect(this,SIGNAL(closedset(QString)),frapmodel,SLOT(setClosed(QString)));
    connect(this,SIGNAL(doselection()),frapmodel,SLOT(doSelection()));
    connect(this,SIGNAL(imagelistset(QStringList)),frapmodel,SLOT(setImageList(QStringList)));

    connect(ui->actionShow_Graph, SIGNAL(triggered()),frapmodel, SLOT(prepareLinearFit()));

    //connect(frapmodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)), ui->tableView,SLOT(dataChanged(QModelIndex,QModelIndex)));
    connect(frapmodel,SIGNAL(update_result(QString)), this, SLOT(show_result(QString)));
    connect(frapmodel,SIGNAL(plotLinearFit(int,std::vector<double>&,std::vector<double>&,std::vector<double>&,double,double)), ui->pl_widget, SLOT(plotLinearFit(int,std::vector<double>&,std::vector<double>&,std::vector<double>&,double,double)));

    ui->tabWidget->setCurrentIndex(0);
    starting_dir = "/home/jon/Programming/C/frap-tool-old";
}
Esempio n. 27
0
void ardRelay::toggle(){
    setClosed(!_closedB);
}
Esempio n. 28
0
//----------------------------------------------------------
void ofPolyline::close(){
    setClosed(true);
}
Esempio n. 29
0
//----------------------------------------------------------
void ofPolyline::clear() {
	setClosed(false);
	points.clear();
	curveVertices.clear();
    flagHasChanged();
}
Esempio n. 30
0
  /*!
   * \author Ingemar Axelsson and Anders Fernström
   * \date 2006-04-18 (update)
   *
   *\brief Sends the content of the inputcell to the evaluator.
   * Displays the result in a outputcell.
   *
   * 2005-11-01 AF, updated so the text that is sent to be evaled isn't
   * in html code.
   * 2005-11-17 AF, added a check if the result if empty, if so add
   * some default text
   * 2005-11-23 AF, added support for inserting image to output
   * 2006-04-18 AF, uses environment variable to find the plot
   *
   * Removes whitespaces and tags from the content string. Then sends
   * the content to the delegate object for evaluation. The result is
   * printed in a output cell. No indentation and syntax
   * highlightning is used in the output cell.
   *
   */
  void InputCell::eval()
  {
    input_->blockSignals(true);
    output_->blockSignals(true);

    if( hasDelegate() )
    {
      // Only the text, no html tags. /AF
      QString expr = input_->toPlainText();
      //expr = expr.simplified();

      // 2006-02-17 AF,
      evaluated_ = true;
      setClosed(false);

      // 2006-02-17 AF, set text '{evaluation expression}" during
      // evaluation of expressiuon
      output_->selectAll();
      output_->textCursor().insertText( "{evaluating expression}" );
      setOutputStyle();
      //output_->setPlainText( "{evaluating expression}" );
      output_->update();
      QCoreApplication::processEvents();
      delegate()->evalExpression(expr);

      // 2005-11-24 AF, added check to see if the user wants to quit
      if( 0 == expr.indexOf( "quit()", 0, Qt::CaseSensitive ))
      {
        qApp->closeAllWindows();
        input_->blockSignals(false);
        output_->blockSignals(false);
        return;
      }

      // get the result
      QString res = delegate()->getResult();
      QString error;
      error = delegate()->getError();

      {
        // check if resualt is empty
        if( res.isEmpty() && error.isEmpty() )
          res = "[done]";

        if( !error.isEmpty() )
          res += QString("\n") + error;

        output_->selectAll();
        output_->textCursor().insertText( res );
        //output_->setPlainText( res );
      }

      ++numEvals_;

      contentChanged();

      //Emit that the text have changed
      emit textChanged(true);
    }
    else
      cout << "Not delegate on inputcell" << endl;

    input_->blockSignals(false);
    output_->blockSignals(false);
  }