Ejemplo n.º 1
0
    //! \brief Filters the view to show only selected file type.
    void QuickOpen::filterFileTypes()
    {
        QAction *action = qobject_cast<QAction*>(sender());
        if(!action) {
            return;
        }

        Settings *settings = Settings::instance();
        int index = filterGroup->actions().indexOf(action);
        settings->setCurrentValue("quickopen/filter", QVariant(index));

        QStringList filters;
        if(action == filterNone) {
            // Default filter (show all but hidden files)
            m_model->setFilter(QDir::Dirs|QDir::AllDirs|QDir::Files|
                               QDir::Drives|QDir::NoDot|QDir::NoDotDot|
                               QDir::AllEntries);
        }
        else if(action == filterSchematics) {
            m_model->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Files);
            IContext *context = SchematicContext::instance();
            foreach(const QString &suffix, context->supportedSuffixes()) {
                filters << "*." + suffix;
            }
        }
Ejemplo n.º 2
0
// @pymethod |PyIContext|SetProperty|Sets a property on the context
PyObject *PyIContext::SetProperty(PyObject *self, PyObject *args)
{
	IContext *pIC = GetI(self);
	if ( pIC == NULL )
		return NULL;
	// @pyparm <o PyIID>|rpolicyId||GUID identifying the property to be set
	// @pyparm int|flags||Reserved, use only 0
	// @pyparm <o PyIUnknown>|pUnk||The property value
	CPFLAGS flags;
	PyObject *obrpolicyId;
	PyObject *obUnk;
	IID rpolicyId;
	IUnknown * pUnk;
	if ( !PyArg_ParseTuple(args, "OkO:SetProperty", &obrpolicyId, &flags, &obUnk) )
		return NULL;
	if (!PyWinObject_AsIID(obrpolicyId, &rpolicyId))
		return NULL;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obUnk, IID_IUnknown, (void **)&pUnk, FALSE))
		return NULL;

	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIC->SetProperty( rpolicyId, flags, pUnk );
	pUnk->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIC, IID_IContext );
	Py_INCREF(Py_None);
	return Py_None;
}
void
TimeSeriesProbeBus::onMeasurement(const wns::simulator::Time& _time,
                               const double& _value,
                               const IContext& _context)
{
    LogEntry entry;
    entry.value = _value;
    entry.time  = _time;

    for(std::vector<std::string>::const_iterator it = contextKeys.begin();
        it != contextKeys.end();
        ++it)
    {
        if(_context.knows(*it))
        {
            if(_context.isInt(*it))
            {
                entry.context.push_back(wns::Ttos(_context.getInt(*it)));
            }
            else if(_context.isString(*it))
            {
                entry.context.push_back(_context.getString(*it));
            }
        }
    }

    // Store value for later output
    logQueue.push_back(entry);
}
Ejemplo n.º 4
0
EditMode::EditMode() :
    m_splitter(new MiniSplitter),
    m_rightSplitWidgetLayout(new QVBoxLayout)
{
    setObjectName(QLatin1String("EditMode"));
    setDisplayName(tr("Edit"));
    setIcon(Utils::Icon::modeIcon(Icons::MODE_EDIT_CLASSIC,
                                  Icons::MODE_EDIT_FLAT, Icons::MODE_EDIT_FLAT_ACTIVE));
    setPriority(Constants::P_MODE_EDIT);
    setId(Constants::MODE_EDIT);

    m_rightSplitWidgetLayout->setSpacing(0);
    m_rightSplitWidgetLayout->setMargin(0);
    QWidget *rightSplitWidget = new QWidget;
    rightSplitWidget->setLayout(m_rightSplitWidgetLayout);
    auto editorPlaceHolder = new EditorManagerPlaceHolder(Constants::MODE_EDIT);
    m_rightSplitWidgetLayout->insertWidget(0, editorPlaceHolder);

    MiniSplitter *rightPaneSplitter = new MiniSplitter;
    rightPaneSplitter->insertWidget(0, rightSplitWidget);
    rightPaneSplitter->insertWidget(1, new RightPanePlaceHolder(Constants::MODE_EDIT));
    rightPaneSplitter->setStretchFactor(0, 1);
    rightPaneSplitter->setStretchFactor(1, 0);

    MiniSplitter *splitter = new MiniSplitter;
    splitter->setOrientation(Qt::Vertical);
    splitter->insertWidget(0, rightPaneSplitter);
    QWidget *outputPane = new OutputPanePlaceHolder(Constants::MODE_EDIT, splitter);
    outputPane->setObjectName(QLatin1String("EditModeOutputPanePlaceHolder"));
    splitter->insertWidget(1, outputPane);
    splitter->setStretchFactor(0, 3);
    splitter->setStretchFactor(1, 0);

    m_splitter->insertWidget(0, new NavigationWidgetPlaceHolder(Constants::MODE_EDIT));
    m_splitter->insertWidget(1, splitter);
    m_splitter->setStretchFactor(0, 0);
    m_splitter->setStretchFactor(1, 1);

    connect(ModeManager::instance(), &ModeManager::currentModeChanged,
            this, &EditMode::grabEditorManager);
    m_splitter->setFocusProxy(editorPlaceHolder);

    IContext *modeContextObject = new IContext(this);
    modeContextObject->setContext(Context(Constants::C_EDITORMANAGER));
    modeContextObject->setWidget(m_splitter);
    ICore::addContextObject(modeContextObject);

    setWidget(m_splitter);
    setContext(Context(Constants::C_EDIT_MODE,
                       Constants::C_NAVIGATION_PANE));
}
Ejemplo n.º 5
0
// @pymethod <o PyIEnumContextProps>|PyIContext|EnumContextProps|Returns an enumerator for the context properties
PyObject *PyIContext::EnumContextProps(PyObject *self, PyObject *args)
{
	IContext *pIC = GetI(self);
	if ( pIC == NULL )
		return NULL;
	IEnumContextProps * pEnumContextProps;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIC->EnumContextProps( &pEnumContextProps );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIC, IID_IContext );
	return PyCom_PyObjectFromIUnknown(pEnumContextProps, IID_IEnumContextProps, FALSE);
}
Ejemplo n.º 6
0
		EventHandle(IContext* ctx){
			mContext = ctx;
			mRpc = NULL;
			if(mContext)
				mRpc = mContext->rpcFactory();
			if(mRpc){
				mRpc->listenObj(DEFAULT_OBJ(RPC_EVENT_NAME));
				mRpc->listenIntf(DEFAULT_INTF(RPC_EVENT_NAME));
				mRpc->registMethod(RPC_EVENT_BROADCAST,false,this);
			}
		}
Ejemplo n.º 7
0
void System::SetActiveDocument(IDocument *pDocument)
{
	if (pDocument != NULL) 
	{
		IBaseInstance *pBase = dynamic_cast<IBaseInstance *>(pDocument);
		IContext *pContext = pBase->GetContext();
		this->pContext = pContext;

		// Check if the context points to the requested active document (can't be sure)
		// documents may share context and an application should be able to swap the root around
		if (pContext->GetDocument() != pDocument) {
			pLogger->Warning("Context Document differs from requested active document - swapping");
			pContext->SetDocument(pDocument);
		}

		pLogger->Debug("SetActiveDocument, doc=%p, context=%p (context_doc=%p)", pDocument, pContext,pContext->GetDocument());
	} else {
		this->pContext = NULL;
	}

}
Ejemplo n.º 8
0
// @pymethod |PyIContext|RemoveProperty|Removes a property from the context
PyObject *PyIContext::RemoveProperty(PyObject *self, PyObject *args)
{
	IContext *pIC = GetI(self);
	if ( pIC == NULL )
		return NULL;
	// @pyparm <o PyIID>|rPolicyId||GUID that identifies a context property
	PyObject *obrPolicyId;
	IID rPolicyId;
	if ( !PyArg_ParseTuple(args, "O:RemoveProperty", &obrPolicyId) )
		return NULL;
	if (!PyWinObject_AsIID(obrPolicyId, &rPolicyId))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIC->RemoveProperty( rPolicyId );
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIC, IID_IContext );
	Py_INCREF(Py_None);
	return Py_None;
}
Ejemplo n.º 9
0
// @pymethod (int, <o PyIUnknown>)|PyIContext|GetProperty|Retrieves a context property
// @rdesc Returns flags (CPFLAGS is reserved, no defined values) and the IUnknown interface set for the property 
PyObject *PyIContext::GetProperty(PyObject *self, PyObject *args)
{
	IContext *pIC = GetI(self);
	if ( pIC == NULL )
		return NULL;
	// @pyparm <o PyIID>|rGuid||GUID that identifies a context property
	CPFLAGS flags;
	PyObject *obGuid;
	IID rGuid;
	IUnknown * pUnk;
	if ( !PyArg_ParseTuple(args, "O:GetProperty", &obGuid))
		return NULL;
	if (!PyWinObject_AsIID(obGuid, &rGuid))
		return NULL;

	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIC->GetProperty( rGuid, &flags, &pUnk );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIC, IID_IContext );
	return Py_BuildValue("kN", flags, PyCom_PyObjectFromIUnknown(pUnk, IID_IUnknown, FALSE));
}
Ejemplo n.º 10
0
		status notify(string event, string data1, string data2,string data3, string data4){
			if(NULL == mContext || mRpc == NULL){
				DOUT("not inited!");
				return s_err_init;
			}
			IRpcParameter *param = mRpc->initParameter();
			if(param){
				param->setStr(mContext->getName());
				param->setStr(event);
				param->setStr(data1);
				param->setStr(data2);
				param->setStr(data3);
				param->setStr(data4);
				mRpc->asyncCall(DEFAULT_OBJ(RPC_EVENT_NAME),DEFAULT_INTF(RPC_EVENT_NAME),RPC_EVENT_BROADCAST,param);
			}
			mRpc->deinitParameter(param);
			return s_ok;
		}
Ejemplo n.º 11
0
bool
ProbeBusStub::accepts(const wns::simulator::Time& /*timestamp*/,
                      const IContext& reg)
{
    if(providerName == "")
    {
        return true;
    }

    if(reg.getInt(providerName) == filter)
    {
        return true;
    }
    else
    {
        return false;
    }
}
Ejemplo n.º 12
0
void OpenGLDrawText::Render(double t, IPluginObjectInstance *pInstance) {
	// Render bitmaps
	IContext *pContext = dynamic_cast<IBaseInstance *>(pInstance)->GetContext();
	IRenderContextParams *contextParams = (IRenderContextParams *)pContext->TopContextParamObject();
	float width = contextParams->GetWindowWidth();
	float height = contextParams->GetWindowHeight();
	float px_width = contextParams->GetFrameBufferWidth();
	float px_height = contextParams->GetFrameBufferHeight();

	//printf("win (%d,%d), fb (%d:%d)\n",(int)width,(int)height,(int)px_width,(int)px_height);

	float xfac = px_width/width;
	float yfac = px_height/height;

	unsigned int uniform_tex = 0;
	unsigned int uniform_color = 0;

	if (rendered) return;
	rendered = false;

	if (useShaders) {
		OpenGLShaderBase::ReloadIfNeeded();
		OpenGLShaderBase::Attach();
	}
	//Window mode:
	//	win (640,360), fb (1280:720)
	//	xfac/yfac 2.000000:2.000000
	//	sx/sy 0.003125:0.005556
	//Full screen:
	//   win (1280,720), fb (2560:1600)
	//   xfac/yfac 2.000000:2.222222
	//   sx/sy 0.001563:0.003086



	float sx = 2.0 / width;
	float sy = 2.0 / height;
	//float sx = xfac / width;
	//float sy = yfac / height;

	// printf("xfac/yfac %f:%f\n",xfac,yfac);
	// printf("sx/sy %f:%f\n",sx,sy);

	sx *= width/height;
	//sy *= width/height;

	// ok for retina full screen -> but NOT in windowed mode
	// sx *= xfac;
	// sy *= yfac;


//	glActiveTexture(GL_TEXTURE0);
	glPushMatrix();
	glScalef(-1,1,1);
	textureFont->SetRenderScaling(sx,sy);

	float xp,yp;
	float str_width, str_height;
	float linepos = 0;
	std::string strBase = std::string(text->v->string);


	Tokenizer tok(strBase, "\\");
	while (true) {
		std::string str = tok.NextIncludeSpace();
		if (str.empty()) break;

		textureFont->Estimate(str, &str_width, &str_height);
		xp = yp = 0;
		xp = position->v->vector[0];
		yp = position->v->vector[1] + linepos;
		switch(alignment->v->int_val) {
			case 0 :	// none, use position
				break;
			case 1 :
				xp = 0;
				break;
			case 2 :	// right
				xp = 1 - str_width;
				break;
			case 3 : 	// center
				xp = 0 - str_width/2.0f;
				break;
		}

	//	printf("alignment: %d\n",alignment->v->int_val);
		if (useblend->v->boolean == true) {
			glEnable(GL_BLEND);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
			glColor4f(color->v->rgba[0], color->v->rgba[1], color->v->rgba[2], alpha->v->float_val);
	//		glColor4f(1,1,1, alpha->v->float_val);
			glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);		
		} else {
			glColor4f(color->v->rgba[0], color->v->rgba[1], color->v->rgba[2], alpha->v->float_val);
		}
		textureFont->Draw(str,xp,yp);
		linepos -= sy * 0.5 * (float)fontSize->v->int_val;
	}
	glPopMatrix();

	if (useShaders) {
		OpenGLShaderBase::Detach();
	}
	if (useblend->v->boolean) {
		glDisable(GL_BLEND);
	}

}
Ejemplo n.º 13
0
void OpenGLShaderQuad::Render(double t, IPluginObjectInstance *pInstance) {
  IContext *pContext = dynamic_cast<IBaseInstance *>(pInstance)->GetContext();
  IRenderContextParams *contextParams = (IRenderContextParams *)pContext->TopContextParamObject();
  width = contextParams->GetFrameBufferWidth();
  height = contextParams->GetFrameBufferHeight();

  BeginOrtho();

  OpenGLShaderBase::ReloadIfNeeded();
  texture_count = 0;

  glGetError();
  program->Attach();
  unsigned int idResolution = program->GetUniform("iResolution");
  unsigned int idGlobalTime = program->GetUniform("iGlobalTime");

  // set user parameters
  SetParametersFromList(pInstance);

  if (idResolution != -1) {
    glUniform2f(idResolution, (float)width, (float)height);    
  }
  if (idGlobalTime != -1) {
    glUniform1f(idGlobalTime, (float)t);    
  }


  if (useblend->v->boolean) {
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      // glColor4f(1,1,1, alpha->v->float_val);
      // glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);    
      //glBlendFunc(GL_ONE, GL_ONE);
      //printf("%f:%f\n",t,alpha->v->float_val);
    }


  if (depthwrite->v->boolean) {
    glDepthMask(GL_TRUE);
  } else {
    glDepthMask(GL_FALSE);
  }

  if (texture->v->int_val != 0) {
      glActiveTexture(GL_TEXTURE0+texture_count);
      glBindTexture(GL_TEXTURE_2D,texture->v->int_val);
      texture_count++;
  }



  glBegin(GL_QUADS);
  /*
    glTexCoord2f(0.0f,0.0f);
    glVertex2f(-1.0f, -1.0f);
    glTexCoord2f(1.0f,0.0f);
    glVertex2f(1, -1.0f);
    glTexCoord2f(1.0f,1.0f);
    glVertex2f(1.0f, 1.0f);
    glTexCoord2f(0.0f,1.0f);
    glVertex2f(-1.0f, 1.0f);
    */
    for(int i=0;i<texture_count;i++) glMultiTexCoord2f(GL_TEXTURE0+i,0.0f,0.0f);
    glVertex2f(-1.0f, -1.0f);
    for(int i=0;i<texture_count;i++) glMultiTexCoord2f(GL_TEXTURE0+i,1.0f,0.0f);
    glVertex2f(1, -1.0f);
    for(int i=0;i<texture_count;i++) glMultiTexCoord2f(GL_TEXTURE0+i,1.0f,1.0f);
    glVertex2f(1.0f, 1.0f);
    for(int i=0;i<texture_count;i++) glMultiTexCoord2f(GL_TEXTURE0+i,0.0f,1.0f);
    glVertex2f(-1.0f, 1.0f);
  glEnd();  //glBegin(GL_QUADS);


  if (texture_count > 0) {
      for(int i=0;i<texture_count;i++) {
        glActiveTexture(GL_TEXTURE0+i);
        glBindTexture(GL_TEXTURE_2D, 0);
      }
      glActiveTexture(GL_TEXTURE0);    // set this back to 0 other wise the active texture is still valid
      glDisable(GL_TEXTURE_2D);

  }
  if (useblend->v->boolean) {
      glDisable(GL_BLEND);
  }

  program->Detach();

  EndOrtho();
  //glDisable(GL_TEXTURE_2D);
  glDepthMask(GL_TRUE);
}
Ejemplo n.º 14
0
    void Renderer::Render(const Camera& cam, IContext& c){
#if ZEUS_SAFE
        if (c.GetType() != IContext::OpenGL21) throw Exception("Context not supported by renderer: " + Utils::ToString<IContext::Type>(c.GetType()));
#endif
        Context& glContext = (Context&)c;

        // Draw scene
        ApplyCamera(cam, c);

        glEnable(GL_CULL_FACE);

        // @TODO Setup light. Lightmaps 'n shit
        glEnable(GL_COLOR_MATERIAL);
        glEnable(GL_LIGHTING);
        glEnable(GL_LIGHT0);
        Vector3 dir = Vector3(1,3,2);
        Normalize(dir);
        float hat[4]; dir.GetData(hat); hat[3] = 1.0f;
        glLightfv(GL_LIGHT0, GL_POSITION, hat);


        SceneObjectList::iterator itr = SceneObjectList::Begin();
        while (itr != SceneObjectList::End()){
            //Debug::Log("Rendering " + (*itr)->GetName());
            
            const ModelComponent* m = (*itr)->GetComponent<ModelComponent>();
            if (m){
                //Debug::Log((*itr)->GetName() + " has mesh");
                const ModelPropertiesPtr props = m->GetModelProperties();
                if (props) {
                    ModelProperties::Texture2DIterator itr = props->Texture2DBegin();
                    while (itr != props->Texture2DEnd()) {
                        const GLTexture2D* tex = glContext.AddTexture(itr->second);
                        glBindTexture(GL_TEXTURE_2D, tex->GetID());
                        glEnable(GL_TEXTURE_2D);
                        ++itr;
                    }
                } else {
                    glBindTexture(GL_TEXTURE_2D, 0);
                    glDisable(GL_TEXTURE_2D);
                }

                const MeshPtr mesh = m->GetMesh();
                if (mesh) {
                    const Transformation* t = (*itr)->GetComponent<Transformation>();
                    glPushMatrix();
                    Matrix4x4 m = t->GetAccumulatedMatrix();
                    glMultMatrixf(m.GetData());
                    
                    // @TODO Apply material

                    const GLMesh* mInfo = glContext.AddMesh(mesh);
                    RenderModel(*mInfo, glContext);
                    
                    glPopMatrix();
                }
            }
            ++itr;
        }

        glDisable(GL_COLOR_MATERIAL);
        glDisable(GL_LIGHTING);
        glDisable(GL_LIGHT0);

        glDisable(GL_CULL_FACE);
    }
Ejemplo n.º 15
0
void OpenGLShaderQuad::Render(double t, IPluginObjectInstance *pInstance) {
  IContext *pContext = dynamic_cast<IBaseInstance *>(pInstance)->GetContext();
  IRenderContextParams *contextParams = (IRenderContextParams *)pContext->TopContextParamObject();
  width = contextParams->GetFrameBufferWidth();
  height = contextParams->GetFrameBufferHeight();

  BeginOrtho();

  OpenGLShaderBase::ReloadIfNeeded();


  program->Attach();
  unsigned int idResolution = program->GetUniform("iResolution");
  unsigned int idGlobalTime = program->GetUniform("iGlobalTime");

  if (idResolution != -1) {
    glUniform2f(idResolution, (float)width, (float)height);    
  }
  if (idGlobalTime != -1) {
    glUniform1f(idGlobalTime, (float)t);    
  }

  // set user parameters
  SetParametersFromList(pInstance);


  if (depthwrite->v->boolean) {
    glDepthMask(GL_TRUE);
  } else {
    glDepthMask(GL_FALSE);
  }

  bool bUseTexture = false;
  if (texture->v->int_val != 0) {
      glBindTexture(GL_TEXTURE_2D,texture->v->int_val);
      glEnable(GL_TEXTURE_2D);
      bUseTexture = true;
  }


  glBegin(GL_QUADS);
    glTexCoord2f(0.0f,0.0f);
    glVertex2f(-1.0f, -1.0f);
    glTexCoord2f(1.0f,0.0f);
    glVertex2f(1, -1.0f);
    glTexCoord2f(1.0f,1.0f);
    glVertex2f(1.0f, 1.0f);
    glTexCoord2f(0.0f,1.0f);
    glVertex2f(-1.0f, 1.0f);
  glEnd();  //glBegin(GL_QUADS);

  if (bUseTexture) {
      glDisable(GL_TEXTURE_2D);
  }


  EndOrtho();
  program->Detach();
  //glDisable(GL_TEXTURE_2D);
  glDepthMask(GL_TRUE);
}